Esempio n. 1
0
func newRandomService() (servicespec.Random, error) {
	newConfig := random.DefaultConfig()
	newConfig.BackoffFactory = func() spec.Backoff {
		return backoff.NewExponentialBackOff()
	}
	newService, err := random.New(newConfig)
	if err != nil {
		return nil, maskAny(err)
	}

	return newService, nil
}
Esempio n. 2
0
func Test_IDService_WithType_Error(t *testing.T) {
	// Create custom random service with timeout config.
	newRandomServiceConfig := random.DefaultConfig()
	newRandomServiceConfig.RandFactory = func(randReader io.Reader, max *big.Int) (n *big.Int, err error) {
		return nil, maskAny(invalidConfigError)
	}
	newRandomService, err := random.New(newRandomServiceConfig)
	if err != nil {
		t.Fatal("expected", nil, "got", err)
	}

	newConfig := DefaultConfig()
	newConfig.RandomService = newRandomService
	newService, err := New(newConfig)
	if err != nil {
		t.Fatal("expected", nil, "got", err)
	}

	_, err = newService.WithType(Hex128)
	if !IsInvalidConfig(err) {
		t.Fatal("expected", nil, "got", err)
	}
}