testsuite

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestSuite

type TestSuite struct {
	Seed int64
	Rand *rand.Rand
}

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

func NewTestSuite(t *testing.T) *TestSuite

NewTestSuite creates a new TestSuite by generating new seed.

func NewTestSuiteForSeed

func NewTestSuiteForSeed(seed int64) *TestSuite

NewTestSuiteForSeed creates a new TestSuite with the given seed.

func (*TestSuite) DecodingHex

func (ts *TestSuite) DecodingHex(in string) []byte

DecodingHex decodes the input string from hexadecimal format and returns the resulting byte slice.

func (*TestSuite) GenerateTestAccount

func (ts *TestSuite) GenerateTestAccount(number int32) (*account.Account, crypto.Signer)

GenerateTestAccount generates an account for testing purposes.

func (*TestSuite) GenerateTestBlock

func (ts *TestSuite) GenerateTestBlock(proposer *crypto.Address, prevBlockHash *hash.Hash) *block.Block

GenerateTestBlock generates a block vote for testing.

func (*TestSuite) GenerateTestBondTx

func (ts *TestSuite) GenerateTestBondTx() (*tx.Tx, crypto.Signer)

GenerateTestBondTx generates a bond transaction for testing.

func (*TestSuite) GenerateTestCertificate

func (ts *TestSuite) GenerateTestCertificate(blockHash hash.Hash) *block.Certificate

GenerateTestCertificate generates a certificate for testing.

func (*TestSuite) GenerateTestChangeProposerVote

func (ts *TestSuite) GenerateTestChangeProposerVote(height uint32, round int16) (*vote.Vote, crypto.Signer)

GenerateTestChangeProposerVote generates a proposer-change vote for testing.

func (*TestSuite) GenerateTestCommittee

func (ts *TestSuite) GenerateTestCommittee(num int) (committee.Committee, []crypto.Signer)

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, crypto.Signer)

GenerateTestPrecommitVote generates a precommit vote for testing.

func (*TestSuite) GenerateTestPrepareVote

func (ts *TestSuite) GenerateTestPrepareVote(height uint32, round int16) (*vote.Vote, crypto.Signer)

GenerateTestPrepareVote generates a prepare vote for testing.

func (*TestSuite) GenerateTestProposal

func (ts *TestSuite) GenerateTestProposal(height uint32, round int16) (*proposal.Proposal, crypto.Signer)

GenerateTestProposal generates a proposal for testing.

func (*TestSuite) GenerateTestSortitionTx

func (ts *TestSuite) GenerateTestSortitionTx() (*tx.Tx, crypto.Signer)

GenerateTestSortitionTx generates a sortition transaction for testing.

func (*TestSuite) GenerateTestTransferTx

func (ts *TestSuite) GenerateTestTransferTx() (*tx.Tx, crypto.Signer)

GenerateTestTransferTx generates a transfer transaction for testing.

func (*TestSuite) GenerateTestUnbondTx

func (ts *TestSuite) GenerateTestUnbondTx() (*tx.Tx, crypto.Signer)

GenerateTestUnbondTx generates an unbond transaction for testing.

func (*TestSuite) GenerateTestValidator

func (ts *TestSuite) GenerateTestValidator(number int32) (*validator.Validator, crypto.Signer)

GenerateTestValidator generates a validator for testing purposes.

func (*TestSuite) GenerateTestWithdrawTx

func (ts *TestSuite) GenerateTestWithdrawTx() (*tx.Tx, crypto.Signer)

GenerateTestWithdrawTx generates a withdraw transaction for testing.

func (*TestSuite) RandInt

func (ts *TestSuite) RandInt(max int) int

RandInt returns a random int between 0 and max.

func (*TestSuite) RandInt16

func (ts *TestSuite) RandInt16(max int16) int16

RandInt16 returns a random int16 between 0 and max.

func (*TestSuite) RandInt16NonZero

func (ts *TestSuite) RandInt16NonZero(max int16) int16

RandInt16NonZero returns a random int16 between 1 and max+1.

func (*TestSuite) RandInt32

func (ts *TestSuite) RandInt32(max int32) int32

RandInt32 returns a random int32 between 0 and max.

func (*TestSuite) RandInt32NonZero

func (ts *TestSuite) RandInt32NonZero(max int32) int32

RandInt32NonZero returns a random int32 between 1 and max+1.

func (*TestSuite) RandInt64

func (ts *TestSuite) RandInt64(max int64) int64

RandInt64 returns a random int64 between 0 and max.

func (*TestSuite) RandInt64NonZero

func (ts *TestSuite) RandInt64NonZero(max int64) int64

RandInt64NonZero returns a random int64 between 1 and max+1.

func (*TestSuite) RandIntNonZero

func (ts *TestSuite) RandIntNonZero(max int) int

RandIntNonZero returns a random int between 1 and max+1.

func (*TestSuite) RandUint16

func (ts *TestSuite) RandUint16(max uint16) uint16

RandUint16 returns a random uint16 between 0 and max.

func (*TestSuite) RandUint16NonZero

func (ts *TestSuite) RandUint16NonZero(max uint16) uint16

RandUint16NonZero returns a random uint16 between 1 and max+1.

func (*TestSuite) RandUint32

func (ts *TestSuite) RandUint32(max uint32) uint32

RandUint32 returns a random uint32 between 0 and max.

func (*TestSuite) RandUint32NonZero

func (ts *TestSuite) RandUint32NonZero(max uint32) uint32

RandUint32NonZero returns a random uint32 between 1 and max+1.

func (*TestSuite) RandUint64

func (ts *TestSuite) RandUint64(max uint64) uint64

RandUint64 returns a random uint64 between 0 and max.

func (*TestSuite) RandUint64NonZero

func (ts *TestSuite) RandUint64NonZero(max uint64) uint64

RandUint64NonZero returns a random uint64 between 1 and max+1.

func (*TestSuite) RandomAddress

func (ts *TestSuite) RandomAddress() crypto.Address

RandomAddress generates a random address for testing.

func (*TestSuite) RandomBLSKeyPair

func (ts *TestSuite) RandomBLSKeyPair() (*bls.PublicKey, *bls.PrivateKey)

RandomBLSKeyPair generates a random BLS key pair for testing.

func (*TestSuite) RandomBytes

func (ts *TestSuite) RandomBytes(len int) []byte

RandomBytes returns a slice of random bytes of the given length.

func (*TestSuite) RandomHash

func (ts *TestSuite) RandomHash() hash.Hash

RandomHash generates a random hash for testing.

func (*TestSuite) RandomPeerID

func (ts *TestSuite) RandomPeerID() peer.ID

RandomPeerID returns a random peer ID.

func (*TestSuite) RandomProof

func (ts *TestSuite) RandomProof() sortition.Proof

RandomProof generates a random Proof for testing.

func (*TestSuite) RandomSeed

func (ts *TestSuite) RandomSeed() sortition.VerifiableSeed

RandomSeed generates a random VerifiableSeed for testing.

func (*TestSuite) RandomSigner

func (ts *TestSuite) RandomSigner() crypto.Signer

RandomSigner generates a random signer for testing.

func (*TestSuite) RandomStamp

func (ts *TestSuite) RandomStamp() hash.Stamp

RandomStamp generates a random stamp for testing.

func (*TestSuite) RandomString

func (ts *TestSuite) RandomString(len int) string

RandomString generates a random string of the given length.

Jump to

Keyboard shortcuts

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