Documentation ¶
Index ¶
- func GenerateSeed() int64
- type OverrideStringer
- type TestSuite
- func (ts *TestSuite) DecodingHex(in string) []byte
- func (ts *TestSuite) GenerateTestAccount(number int32) (*account.Account, crypto.Address)
- func (ts *TestSuite) GenerateTestBlock(height uint32) (*block.Block, *certificate.Certificate)
- func (ts *TestSuite) GenerateTestBlockWithProposer(height uint32, proposer crypto.Address) (*block.Block, *certificate.Certificate)
- func (ts *TestSuite) GenerateTestBlockWithTime(height uint32, tme time.Time) (*block.Block, *certificate.Certificate)
- func (ts *TestSuite) GenerateTestBondTx() (*tx.Tx, *bls.PrivateKey)
- func (ts *TestSuite) GenerateTestCertificate(height uint32) *certificate.Certificate
- func (ts *TestSuite) GenerateTestCommittee(num int) (committee.Committee, []*bls.ValidatorKey)
- func (ts *TestSuite) GenerateTestPrecommitVote(height uint32, round int16) (*vote.Vote, *bls.ValidatorKey)
- func (ts *TestSuite) GenerateTestPrepareVote(height uint32, round int16) (*vote.Vote, *bls.ValidatorKey)
- func (ts *TestSuite) GenerateTestProposal(height uint32, round int16) (*proposal.Proposal, *bls.ValidatorKey)
- func (ts *TestSuite) GenerateTestSortitionTx() (*tx.Tx, *bls.PrivateKey)
- func (ts *TestSuite) GenerateTestTransferTx() (*tx.Tx, *bls.PrivateKey)
- func (ts *TestSuite) GenerateTestUnbondTx() (*tx.Tx, *bls.PrivateKey)
- func (ts *TestSuite) GenerateTestValidator(number int32) (*validator.Validator, *bls.ValidatorKey)
- func (ts *TestSuite) GenerateTestWithdrawTx() (*tx.Tx, *bls.PrivateKey)
- func (ts *TestSuite) HelperSignProposal(valKey *bls.ValidatorKey, p *proposal.Proposal)
- func (ts *TestSuite) HelperSignTransaction(prv crypto.PrivateKey, trx *tx.Tx)
- func (ts *TestSuite) HelperSignVote(valKey *bls.ValidatorKey, v *vote.Vote)
- func (ts *TestSuite) RandAccAddress() crypto.Address
- func (ts *TestSuite) RandAmount() amount.Amount
- func (ts *TestSuite) RandBLSKeyPair() (*bls.PublicKey, *bls.PrivateKey)
- func (ts *TestSuite) RandBLSSignature() *bls.Signature
- func (ts *TestSuite) RandBool() bool
- func (ts *TestSuite) RandBytes(length int) []byte
- func (ts *TestSuite) RandHash() hash.Hash
- func (ts *TestSuite) RandHeight() uint32
- func (ts *TestSuite) RandInt(max int) int
- func (ts *TestSuite) RandInt16(max int16) int16
- func (ts *TestSuite) RandInt16NonZero(max int16) int16
- func (ts *TestSuite) RandInt32(max int32) int32
- func (ts *TestSuite) RandInt32NonZero(max int32) int32
- func (ts *TestSuite) RandInt64(max int64) int64
- func (ts *TestSuite) RandInt64NonZero(max int64) int64
- func (ts *TestSuite) RandIntNonZero(max int) int
- func (ts *TestSuite) RandPeerID() peer.ID
- func (ts *TestSuite) RandProof() sortition.Proof
- func (ts *TestSuite) RandRound() int16
- func (ts *TestSuite) RandSeed() sortition.VerifiableSeed
- func (ts *TestSuite) RandString(length int) string
- func (ts *TestSuite) RandUint16(max uint16) uint16
- func (ts *TestSuite) RandUint16NonZero(max uint16) uint16
- func (ts *TestSuite) RandUint32(max uint32) uint32
- func (ts *TestSuite) RandUint32NonZero(max uint32) uint32
- func (ts *TestSuite) RandUint64(max uint64) uint64
- func (ts *TestSuite) RandUint64NonZero(max uint64) uint64
- func (ts *TestSuite) RandValAddress() crypto.Address
- func (ts *TestSuite) RandValKey() *bls.ValidatorKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateSeed ¶ added in v0.15.0
func GenerateSeed() int64
Types ¶
type OverrideStringer ¶ added in v0.17.0
type OverrideStringer struct {
// contains filtered or unexported fields
}
func NewOverrideStringer ¶ added in v0.17.0
func NewOverrideStringer(name string, obj fmt.Stringer) *OverrideStringer
func (*OverrideStringer) String ¶ added in v0.17.0
func (o *OverrideStringer) String() string
type TestSuite ¶
TestSuite provides a set of helper functions for testing purposes. All the random values are generated based on a logged seed. By using a pre-generated seed, it is possible to reproduce failed tests by re-evaluating all the random values. This helps in identifying and debugging failures in testing conditions.
func NewTestSuite ¶
NewTestSuite creates a new TestSuite by generating new seed.
func NewTestSuiteForSeed ¶
NewTestSuiteForSeed creates a new TestSuite with the given seed.
func (*TestSuite) DecodingHex ¶
DecodingHex decodes the input string from hexadecimal format and returns the resulting byte slice.
func (*TestSuite) GenerateTestAccount ¶
GenerateTestAccount generates an account for testing purposes.
func (*TestSuite) GenerateTestBlock ¶
func (ts *TestSuite) GenerateTestBlock(height uint32) (*block.Block, *certificate.Certificate)
GenerateTestBlock generates a block for testing purposes.
func (*TestSuite) GenerateTestBlockWithProposer ¶ added in v0.15.0
func (ts *TestSuite) GenerateTestBlockWithProposer(height uint32, proposer crypto.Address, ) (*block.Block, *certificate.Certificate)
GenerateTestBlockWithProposer generates a block with the give proposer address for testing purposes.
func (*TestSuite) GenerateTestBlockWithTime ¶ added in v0.15.0
func (ts *TestSuite) GenerateTestBlockWithTime(height uint32, tme time.Time, ) (*block.Block, *certificate.Certificate)
GenerateTestBlockWithTime generates a block with the given time for testing purposes.
func (*TestSuite) GenerateTestBondTx ¶
func (ts *TestSuite) GenerateTestBondTx() (*tx.Tx, *bls.PrivateKey)
GenerateTestBondTx generates a bond transaction for testing purposes.
func (*TestSuite) GenerateTestCertificate ¶
func (ts *TestSuite) GenerateTestCertificate(height uint32) *certificate.Certificate
GenerateTestCertificate generates a certificate for testing purposes.
func (*TestSuite) GenerateTestCommittee ¶
GenerateTestCommittee generates a committee for testing purposes. All committee members have the same power.
func (*TestSuite) GenerateTestPrecommitVote ¶
func (ts *TestSuite) GenerateTestPrecommitVote(height uint32, round int16) (*vote.Vote, *bls.ValidatorKey)
GenerateTestPrecommitVote generates a precommit vote for testing purposes.
func (*TestSuite) GenerateTestPrepareVote ¶
func (ts *TestSuite) GenerateTestPrepareVote(height uint32, round int16) (*vote.Vote, *bls.ValidatorKey)
GenerateTestPrepareVote generates a prepare vote for testing purposes.
func (*TestSuite) GenerateTestProposal ¶
func (ts *TestSuite) GenerateTestProposal(height uint32, round int16) (*proposal.Proposal, *bls.ValidatorKey)
GenerateTestProposal generates a proposal for testing purposes.
func (*TestSuite) GenerateTestSortitionTx ¶
func (ts *TestSuite) GenerateTestSortitionTx() (*tx.Tx, *bls.PrivateKey)
GenerateTestSortitionTx generates a sortition transaction for testing purposes.
func (*TestSuite) GenerateTestTransferTx ¶
func (ts *TestSuite) GenerateTestTransferTx() (*tx.Tx, *bls.PrivateKey)
GenerateTestTransferTx generates a transfer transaction for testing purposes.
func (*TestSuite) GenerateTestUnbondTx ¶
func (ts *TestSuite) GenerateTestUnbondTx() (*tx.Tx, *bls.PrivateKey)
GenerateTestUnbondTx generates an unbond transaction for testing purposes.
func (*TestSuite) GenerateTestValidator ¶
GenerateTestValidator generates a validator for testing purposes.
func (*TestSuite) GenerateTestWithdrawTx ¶
func (ts *TestSuite) GenerateTestWithdrawTx() (*tx.Tx, *bls.PrivateKey)
GenerateTestWithdrawTx generates a withdraw transaction for testing purposes.
func (*TestSuite) HelperSignProposal ¶ added in v0.15.0
func (ts *TestSuite) HelperSignProposal(valKey *bls.ValidatorKey, p *proposal.Proposal)
func (*TestSuite) HelperSignTransaction ¶ added in v0.15.0
func (ts *TestSuite) HelperSignTransaction(prv crypto.PrivateKey, trx *tx.Tx)
func (*TestSuite) HelperSignVote ¶ added in v0.15.0
func (ts *TestSuite) HelperSignVote(valKey *bls.ValidatorKey, v *vote.Vote)
func (*TestSuite) RandAccAddress ¶ added in v0.15.0
RandAccAddress generates a random account address for testing purposes.
func (*TestSuite) RandAmount ¶ added in v0.19.0
RandAmount returns a random amount between [0, 100^e9).
func (*TestSuite) RandBLSKeyPair ¶ added in v0.15.0
func (ts *TestSuite) RandBLSKeyPair() (*bls.PublicKey, *bls.PrivateKey)
RandBLSKeyPair generates a random BLS key pair for testing purposes.
func (*TestSuite) RandBLSSignature ¶ added in v0.15.0
RandBLSSignature generates a random BLS signature for testing purposes.
func (*TestSuite) RandBytes ¶ added in v0.15.0
RandBytes returns a slice of random bytes of the given length.
func (*TestSuite) RandHash ¶ added in v0.15.0
RandHash generates a random hash for testing purposes.
func (*TestSuite) RandHeight ¶ added in v0.15.0
RandHeight returns a random number between [1000, 1000000] for block height.
func (*TestSuite) RandInt16NonZero ¶
RandInt16NonZero returns a random int16 between 1 and max+1: [1, max+1).
func (*TestSuite) RandInt32NonZero ¶
RandInt32NonZero returns a random int32 between 1 and max+1: [1, max+1).
func (*TestSuite) RandInt64NonZero ¶
RandInt64NonZero returns a random int64 between 1 and max+1: [1, max+1).
func (*TestSuite) RandIntNonZero ¶
RandIntNonZero returns a random int between 1 and max+1: [1, max+1).
func (*TestSuite) RandPeerID ¶ added in v0.15.0
RandPeerID returns a random peer ID.
func (*TestSuite) RandProof ¶ added in v0.15.0
RandProof generates a random Proof for testing purposes.
func (*TestSuite) RandRound ¶ added in v0.15.0
RandRound returns a random number between [0, 10) for block round.
func (*TestSuite) RandSeed ¶ added in v0.15.0
func (ts *TestSuite) RandSeed() sortition.VerifiableSeed
RandSeed generates a random VerifiableSeed for testing purposes.
func (*TestSuite) RandString ¶ added in v0.15.0
RandString generates a random string of the given length.
func (*TestSuite) RandUint16 ¶
RandUint16 returns a random uint16 between 0 and max: [0, max).
func (*TestSuite) RandUint16NonZero ¶
RandUint16NonZero returns a random uint16 between 1 and max+1: [1, max+1).
func (*TestSuite) RandUint32 ¶
RandUint32 returns a random uint32 between 0 and max: [0, max).
func (*TestSuite) RandUint32NonZero ¶
RandUint32NonZero returns a random uint32 between 1 and max+1: [1, max+1).
func (*TestSuite) RandUint64 ¶
RandUint64 returns a random uint64 between 0 and max: [0, max).
func (*TestSuite) RandUint64NonZero ¶
RandUint64NonZero returns a random uint64 between 1 and max+1: [1, max+1).
func (*TestSuite) RandValAddress ¶ added in v0.15.0
RandValAddress generates a random validator address for testing purposes.
func (*TestSuite) RandValKey ¶ added in v0.15.0
func (ts *TestSuite) RandValKey() *bls.ValidatorKey
RandValKey generates a random validator key for testing purposes.