testing

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 47 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) (*messaging.Envelope, error)

func BvnIdForTest

func BvnIdForTest(t testing.TB) string

func BvnUrlForTest

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

func CreateADI

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

func CreateAccount

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

func CreateAdiWithCredits

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

func CreateKeyBook

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

func CreateKeyPage

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

func CreateLiteIdentity

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

func CreateSubADI(db DB, originUrlStr string, urlStr 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 protocol.PartitionType, node config.NodeType, netId string) *config.Config

func DirectJrpcClient

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

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

func DisableDebugFeatures

func DisableDebugFeatures()

func EnableDebugFeatures

func EnableDebugFeatures()

func GenerateKey

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

func GenerateTmKey

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

func GetIP

func GetIP() net.IP

func GetIPs

func GetIPs(n int) []net.IP

func NewTestLogger

func NewTestLogger(t testing.TB) log.Logger

func ParseUrl

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

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

func UpdateKeyPage

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

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

func NewBatchTest

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

func (*BatchTest) AddSignature

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

func (*BatchTest) GetSignatures

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

func (*BatchTest) GetTxnStatus

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

func (*BatchTest) PutAccount

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

func (*BatchTest) PutAccountCopy

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

func (BatchTest) Run

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

type DB

type DB = *database.Batch

type FakeAccount

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

func (*FakeAccount) Copy

func (v *FakeAccount) Copy() *FakeAccount

func (*FakeAccount) CopyAsInterface

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

func (*FakeAccount) Equal

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

func (*FakeAccount) GetAuth

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

func (*FakeAccount) IsValid

func (v *FakeAccount) IsValid() error

func (*FakeAccount) MarshalBinary

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

func (*FakeAccount) MarshalJSON

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

func (*FakeAccount) UnmarshalBinary

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

func (*FakeAccount) UnmarshalBinaryFrom

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

func (*FakeAccount) UnmarshalFieldsFrom

func (*FakeAccount) UnmarshalFieldsFrom(*encoding.Reader) error

func (*FakeAccount) UnmarshalJSON

func (v *FakeAccount) UnmarshalJSON(b []byte) error

type FakeAuthority

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

func (*FakeAuthority) Copy

func (v *FakeAuthority) Copy() *FakeAuthority

func (*FakeAuthority) CopyAsInterface

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

func (*FakeAuthority) Equal

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

func (*FakeAuthority) IsValid

func (v *FakeAuthority) IsValid() error

func (*FakeAuthority) MarshalBinary

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

func (*FakeAuthority) MarshalJSON

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

func (*FakeAuthority) UnmarshalBinary

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

func (*FakeAuthority) UnmarshalBinaryFrom

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

func (*FakeAuthority) UnmarshalJSON

func (v *FakeAuthority) UnmarshalJSON(b []byte) error

type FakeLiteAccount

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

func (v *FakeLiteAccount) Copy() *FakeLiteAccount

func (*FakeLiteAccount) CopyAsInterface

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

func (*FakeLiteAccount) Equal

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

func (*FakeLiteAccount) GetUrl

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

func (*FakeLiteAccount) IsValid

func (v *FakeLiteAccount) IsValid() error

func (*FakeLiteAccount) MarshalBinary

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

func (*FakeLiteAccount) MarshalJSON

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

func (*FakeLiteAccount) StripUrl

func (f *FakeLiteAccount) StripUrl()

func (*FakeLiteAccount) Type

func (*FakeLiteAccount) UnmarshalBinary

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

func (*FakeLiteAccount) UnmarshalBinaryFrom

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

func (*FakeLiteAccount) UnmarshalFieldsFrom

func (*FakeLiteAccount) UnmarshalFieldsFrom(*encoding.Reader) error

func (*FakeLiteAccount) UnmarshalJSON

func (v *FakeLiteAccount) UnmarshalJSON(b []byte) error

type FakeSignature

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

func (v *FakeSignature) Copy() *FakeSignature

func (*FakeSignature) CopyAsInterface

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

func (*FakeSignature) Equal

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

func (*FakeSignature) GetPublicKey

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

func (*FakeSignature) GetPublicKeyHash

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

func (*FakeSignature) GetSignature

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

func (*FakeSignature) GetSigner

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

func (*FakeSignature) GetSignerVersion

func (f *FakeSignature) GetSignerVersion() uint64

