testing

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 56 Imported by: 0

Documentation

Index

Constants

View Source
const LogConsole = true

Variables

View Source
var DefaultLogLevels = config.LogLevel{}.
	Parse(config.DefaultLogLevels).
	SetModule("restore", "error").
	String()

Functions

func AcmeLiteAddress

func AcmeLiteAddress(pubKey []byte) *url.URL

AcmeLiteAddress creates an ACME lite address for the given key. FOR TESTING USE ONLY.

func AcmeLiteAddressStdPriv

func AcmeLiteAddressStdPriv(key ed25519.PrivateKey) *url.URL

func AcmeLiteAddressTmPriv

func AcmeLiteAddressTmPriv(key tmcrypto.PrivKey) *url.URL

func AddCredits

func AddCredits(db DB, account *url.URL, credits float64) error

func BuildTestTokenTxGenTx

func BuildTestTokenTxGenTx(sponsor ed25519.PrivateKey, destAddr string, amount uint64) (*protocol.Envelope, error)

func BvnIdForTest added in v1.0.0

func BvnIdForTest(t testing.TB) string

func BvnUrlForTest added in v1.0.0

func BvnUrlForTest(t testing.TB) *url.URL

func CreateADI

func CreateADI(db DB, key tmed25519.PrivKey, urlStr types.String) error

func CreateAccount added in v0.6.0

func CreateAccount(db DB, account protocol.FullAccount) error

func CreateAdiWithCredits

func CreateAdiWithCredits(db DB, key tmed25519.PrivKey, urlStr types.String, credits float64) error

func CreateKeyBook

func CreateKeyBook(db DB, urlStr types.String, publicKey tmed25519.PubKey) error

func CreateKeyPage

func CreateKeyPage(db DB, bookUrlStr types.String, keys ...tmed25519.PubKey) error

func CreateLiteIdentity added in v0.6.0

func CreateLiteIdentity(db DB, accUrl string, credits float64) error

func CreateLiteTokenAccount

func CreateLiteTokenAccount(db DB, key tmed25519.PrivKey, tokens float64) error

func CreateLiteTokenAccountWithCredits

func CreateLiteTokenAccountWithCredits(db DB, key tmed25519.PrivKey, tokens, credits float64) error

func CreateSubADI added in v0.5.1

func CreateSubADI(db DB, originUrlStr types.String, urlStr types.String) error

func CreateTestNet

func CreateTestNet(t testing.TB, numBvns, numValidators, numFollowers int, withFactomAddress bool) ([]string, map[string][]*accumulated.Daemon)

func CreateTokenAccount

func CreateTokenAccount(db DB, accUrl, tokenUrl string, tokens float64, lite bool) error

func CreateTokenIssuer

func CreateTokenIssuer(db DB, urlStr, symbol string, precision uint64, supplyLimit *big.Int) error

func DefaultConfig

func DefaultConfig(networkName string, net config.NetworkType, node config.NodeType, netId string) *config.Config

func DirectJrpcClient added in v1.0.0

func DirectJrpcClient(jrpc *api.JrpcMethods) *client.Client

DirectJrpcClient returns a client that executes HTTP requests directly without going through a TCP connection.

func DisableDebugFeatures added in v1.0.0

func DisableDebugFeatures()

func EnableDebugFeatures added in v0.6.0

func EnableDebugFeatures()

func GenerateKey

func GenerateKey(seed ...interface{}) ed25519.PrivateKey

func GenerateTmKey added in v0.5.1

func GenerateTmKey(seed ...interface{}) tmed25519.PrivKey

func GetIP

func GetIP() net.IP

func GetIPs

func GetIPs(n int) []net.IP

func NewTestLogger added in v0.6.0

func NewTestLogger(t testing.TB) log.Logger

func ParseUrl added in v1.0.0

func ParseUrl(s string) (*url.URL, error)

func RunTestNet

func RunTestNet(t testing.TB, partitions []string, daemons map[string][]*accumulated.Daemon)

func SkipCI

func SkipCI(t testing.TB, reason string)

