Documentation
¶
Index ¶
- func AccountWithAddress(address crypto.Address) func(*AccountMaker)
- func AccountWithBalance(balance amount.Amount) func(*AccountMaker)
- func AccountWithNumber(number int32) func(*AccountMaker)
- func BlockWithPrevCert(cert *certificate.Certificate) func(*BlockMaker)
- func BlockWithPrevHash(h hash.Hash) func(*BlockMaker)
- func BlockWithProposer(addr crypto.Address) func(*BlockMaker)
- func BlockWithSeed(seed sortition.VerifiableSeed) func(*BlockMaker)
- func BlockWithStateHash(h hash.Hash) func(*BlockMaker)
- func BlockWithTime(t time.Time) func(*BlockMaker)
- func BlockWithTransactions(txs block.Txs) func(*BlockMaker)
- func BlockWithVersion(ver protocol.Version) func(*BlockMaker)
- func FindFreePort() int
- func GenerateSeed() int64
- func ProposalWithKey(key *bls.ValidatorKey) func(*ProposalMaker)
- func TransactionWithAmount(amt amount.Amount) func(*TransactionMaker)
- func TransactionWithFee(fee amount.Amount) func(*TransactionMaker)
- func TransactionWithLockTime(lockTime uint32) func(*TransactionMaker)
- func TransactionWithRecipients(recipients []payload.BatchRecipient) func(*TransactionMaker)
- func TransactionWithSigner(signer crypto.PrivateKey) func(*TransactionMaker)
- func TransactionWithValidatorPublicKey(pubKey *bls.PublicKey) func(*TransactionMaker)
- func ValidatorWithNumber(number int32) func(*ValidatorMaker)
- func ValidatorWithPublicKey(publicKey *bls.PublicKey) func(*ValidatorMaker)
- func ValidatorWithStake(stake amount.Amount) func(*ValidatorMaker)
- type AccountMaker
- type BlockMaker
- type OverrideStringer
- type ProposalMaker
- type TestSuite
- func (*TestSuite) DecodingHex(in string) []byte
- func (ts *TestSuite) GenerateTestAccount(options ...func(*AccountMaker)) (*account.Account, crypto.Address)
- func (ts *TestSuite) GenerateTestBatchTransferTx(options ...func(*TransactionMaker)) *tx.Tx
- func (ts *TestSuite) GenerateTestBlock(height uint32, options ...func(*BlockMaker)) (*block.Block, *certificate.Certificate)
- func (ts *TestSuite) GenerateTestBondTx(options ...func(*TransactionMaker)) *tx.Tx
- 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, options ...func(*ProposalMaker)) *proposal.Proposal
- func (ts *TestSuite) GenerateTestSortitionTx(options ...func(*TransactionMaker)) *tx.Tx
- func (ts *TestSuite) GenerateTestSubsidyTx(options ...func(tm *TransactionMaker)) *tx.Tx
- func (ts *TestSuite) GenerateTestTransferTx(options ...func(*TransactionMaker)) *tx.Tx
- func (ts *TestSuite) GenerateTestUnbondTx(options ...func(*TransactionMaker)) *tx.Tx
- func (ts *TestSuite) GenerateTestValidator(options ...func(*ValidatorMaker)) *validator.Validator
- func (ts *TestSuite) GenerateTestWithdrawTx(options ...func(*TransactionMaker)) *tx.Tx
- func (*TestSuite) HelperSignProposal(valKey *bls.ValidatorKey, p *proposal.Proposal)
- func (*TestSuite) HelperSignTransaction(prv crypto.PrivateKey, trx *tx.Tx)
- func (*TestSuite) HelperSignVote(valKey *bls.ValidatorKey, v *vote.Vote)
- func (ts *TestSuite) NewAccountMaker() *AccountMaker
- func (ts *TestSuite) NewBlockMaker() *BlockMaker
- func (ts *TestSuite) NewProposalMaker() *ProposalMaker
- func (ts *TestSuite) NewTransactionMaker() *TransactionMaker
- func (ts *TestSuite) NewValidatorMaker() *ValidatorMaker
- func (ts *TestSuite) RandAccAddress() crypto.Address
- func (ts *TestSuite) RandAmount(max ...amount.Amount) amount.Amount
- func (ts *TestSuite) RandAmountRange(min, max amount.Amount) 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) RandEd25519KeyPair() (*ed25519.PublicKey, *ed25519.PrivateKey)
- func (ts *TestSuite) RandEd25519Signature() *ed25519.Signature
- func (ts *TestSuite) RandFee(max ...amount.Amount) amount.Amount
- func (ts *TestSuite) RandHash() hash.Hash
- func (ts *TestSuite) RandHeight() uint32
- func (ts *TestSuite) RandInt(max int) int
- func (ts *TestSuite) RandInt8(max int8) int8
- 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) RandKeyPair() (crypto.PublicKey, crypto.PrivateKey)
- func (ts *TestSuite) RandMultiAddress() string
- 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) RandSlice(length int) []int32
- func (ts *TestSuite) RandString(length int) string
- func (ts *TestSuite) RandUint8(max uint8) uint8
- 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
- type TransactionMaker
- type ValidatorMaker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccountWithAddress ¶
func AccountWithAddress(address crypto.Address) func(*AccountMaker)
AccountWithAddress sets the address for the generated test account.
func AccountWithBalance ¶
func AccountWithBalance(balance amount.Amount) func(*AccountMaker)
AccountWithBalance sets the balance for the generated test account.
func AccountWithNumber ¶
func AccountWithNumber(number int32) func(*AccountMaker)
AccountWithNumber sets the account number for the generated test account.
func BlockWithPrevCert ¶
func BlockWithPrevCert(cert *certificate.Certificate) func(*BlockMaker)
BlockWithPrevCert sets previous block certificate to the block.
func BlockWithPrevHash ¶
func BlockWithPrevHash(h hash.Hash) func(*BlockMaker)
BlockWithPrevHash sets previous block hash to the block.
func BlockWithProposer ¶
func BlockWithProposer(addr crypto.Address) func(*BlockMaker)
BlockWithProposer sets proposer address to the block.
func BlockWithSeed ¶
func BlockWithSeed(seed sortition.VerifiableSeed) func(*BlockMaker)
BlockWithSeed sets verifiable seed to the block.
func BlockWithStateHash ¶
func BlockWithStateHash(h hash.Hash) func(*BlockMaker)
BlockWithStateHash sets state hash to the block.
func BlockWithTime ¶
func BlockWithTime(t time.Time) func(*BlockMaker)
BlockWithTime sets block creation time to the block.
func BlockWithTransactions ¶
func BlockWithTransactions(txs block.Txs) func(*BlockMaker)
BlockWithTransactions adds transactions to the block.
func BlockWithVersion ¶
func BlockWithVersion(ver protocol.Version) func(*BlockMaker)
BlockWithVersion sets version to the block.
func FindFreePort ¶
func FindFreePort() int
func GenerateSeed ¶
func GenerateSeed() int64
func ProposalWithKey ¶
func ProposalWithKey(key *bls.ValidatorKey) func(*ProposalMaker)
ProposalWithKey sets the private key of the proposer.
func TransactionWithAmount ¶
func TransactionWithAmount(amt amount.Amount) func(*TransactionMaker)
TransactionWithAmount sets amount to the transaction.
func TransactionWithFee ¶
func TransactionWithFee(fee amount.Amount) func(*TransactionMaker)
TransactionWithFee sets fee to the transaction.
func TransactionWithLockTime ¶
func TransactionWithLockTime(lockTime uint32) func(*TransactionMaker)
TransactionWithLockTime sets lock-time to the transaction.
func TransactionWithRecipients ¶
func TransactionWithRecipients(recipients []payload.BatchRecipient) func(*TransactionMaker)
TransactionWithRecipients sets the recipients for the Bath Transfer transaction.
func TransactionWithSigner ¶
func TransactionWithSigner(signer crypto.PrivateKey) func(*TransactionMaker)
TransactionWithSigner sets the BLS signer to sign the test transaction.
func TransactionWithValidatorPublicKey ¶
func TransactionWithValidatorPublicKey(pubKey *bls.PublicKey) func(*TransactionMaker)
TransactionWithValidatorPublicKey sets the Validator's public key for the Bond transaction.
func ValidatorWithNumber ¶
func ValidatorWithNumber(number int32) func(*ValidatorMaker)
ValidatorWithNumber sets the validator number for the generated test validator.
func ValidatorWithPublicKey ¶
func ValidatorWithPublicKey(publicKey *bls.PublicKey) func(*ValidatorMaker)
ValidatorWithPublicKey sets the public Key for the generated test account.
func ValidatorWithStake ¶
func ValidatorWithStake(stake amount.Amount) func(*ValidatorMaker)
ValidatorWithStake sets the stake for the generated test account.
Types ¶
type AccountMaker ¶
type BlockMaker ¶
type OverrideStringer ¶
type OverrideStringer struct {
// contains filtered or unexported fields
}
func NewOverrideStringer ¶
func NewOverrideStringer(name string, obj fmt.Stringer) *OverrideStringer
func (*OverrideStringer) String ¶
func (o *OverrideStringer) String() string
type ProposalMaker ¶
type ProposalMaker struct {
ProposerKey *bls.ValidatorKey
}
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 NewTestSuiteFromSeed ¶
NewTestSuiteFromSeed 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 ¶
func (ts *TestSuite) GenerateTestAccount(options ...func(*AccountMaker)) (*account.Account, crypto.Address)
GenerateTestAccount generates an account for testing purposes.
func (*TestSuite) GenerateTestBatchTransferTx ¶
func (ts *TestSuite) GenerateTestBatchTransferTx(options ...func(*TransactionMaker)) *tx.Tx
GenerateTestBatchTransferTx generate a batch transfer transaction for test.
func (*TestSuite) GenerateTestBlock ¶
func (ts *TestSuite) GenerateTestBlock(height uint32, options ...func(*BlockMaker)) ( *block.Block, *certificate.Certificate, )
GenerateTestBlock generates a block for testing purposes with optional configuration.
func (*TestSuite) GenerateTestBondTx ¶
func (ts *TestSuite) GenerateTestBondTx(options ...func(*TransactionMaker)) *tx.Tx
GenerateTestBondTx generates a bond transaction for testing purposes.
func (*TestSuite) GenerateTestCertificate ¶
func (ts *TestSuite) GenerateTestCertificate(height uint32) *certificate.Certificate
GenerateTestCertificate generates a block 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, options ...func(*ProposalMaker), ) *proposal.Proposal
GenerateTestProposal generates a proposal for testing purposes.
func (*TestSuite) GenerateTestSortitionTx ¶
func (ts *TestSuite) GenerateTestSortitionTx(options ...func(*TransactionMaker)) *tx.Tx
GenerateTestSortitionTx generates a sortition transaction for testing purposes.
func (*TestSuite) GenerateTestSubsidyTx ¶
func (ts *TestSuite) GenerateTestSubsidyTx(options ...func(tm *TransactionMaker)) *tx.Tx
GenerateTestSubsidyTx creates a subsidy transaction for testing.
func (*TestSuite) GenerateTestTransferTx ¶
func (ts *TestSuite) GenerateTestTransferTx(options ...func(*TransactionMaker)) *tx.Tx
GenerateTestTransferTx generates a transfer transaction for testing purposes.
func (*TestSuite) GenerateTestUnbondTx ¶
func (ts *TestSuite) GenerateTestUnbondTx(options ...func(*TransactionMaker)) *tx.Tx
GenerateTestUnbondTx generates an unbond transaction for testing purposes.
func (*TestSuite) GenerateTestValidator ¶
func (ts *TestSuite) GenerateTestValidator(options ...func(*ValidatorMaker)) *validator.Validator
GenerateTestValidator generates a validator for testing purposes.
func (*TestSuite) GenerateTestWithdrawTx ¶
func (ts *TestSuite) GenerateTestWithdrawTx(options ...func(*TransactionMaker)) *tx.Tx
GenerateTestWithdrawTx generates a withdraw transaction for testing purposes.
func (*TestSuite) HelperSignProposal ¶
func (*TestSuite) HelperSignProposal(valKey *bls.ValidatorKey, p *proposal.Proposal)
func (*TestSuite) HelperSignTransaction ¶
func (*TestSuite) HelperSignTransaction(prv crypto.PrivateKey, trx *tx.Tx)
func (*TestSuite) HelperSignVote ¶
func (*TestSuite) HelperSignVote(valKey *bls.ValidatorKey, v *vote.Vote)
func (*TestSuite) NewAccountMaker ¶
func (ts *TestSuite) NewAccountMaker() *AccountMaker
NewAccountMaker creates a new instance of AccountMaker with random values.
func (*TestSuite) NewBlockMaker ¶
func (ts *TestSuite) NewBlockMaker() *BlockMaker
NewBlockMaker creates a new BlockMaker instance.
func (*TestSuite) NewProposalMaker ¶
func (ts *TestSuite) NewProposalMaker() *ProposalMaker
NewProposalMaker creates a new NewProposalMaker instance.
func (*TestSuite) NewTransactionMaker ¶
func (ts *TestSuite) NewTransactionMaker() *TransactionMaker
NewTransactionMaker creates a new TransactionMaker instance.
func (*TestSuite) NewValidatorMaker ¶
func (ts *TestSuite) NewValidatorMaker() *ValidatorMaker
NewValidatorMaker creates a new instance of ValidatorMaker with random values.
func (*TestSuite) RandAccAddress ¶
RandAccAddress generates a random account address for testing purposes.
func (*TestSuite) RandAmount ¶
RandAmount returns a random amount between [1e9, max). If max is not set, it defaults to 100e9.
func (*TestSuite) RandAmountRange ¶
RandAmountRange returns a random amount between [min, max).
func (*TestSuite) RandBLSKeyPair ¶
func (ts *TestSuite) RandBLSKeyPair() (*bls.PublicKey, *bls.PrivateKey)
RandBLSKeyPair generates a random BLS key pair for testing purposes.
func (*TestSuite) RandBLSSignature ¶
RandBLSSignature generates a random BLS signature for testing purposes.
func (*TestSuite) RandEd25519KeyPair ¶
func (ts *TestSuite) RandEd25519KeyPair() (*ed25519.PublicKey, *ed25519.PrivateKey)
RandEd25519KeyPair generates a random Ed25519 key pair for testing purposes.
func (*TestSuite) RandEd25519Signature ¶
RandEd25519Signature generates a random BLS signature for testing purposes.
func (*TestSuite) RandFee ¶
RandFee returns a random fee between [1e7, max). If max is not set, it defaults to 1e9.
func (*TestSuite) RandHeight ¶
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) RandKeyPair ¶
func (ts *TestSuite) RandKeyPair() (crypto.PublicKey, crypto.PrivateKey)
func (*TestSuite) RandMultiAddress ¶
RandMultiAddress returns a random MultiAddress.
func (*TestSuite) RandPeerID ¶
RandPeerID returns a random peer ID.
func (*TestSuite) RandSeed ¶
func (ts *TestSuite) RandSeed() sortition.VerifiableSeed
RandSeed generates a random VerifiableSeed for testing purposes.
func (*TestSuite) RandSlice ¶
RandSlice generates a random non-repeating slice of int32 elements with the specified length.
func (*TestSuite) RandString ¶
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 ¶
RandValAddress generates a random validator address for testing purposes.
func (*TestSuite) RandValKey ¶
func (ts *TestSuite) RandValKey() *bls.ValidatorKey
RandValKey generates a random validator key for testing purposes.
type TransactionMaker ¶
type TransactionMaker struct {
LockTime uint32
Amount amount.Amount
Fee amount.Amount
Signer crypto.PrivateKey
ValPubKey *bls.PublicKey
Recipients []payload.BatchRecipient
}
func (*TransactionMaker) SignerAccountAddress ¶
func (tm *TransactionMaker) SignerAccountAddress() crypto.Address
func (*TransactionMaker) SignerValidatorAddress ¶
func (tm *TransactionMaker) SignerValidatorAddress() crypto.Address