func (*FakeSignature) GetTimestamp

func (f *FakeSignature) GetTimestamp() uint64

func (*FakeSignature) GetTransactionHash

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

func (*FakeSignature) GetVote

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

func (*FakeSignature) Hash

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

func (*FakeSignature) Initiator

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

func (*FakeSignature) IsValid

func (v *FakeSignature) IsValid() error

func (*FakeSignature) MarshalBinary

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

func (*FakeSignature) MarshalJSON

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

func (*FakeSignature) Metadata

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

func (*FakeSignature) RoutingLocation

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

func (*FakeSignature) Type

func (*FakeSignature) UnmarshalBinary

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

func (*FakeSignature) UnmarshalBinaryFrom

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

func (*FakeSignature) UnmarshalFieldsFrom

func (*FakeSignature) UnmarshalFieldsFrom(*encoding.Reader) error

func (*FakeSignature) UnmarshalJSON

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

func (*FakeSignature) Verify

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

type FakeSigner

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

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

func (*FakeSigner) Copy

func (v *FakeSigner) Copy() *FakeSigner

func (*FakeSigner) CopyAsInterface

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

func (*FakeSigner) CreditCredits

func (f *FakeSigner) CreditCredits(amount uint64)

func (*FakeSigner) DebitCredits

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

func (*FakeSigner) EntryByDelegate

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

func (*FakeSigner) EntryByKey

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

func (*FakeSigner) EntryByKeyHash

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

func (*FakeSigner) Equal

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

func (*FakeSigner) GetAuthority

func (f *FakeSigner) GetAuthority() *url.URL

func (*FakeSigner) GetCreditBalance

func (f *FakeSigner) GetCreditBalance() uint64

func (*FakeSigner) GetSignatureThreshold

func (f *FakeSigner) GetSignatureThreshold() uint64

func (*FakeSigner) GetVersion

func (f *FakeSigner) GetVersion() uint64

func (*FakeSigner) IsValid

func (v *FakeSigner) IsValid() error

func (*FakeSigner) MarshalBinary

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

func (*FakeSigner) MarshalJSON

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

func (*FakeSigner) UnmarshalBinary

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

func (*FakeSigner) UnmarshalBinaryFrom

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

func (*FakeSigner) UnmarshalFieldsFrom

func (*FakeSigner) UnmarshalFieldsFrom(*encoding.Reader) error

func (*FakeSigner) UnmarshalJSON

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

type FakeTransactionBody

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

func (*FakeTransactionBody) Copy

func (*FakeTransactionBody) CopyAsInterface

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

func (*FakeTransactionBody) Equal

func (*FakeTransactionBody) IsValid

func (v *FakeTransactionBody) IsValid() error

func (*FakeTransactionBody) MarshalBinary

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

func (*FakeTransactionBody) MarshalJSON

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

func (*FakeTransactionBody) Type

func (*FakeTransactionBody) UnmarshalBinary

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

func (*FakeTransactionBody) UnmarshalBinaryFrom

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

func (*FakeTransactionBody) UnmarshalFieldsFrom

func (*FakeTransactionBody) UnmarshalFieldsFrom(*encoding.Reader) error

func (*FakeTransactionBody) UnmarshalJSON

func (v *FakeTransactionBody) UnmarshalJSON(b []byte) error

type MerkleTestCase

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

type NullObserver

type NullObserver struct{}

NullObserver returns a null hash.

func (NullObserver) DidChangeAccount

func (NullObserver) DidChangeAccount(batch *database.Batch, account *database.Account) (hash.Hasher, error)

type NullRouter

type NullRouter struct{}

func (NullRouter) Query

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

func (NullRouter) Route

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

func (NullRouter) RouteAccount

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

type VisitorObserver

type VisitorObserver map[[32]byte][32]byte

VisitorObserver builds a list of hashes from a snapshot and then returns those exact same hashes.

func (VisitorObserver) DidChangeAccount

func (h VisitorObserver) DidChangeAccount(_ *database.Batch, a *database.Account) (hash.Hasher, error)

func (VisitorObserver) VisitAccount

func (h VisitorObserver) VisitAccount(a *snapshot.Account, i int) error

type YamlHexString

type YamlHexString []byte

func (*YamlHexString) UnmarshalYAML

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

Jump to

Keyboard shortcuts

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