SkipCI skips a test when running in CI.

func SkipLong

func SkipLong(t testing.TB)

SkipLong skips a long test when running in -short mode.

func SkipPlatform

func SkipPlatform(t testing.TB, goos, reason string)

SkipPlatform skips a test when on a specific GOOS.

func SkipPlatformCI

func SkipPlatformCI(t testing.TB, goos, reason string)

SkipPlatformCI skips a test when running in CI on a specific GOOS.

func UpdateAccount added in v0.6.0

func UpdateAccount[T protocol.Account](db DB, accountUrl *url.URL, fn func(T)) error

func UpdateKeyPage added in v0.5.1

func UpdateKeyPage(db DB, account *url.URL, fn func(*protocol.KeyPage)) error

func WriteStates

func WriteStates(db DB, chains ...protocol.Account) error

Types

type BatchTest added in v0.6.0

type BatchTest struct {
	*testing.T
	*database.Batch
}

func NewBatchTest added in v0.6.0

func NewBatchTest(t *testing.T, beginner database.Beginner) BatchTest

func (*BatchTest) AddSignature added in v0.6.0

func (t *BatchTest) AddSignature(txnHash []byte, keyEntryIndex uint64, sig protocol.Signature)

func (*BatchTest) GetSignatures added in v0.6.0

func (t *BatchTest) GetSignatures(txnHash []byte, signer *url.URL) *database.SignatureSet

func (*BatchTest) GetTxnStatus added in v0.6.0

func (t *BatchTest) GetTxnStatus(txnHash []byte) *protocol.TransactionStatus

func (*BatchTest) PutAccount added in v0.6.0

func (t *BatchTest) PutAccount(account protocol.Account)

func (*BatchTest) PutAccountCopy added in v0.6.0

func (t *BatchTest) PutAccountCopy(account protocol.Account) protocol.Account

func (BatchTest) Run added in v0.6.0

func (t BatchTest) Run(name string, run func(t BatchTest))

type DB

type DB = *database.Batch

type FakeAccount added in v0.6.0

type FakeAccount struct {
	FakeLiteAccount
	protocol.AccountAuth
	// contains filtered or unexported fields
}

func (*FakeAccount) Copy added in v0.6.0

func (v *FakeAccount) Copy() *FakeAccount

func (*FakeAccount) CopyAsInterface added in v0.6.0

func (v *FakeAccount) CopyAsInterface() interface{}

func (*FakeAccount) Equal added in v0.6.0

func (v *FakeAccount) Equal(u *FakeAccount) bool

func (*FakeAccount) GetAuth added in v0.6.0

func (f *FakeAccount) GetAuth() *protocol.AccountAuth

func (*FakeAccount) IsValid added in v0.6.0

func (v *FakeAccount) IsValid() error

func (*FakeAccount) MarshalBinary added in v0.6.0

func (v *FakeAccount) MarshalBinary() ([]byte, error)

func (*FakeAccount) UnmarshalBinary added in v0.6.0

func (v *FakeAccount) UnmarshalBinary(data []byte) error

func (*FakeAccount) UnmarshalBinaryFrom added in v0.6.0

func (v *FakeAccount) UnmarshalBinaryFrom(rd io.Reader) error

type FakeAuthority added in v0.6.0

type FakeAuthority struct {
	FakeAccount
	Signers *url.URL `json:"signers,omitempty" form:"signers" query:"signers" validate:"required"`
	// contains filtered or unexported fields
}

func (*FakeAuthority) Copy added in v0.6.0

func (v *FakeAuthority) Copy() *FakeAuthority

func (*FakeAuthority) CopyAsInterface added in v0.6.0

func (v *FakeAuthority) CopyAsInterface() interface{}

func (*FakeAuthority) Equal added in v0.6.0

func (v *FakeAuthority) Equal(u *FakeAuthority) bool

func (*FakeAuthority) IsValid added in v0.6.0

func (v *FakeAuthority) IsValid() error

func (*FakeAuthority) MarshalBinary added in v0.6.0

func (v *FakeAuthority) MarshalBinary() ([]byte, error)

func (*FakeAuthority) UnmarshalBinary added in v0.6.0

func (v *FakeAuthority) UnmarshalBinary(data []byte) error

func (*FakeAuthority) UnmarshalBinaryFrom added in v0.6.0

func (v *FakeAuthority) UnmarshalBinaryFrom(rd io.Reader) error

type FakeLiteAccount added in v0.6.0

type FakeLiteAccount struct {
	TheType protocol.AccountType `json:"theType,omitempty" form:"theType" query:"theType" validate:"required"`
	Url     *url.URL             `json:"url,omitempty" form:"url" query:"url" validate:"required"`
	// contains filtered or unexported fields
}

func (*FakeLiteAccount) Copy added in v0.6.0

func (v *FakeLiteAccount) Copy() *FakeLiteAccount

func (*FakeLiteAccount) CopyAsInterface added in v0.6.0

func (v *FakeLiteAccount) CopyAsInterface() interface{}

func (*FakeLiteAccount) Equal added in v0.6.0

func (v *FakeLiteAccount) Equal(u *FakeLiteAccount) bool

func (*FakeLiteAccount) GetUrl added in v0.6.0

func (f *FakeLiteAccount) GetUrl() *url.URL

func (*FakeLiteAccount) IsValid added in v0.6.0

func (v *FakeLiteAccount) IsValid() error

func (*FakeLiteAccount) MarshalBinary added in v0.6.0

func (v *FakeLiteAccount) MarshalBinary() ([]byte, error)

func (*FakeLiteAccount) StripUrl added in v1.0.0

func (f *FakeLiteAccount) StripUrl()

func (*FakeLiteAccount) Type added in v0.6.0

func (*FakeLiteAccount) UnmarshalBinary added in v0.6.0

func (v *FakeLiteAccount) UnmarshalBinary(data []byte) error

func (*FakeLiteAccount) UnmarshalBinaryFrom added in v0.6.0

func (v *FakeLiteAccount) UnmarshalBinaryFrom(rd io.Reader) error

type FakeSignature added in v0.6.0

type FakeSignature struct {
	TheType       protocol.SignatureType `json:"theType,omitempty" form:"theType" query:"theType" validate:"required"`
	Vote          protocol.VoteType      `json:"vote,omitempty" form:"vote" query:"vote" validate:"required"`
	PublicKey     []byte                 `json:"publicKey,omitempty" form:"publicKey" query:"publicKey" validate:"required"`
	Signer        *url.URL               `json:"signer,omitempty" form:"signer" query:"signer" validate:"required"`
	SignerVersion uint64                 `json:"signerVersion,omitempty" form:"signerVersion" query:"signerVersion" validate:"required"`
	Timestamp     uint64                 `json:"timestamp,omitempty" form:"timestamp" query:"timestamp"`
	// contains filtered or unexported fields
}

func (*FakeSignature) Copy added in v0.6.0

func (v *FakeSignature) Copy() *FakeSignature

func (*FakeSignature) CopyAsInterface added in v0.6.0

func (v *FakeSignature) CopyAsInterface() interface{}

func (*FakeSignature) Equal added in v0.6.0

func (v *FakeSignature) Equal(u *FakeSignature) bool

func (*FakeSignature) GetPublicKey added in v0.6.0

func (f *FakeSignature) GetPublicKey() []byte

func (*FakeSignature) GetPublicKeyHash added in v0.6.0

func (f *FakeSignature) GetPublicKeyHash() []byte

func (*FakeSignature) GetSignature added in v0.6.0

func (f *FakeSignature) GetSignature() []byte

func (*FakeSignature) GetSigner added in v0.6.0

func (f *FakeSignature) GetSigner() *url.URL

func (*FakeSignature) GetSignerVersion added in v0.6.0

func (f *FakeSignature) GetSignerVersion() uint64

func (*FakeSignature) GetTimestamp added in v0.6.0

func (f *FakeSignature) GetTimestamp() uint64

func (*FakeSignature) GetTransactionHash added in v0.6.0

func (f *FakeSignature) GetTransactionHash() [32]byte

func (*FakeSignature) GetVote added in v0.6.0

func (f *FakeSignature) GetVote() protocol.VoteType

func (*FakeSignature) Hash added in v0.6.0

func (f *FakeSignature) Hash() []byte

func (*FakeSignature) Initiator added in v0.6.0

func (f *FakeSignature) Initiator() (hash.Hasher, error)

func (*FakeSignature) IsValid added in v0.6.0

func (v *FakeSignature) IsValid() error

func (*FakeSignature) MarshalBinary added in v0.6.0

func (v *FakeSignature) MarshalBinary() ([]byte, error)

func (*FakeSignature) MarshalJSON added in v0.6.0

func (v *FakeSignature) MarshalJSON() ([]byte, error)

func (*FakeSignature) Metadata added in v0.6.0

func (f *FakeSignature) Metadata() protocol.Signature

func (*FakeSignature) RoutingLocation added in v0.6.0

func (f *FakeSignature) RoutingLocation() *url.URL

func (*FakeSignature) Type added in v0.6.0

func (*FakeSignature) UnmarshalBinary added in v0.6.0

func (v *FakeSignature) UnmarshalBinary(data []byte) error

func (*FakeSignature) UnmarshalBinaryFrom added in v0.6.0

func (v *FakeSignature) UnmarshalBinaryFrom(rd io.Reader) error

func (*FakeSignature) UnmarshalJSON added in v0.6.0

func (v *FakeSignature) UnmarshalJSON(data []byte) error

func (*FakeSignature) Verify added in v0.6.0

func (f *FakeSignature) Verify(sigMdHash, hash []byte) bool

type FakeSigner added in v0.6.0

type FakeSigner struct {
	FakeLiteAccount
	CreditBalance uint64              `json:"creditBalance,omitempty" form:"creditBalance" query:"creditBalance" validate:"required"`
	Threshold     uint64              `json:"threshold,omitempty" form:"threshold" query:"threshold" validate:"required"`
	Version       uint64              `json:"version,omitempty" form:"version" query:"version" validate:"required"`
	Keys          []*protocol.KeySpec `json:"keys,omitempty" form:"keys" query:"keys" validate:"required"`
	// contains filtered or unexported fields
}

func (*FakeSigner) CanDebitCredits added in v0.6.0

func (f *FakeSigner) CanDebitCredits(amount uint64) bool

func (*FakeSigner) Copy added in v0.6.0

func (v *FakeSigner) Copy() *FakeSigner

func (*FakeSigner) CopyAsInterface added in v0.6.0

func (v *FakeSigner) CopyAsInterface() interface{}

func (*FakeSigner) CreditCredits added in v0.6.0

func (f *FakeSigner) CreditCredits(amount uint64)

func (*FakeSigner) DebitCredits added in v0.6.0

func (f *FakeSigner) DebitCredits(amount uint64) bool

func (*FakeSigner) EntryByDelegate added in v0.6.0

func (f *FakeSigner) EntryByDelegate(owner *url.URL) (int, protocol.KeyEntry, bool)

func (*FakeSigner) EntryByKey added in v0.6.0

func (f *FakeSigner) EntryByKey(key []byte) (int, protocol.KeyEntry, bool)

func (*FakeSigner) EntryByKeyHash added in v0.6.0

func (f *FakeSigner) EntryByKeyHash(keyHash []byte) (int, protocol.KeyEntry, bool)

func (*FakeSigner) Equal added in v0.6.0

func (v *FakeSigner) Equal(u *FakeSigner) bool

func (*FakeSigner) GetCreditBalance added in v0.6.0

func (f *FakeSigner) GetCreditBalance() uint64

func (*FakeSigner) GetSignatureThreshold added in v0.6.0

func (f *FakeSigner) GetSignatureThreshold() uint64

func (*FakeSigner) GetVersion added in v0.6.0

func (f *FakeSigner) GetVersion() uint64

func (*FakeSigner) IsValid added in v0.6.0

func (v *FakeSigner) IsValid() error

func (*FakeSigner) MarshalBinary added in v0.6.0

func (v *FakeSigner) MarshalBinary() ([]byte, error)

func (*FakeSigner) MarshalJSON added in v0.6.0

func (v *FakeSigner) MarshalJSON() ([]byte, error)

func (*FakeSigner) UnmarshalBinary added in v0.6.0

func (v *FakeSigner) UnmarshalBinary(data []byte) error

func (*FakeSigner) UnmarshalBinaryFrom added in v0.6.0

func (v *FakeSigner) UnmarshalBinaryFrom(rd io.Reader) error

func (*FakeSigner) UnmarshalJSON added in v0.6.0

func (v *FakeSigner) UnmarshalJSON(data []byte) error

type FakeTendermint

type FakeTendermint struct {
	// contains filtered or unexported fields
}

FakeTendermint is a test harness that facilitates testing the ABCI application without creating an actual Tendermint node.

func NewFakeTendermint

func NewFakeTendermint(app <-chan abci.Application, db *database.Database, network *config.Describe, pubKey crypto.PubKey, logger log.Logger, nextHeight func() int64, onError func(err error), interval time.Duration, isEvil bool) *FakeTendermint

func (*FakeTendermint) ABCIQuery

func (c *FakeTendermint) ABCIQuery(ctx context.Context, path string, data tmbytes.HexBytes) (*ctypes.ResultABCIQuery, error)

func (*FakeTendermint) ABCIQueryWithOptions

func (c *FakeTendermint) ABCIQueryWithOptions(ctx context.Context, path string, data tmbytes.HexBytes, opts rpc.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)

func (*FakeTendermint) App

func (c *FakeTendermint) App() abci.Application

func (*FakeTendermint) BroadcastTxAsync

func (c *FakeTendermint) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)

func (*FakeTendermint) BroadcastTxSync

func (c *FakeTendermint) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)

func (*FakeTendermint) CheckTx

func (c *FakeTendermint) CheckTx(ctx context.Context, tx types.Tx) (*ctypes.ResultCheckTx, error)

func (*FakeTendermint) Shutdown

func (c *FakeTendermint) Shutdown()

func (*FakeTendermint) Status added in v1.0.0

func (*FakeTendermint) SubmitTx

func (c *FakeTendermint) SubmitTx(ctx context.Context, tx types.Tx, check bool) *txStatus

func (*FakeTendermint) Tx

func (c *FakeTendermint) Tx(ctx context.Context, hash []byte, prove bool) (*ctypes.ResultTx, error)

func (*FakeTendermint) Validators added in v0.5.1

func (c *FakeTendermint) Validators() []crypto.PubKey

type FakeTransactionBody added in v0.6.0

type FakeTransactionBody struct {
	TheType protocol.TransactionType `json:"theType,omitempty" form:"theType" query:"theType" validate:"required"`
	// contains filtered or unexported fields
}

func (*FakeTransactionBody) Copy added in v0.6.0

func (*FakeTransactionBody) CopyAsInterface added in v0.6.0

func (v *FakeTransactionBody) CopyAsInterface() interface{}

func (*FakeTransactionBody) Equal added in v0.6.0

func (*FakeTransactionBody) IsValid added in v0.6.0

func (v *FakeTransactionBody) IsValid() error

func (*FakeTransactionBody) MarshalBinary added in v0.6.0

func (v *FakeTransactionBody) MarshalBinary() ([]byte, error)

func (*FakeTransactionBody) Type added in v0.6.0

func (*FakeTransactionBody) UnmarshalBinary added in v0.6.0

func (v *FakeTransactionBody) UnmarshalBinary(data []byte) error

func (*FakeTransactionBody) UnmarshalBinaryFrom added in v0.6.0

func (v *FakeTransactionBody) UnmarshalBinaryFrom(rd io.Reader) error

type MerkleTestCase added in v1.0.0

type MerkleTestCase struct {
	Root    YamlHexString
	Entries []YamlHexString
	Cascade []YamlHexString
}

type NullRouter added in v0.5.1

type NullRouter struct{}

func (NullRouter) Query added in v0.5.1

func (NullRouter) Query(ctx context.Context, partition string, query []byte, opts client.ABCIQueryOptions) (*core.ResultABCIQuery, error)

func (NullRouter) RequestAPIv2 added in v1.0.0

func (NullRouter) RequestAPIv2(ctx context.Context, partitionId, method string, params, result interface{}) error

func (NullRouter) Route added in v0.5.1

func (NullRouter) Route(...*protocol.Envelope) (string, error)

func (NullRouter) RouteAccount added in v0.5.1

func (NullRouter) RouteAccount(*url.URL) (string, error)

func (NullRouter) Submit added in v0.5.1

func (NullRouter) Submit(ctx context.Context, partition string, tx *protocol.Envelope, pretend, async bool) (*routing.ResponseSubmit, error)

type TransactionBuilder

type TransactionBuilder struct {
	*protocol.Envelope

	SkipChecks bool
	// contains filtered or unexported fields
}

func NewTransaction

func NewTransaction() TransactionBuilder

func (TransactionBuilder) Build added in v0.6.0

func (tb TransactionBuilder) Build() *protocol.Envelope

func (TransactionBuilder) BuildDelivery added in v1.0.0

func (tb TransactionBuilder) BuildDelivery() *chain.Delivery

func (TransactionBuilder) Faucet added in v0.5.1

func (tb TransactionBuilder) Faucet() *protocol.Envelope

func (TransactionBuilder) Initiate added in v0.5.1

func (tb TransactionBuilder) Initiate(typ protocol.SignatureType, privateKey []byte) TransactionBuilder

func (TransactionBuilder) InitiateSynthetic added in v0.5.1

func (tb TransactionBuilder) InitiateSynthetic(destPartitionUrl *url.URL) TransactionBuilder

func (TransactionBuilder) SetSigner added in v1.0.0

func (TransactionBuilder) Sign

func (TransactionBuilder) SignFunc added in v1.0.0

func (TransactionBuilder) Unsafe added in v1.0.0

Unsafe allows the caller to generate invalid signatures

func (TransactionBuilder) UseSimpleHash added in v1.0.0

func (tb TransactionBuilder) UseSimpleHash() TransactionBuilder

func (TransactionBuilder) WithBody

func (TransactionBuilder) WithCurrentTimestamp added in v0.5.1

func (tb TransactionBuilder) WithCurrentTimestamp() TransactionBuilder

func (TransactionBuilder) WithDelegator added in v0.6.0

func (tb TransactionBuilder) WithDelegator(delegator *url.URL) TransactionBuilder

func (TransactionBuilder) WithHeader

func (TransactionBuilder) WithPrincipal added in v0.5.1

func (tb TransactionBuilder) WithPrincipal(origin *url.URL) TransactionBuilder

func (TransactionBuilder) WithSigner added in v0.5.1

func (tb TransactionBuilder) WithSigner(signer *url.URL, height uint64) TransactionBuilder

func (TransactionBuilder) WithTimestamp added in v0.5.1

func (tb TransactionBuilder) WithTimestamp(nonce uint64) TransactionBuilder

func (TransactionBuilder) WithTimestampVar added in v0.6.0

func (tb TransactionBuilder) WithTimestampVar(nonce *uint64) TransactionBuilder

func (TransactionBuilder) WithTransaction added in v1.0.0

func (tb TransactionBuilder) WithTransaction(txn *protocol.Transaction) TransactionBuilder

func (TransactionBuilder) WithTxnHash

func (tb TransactionBuilder) WithTxnHash(hash []byte) TransactionBuilder

type YamlHexString added in v1.0.0

type YamlHexString []byte

func (*YamlHexString) UnmarshalYAML added in v1.0.0

func (s *YamlHexString) UnmarshalYAML(value *yaml.Node) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL