integrationTests

package
v0.0.0-...-08f901d Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: GPL-3.0 Imports: 202 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultNodeName = "heartbeatNode"
	DefaultIdentity = "test_identity"
)

constants used for the hearbeat node & generated messages

View Source
const AddressHrp = "moa"

AddressPrefix is a global testing const

View Source
const GasSchedulePath = "../../../../cmd/node/config/gasSchedules/gasScheduleV4.toml"

GasSchedulePath --

View Source
const GlobalTopic = "global"

GlobalTopic is a global testing that all nodes will bind an interceptor

View Source
const MaxGasLimitPerBlock = uint64(3000000)

MaxGasLimitPerBlock defines maximum gas limit allowed per one block

View Source
const OpGasValueForMockVm = uint64(50)

OpGasValueForMockVm represents the gas value that it consumed by each operation called on the mock VM By operation, we mean each go function that is called on the VM implementation

View Source
const ScheduledMiniBlocksEnableEpoch = 1000

ScheduledMiniBlocksEnableEpoch defines the epoch for integration tests when scheduled nini blocks are enabled

View Source
const ShardTopic = "shard"

ShardTopic is the topic string generator for sharded topics Will generate topics in the following pattern: shard_0, shard_0_1, shard_0_META, shard_1 and so on

View Source
const StakingV4Step1EnableEpoch = 4443

StakingV4Step1EnableEpoch defines the epoch for integration tests when stakingV4 init is enabled

View Source
const StakingV4Step2EnableEpoch = 4444

StakingV4Step2EnableEpoch defines the epoch for integration tests when stakingV4 is enabled; should be greater than StakingV2Epoch

View Source
const StakingV4Step3EnableEpoch = 4445

StakingV4Step3EnableEpoch defines the epoch for integration tests when nodes distribution from auction to waiting list is enabled in staking v4

View Source
const UnreachableEpoch = uint32(1000000)

UnreachableEpoch defines an unreachable epoch for integration tests

Variables

View Source
var AdditionalGasLimit = uint64(999000)

AdditionalGasLimit is the value that can be added on a transaction in the GasLimit

View Source
var ChainID = []byte("integration tests chain ID")

ChainID is the chain ID identifier used in integration tests, processing nodes

View Source
var DelegationManagerConfigChangeAddress = "moa1vxy22x0fj4zv6hktmydg8vpfh6euv02cz4yg0aaws6rrad5a5awq9cstml"

DelegationManagerConfigChangeAddress represents the address that can change the config parameters of the delegation manager system smartcontract

View Source
var InitialRating = uint32(50)

InitialRating is used to initiate a node's info

View Source
var MinTransactionVersion = uint32(1)

MinTransactionVersion is the minimum transaction version used in integration tests, processing nodes

View Source
var MinTxGasLimit = uint64(1000)

MinTxGasLimit defines minimum gas limit required by a transaction

View Source
var MinTxGasPrice = uint64(100)

MinTxGasPrice defines minimum gas price required by a transaction

View Source
var P2pBootstrapDelay = 5 * time.Second

P2pBootstrapDelay is used so that nodes have enough time to bootstrap

View Source
var SoftwareVersion = []byte("intT")

SoftwareVersion is the software version identifier used in integration tests, processing nodes

View Source
var StepDelay = time.Millisecond * 180

StepDelay is used so that transactions can disseminate properly

View Source
var SyncDelay = time.Second / 5

SyncDelay is used so that nodes have enough time to sync

View Source
var TestAddressPubkeyConverter, _ = pubkeyConverter.NewBech32PubkeyConverter(32, AddressHrp)

TestAddressPubkeyConverter represents an address public key converter

View Source
var TestAppStatusHandler = &statusHandlerMock.AppStatusHandlerStub{}

TestAppStatusHandler represents an AppStatusHandler

View Source
var TestBLSKeyGenerator = signing.NewKeyGenerator(mcl.NewSuiteBLS12())

TestBLSKeyGenerator represents the BLS key generator

View Source
var TestBalanceComputationHandler, _ = preprocess.NewBalanceComputation()

TestBalanceComputationHandler represents a balance computation handler

TestBlockSizeComputation represents a block size computation handler

View Source
var TestBlockSizeThrottler = &mock.BlockSizeThrottlerStub{}

TestBlockSizeThrottler represents a block size throttler used in adaptive block size computation

View Source
var TestBuiltinFunctions = make(map[string]vmcommon.BuiltinFunction)

TestBuiltinFunctions is an additional map of builtin functions to be added to the scProcessor

View Source
var TestHasher = sha256.NewSha256()

TestHasher represents a sha256 hasher

View Source
var TestKeyGenForAccounts = signing.NewKeyGenerator(ed25519.NewEd25519())

TestKeyGenForAccounts represents a mock key generator for balances

View Source
var TestMarshalizer = &marshal.GogoProtoMarshalizer{}

TestMarshalizer represents the main marshalizer

View Source
var TestMarshaller = &marshal.GogoProtoMarshalizer{}

TestMarshaller represents the main marshaller

View Source
var TestMultiSig = cryptoMocks.NewMultiSigner()

TestMultiSig represents a mock multisig

TestP2PKeyGenerator represents the p2p key generator

View Source
var TestSingleBlsSigner = &mclsig.BlsSingleSigner{}

TestSingleBlsSigner defines a BlsSingleSigner

View Source
var TestSingleSigner = &ed25519SingleSig.Ed25519Signer{}

TestSingleSigner defines a Ed25519Signer

View Source
var TestThrottler = &processMock.InterceptorThrottlerStub{
	CanProcessCalled: func() bool {
		return true
	},
}

TestThrottler -

View Source
var TestTxSignHasher = keccak.NewKeccak()

TestTxSignHasher represents a sha3 legacy keccak 256 hasher

View Source
var TestTxSignMarshalizer = &marshal.JsonMarshalizer{}

TestTxSignMarshalizer represents the marshalizer used in vm communication

View Source
var TestUint64Converter = uint64ByteSlice.NewBigEndianConverter()

TestUint64Converter represents an uint64 to byte slice converter

View Source
var TestValidatorPubkeyConverter, _ = pubkeyConverter.NewHexPubkeyConverter(96)

TestValidatorPubkeyConverter represents an address public key converter

View Source
var TestVmMarshalizer = &marshal.JsonMarshalizer{}

TestVmMarshalizer represents the marshalizer used in vm communication

View Source
var TimeSpanForBadHeaders = time.Second * 30

TimeSpanForBadHeaders is the expiry time for an added block header hash

Functions

func AdbEmulateBalanceTxExecution

func AdbEmulateBalanceTxExecution(accounts state.AccountsAdapter, acntSrc, acntDest state.UserAccountHandler, value *big.Int) error

AdbEmulateBalanceTxExecution emulates a tx execution by altering the accounts balance and nonce, and printing any encountered error

func AdbEmulateBalanceTxSafeExecution

func AdbEmulateBalanceTxSafeExecution(acntSrc, acntDest state.UserAccountHandler, accounts state.AccountsAdapter, value *big.Int)

AdbEmulateBalanceTxSafeExecution emulates a tx execution by altering the accounts balance and nonce, and printing any encountered error

func AddSelfNotarizedHeaderByMetachain

func AddSelfNotarizedHeaderByMetachain(nodes []*TestProcessorNode)

AddSelfNotarizedHeaderByMetachain -

func AllShardsProposeBlock

func AllShardsProposeBlock(
	round uint64,
	nonce uint64,
	nodesMap map[uint32][]*TestProcessorNode,
) (
	map[uint32]data.BodyHandler,
	map[uint32]data.HeaderHandler,
	map[uint32][]*TestProcessorNode,
)

AllShardsProposeBlock simulates each shard selecting a consensus group and proposing/broadcasting/committing a block

func BootstrapDelay

func BootstrapDelay()

BootstrapDelay will delay the execution to allow the p2p bootstrap

func CheckRootHashes

func CheckRootHashes(t *testing.T, nodes []*TestProcessorNode, idxProposers []int)

CheckRootHashes checks the root hash of the proposer in every shard

func CheckTxPresentAndRightNonce

func CheckTxPresentAndRightNonce(
	t *testing.T,
	startingNonce uint64,
	noOfTxs int,
	txHashes [][]byte,
	txs []data.TransactionHandler,
	cache dataRetriever.ShardedDataCacherNotifier,
	shardCoordinator sharding.Coordinator,
)

CheckTxPresentAndRightNonce verifies that the nonce was updated correctly after the exec of bulk txs

func ClosePeers

func ClosePeers(peers []p2p.Messenger)

ClosePeers calls Messenger.Close on the provided peers

func CloseProcessorNodes

func CloseProcessorNodes(nodes []*TestProcessorNode)

CloseProcessorNodes closes the used TestProcessorNodes and advertiser

func ComputeAndRequestMissingTransactions

func ComputeAndRequestMissingTransactions(
	nodes []*TestProcessorNode,
	generatedTxHashes [][]byte,
	shardResolver uint32,
	shardRequesters ...uint32,
)

ComputeAndRequestMissingTransactions computes missing transactions for each node, and requests them

func ConnectNodes

func ConnectNodes(nodes []Connectable)

ConnectNodes will try to connect all provided connectable instances in a full mesh fashion

func CreateAccount

func CreateAccount(accnts state.AccountsAdapter, nonce uint64, balance *big.Int) []byte

CreateAccount creates a new account and returns the address

func CreateAccountForNode

func CreateAccountForNode(node *TestProcessorNode)

CreateAccountForNode creates an account for the given node

func CreateAccountForNodes

func CreateAccountForNodes(nodes []*TestProcessorNode)

CreateAccountForNodes creates accounts for each node and commits the accounts state

func CreateAccountsDB

func CreateAccountsDB(
	accountType Type,
	trieStorageManager common.StorageManager,
) (*state.AccountsDB, common.Trie)

CreateAccountsDB creates an account state with a valid trie implementation but with a memory storage

func CreateAccountsDBWithEnableEpochsHandler

func CreateAccountsDBWithEnableEpochsHandler(
	accountType Type,
	trieStorageManager common.StorageManager,
	enableEpochsHandler common.EnableEpochsHandler,
) (*state.AccountsDB, common.Trie)

CreateAccountsDBWithEnableEpochsHandler creates a new AccountsDb with the given enableEpochsHandler

func CreateAndSendTransaction

func CreateAndSendTransaction(
	node *TestProcessorNode,
	nodes []*TestProcessorNode,
	txValue *big.Int,
	rcvAddress []byte,
	txData string,
	additionalGasLimit uint64,
)

CreateAndSendTransaction will generate a transaction with provided parameters, sign it with the provided node's tx sign private key and send it on the transaction topic using the correct node that can send the transaction

func CreateAndSendTransactionWithGasLimit

func CreateAndSendTransactionWithGasLimit(
	node *TestProcessorNode,
	txValue *big.Int,
	gasLimit uint64,
	rcvAddress []byte,
	txData []byte,
	chainID []byte,
	version uint32,
)

CreateAndSendTransactionWithGasLimit generates and send a transaction with provided gas limit/gas price

func CreateAndSendTransactionWithSenderAccount

func CreateAndSendTransactionWithSenderAccount(
	node *TestProcessorNode,
	nodes []*TestProcessorNode,
	txValue *big.Int,
	senderAccount *TestWalletAccount,
	rcvAddress []byte,
	txData string,
	additionalGasLimit uint64,
)

CreateAndSendTransactionWithSenderAccount will generate a transaction with provided parameters, sign it with the provided node's tx sign private key and send it on the transaction topic using the correct node that can send the transaction

func CreateAndSendTransactions

func CreateAndSendTransactions(
	nodes map[uint32][]*TestProcessorNode,
	sendersPrivKeysMap map[uint32][]crypto.PrivateKey,
	receiversPubKeysMap map[uint32][]crypto.PublicKey,
	gasPricePerTx uint64,
	gasLimitPerTx uint64,
	valueToTransfer *big.Int,
)

CreateAndSendTransactions creates and sends transactions between given senders and receivers.

func CreateEnableEpochsConfig

func CreateEnableEpochsConfig() config.EnableEpochs

CreateEnableEpochsConfig creates enable epochs definitions to be used in tests

func CreateFixedNetworkOf8Peers

func CreateFixedNetworkOf8Peers() ([]p2p.Messenger, error)

CreateFixedNetworkOf8Peers assembles a network as following:

                     0------------------- 1
                     |                    |
2 ------------------ 3 ------------------ 4
|                    |                    |
5                    6                    7

func CreateFixedNetworkOf14Peers

func CreateFixedNetworkOf14Peers() ([]p2p.Messenger, error)

CreateFixedNetworkOf14Peers assembles a network as following:

               0
               |
               1
               |
+--+--+--+--+--2--+--+--+--+--+
|  |  |  |  |  |  |  |  |  |  |
3  4  5  6  7  8  9  10 11 12 13

func CreateFullGenesisBlocks

func CreateFullGenesisBlocks(
	accounts state.AccountsAdapter,
	validatorAccounts state.AccountsAdapter,
	trieStorageManagers map[string]common.StorageManager,
	nodesSetup sharding.GenesisNodesSetupHandler,
	shardCoordinator sharding.Coordinator,
	store dataRetriever.StorageService,
	blkc data.ChainHandler,
	dataPool dataRetriever.PoolsHolder,
	economics process.EconomicsDataHandler,
	accountsParser genesis.AccountsParser,
	smartContractParser genesis.InitialSmartContractParser,
	enableEpochsConfig config.EnableEpochs,
) map[uint32]data.HeaderHandler

CreateFullGenesisBlocks does the full genesis process, deploys smart contract at genesis

func CreateGenesisBlocks

func CreateGenesisBlocks(
	accounts state.AccountsAdapter,
	validatorAccounts state.AccountsAdapter,
	trieStorageManagers map[string]common.StorageManager,
	pubkeyConv core.PubkeyConverter,
	nodesSetup sharding.GenesisNodesSetupHandler,
	shardCoordinator sharding.Coordinator,
	store dataRetriever.StorageService,
	blkc data.ChainHandler,
	marshalizer marshal.Marshalizer,
	hasher hashing.Hasher,
	uint64Converter typeConverters.Uint64ByteSliceConverter,
	dataPool dataRetriever.PoolsHolder,
	economics process.EconomicsDataHandler,
	enableEpochsConfig config.EnableEpochs,
) map[uint32]data.HeaderHandler

CreateGenesisBlocks creates empty genesis blocks for all known shards, including metachain

func CreateGenesisMetaBlock

func CreateGenesisMetaBlock(
	accounts state.AccountsAdapter,
	validatorAccounts state.AccountsAdapter,
	trieStorageManagers map[string]common.StorageManager,
	pubkeyConv core.PubkeyConverter,
	nodesSetup sharding.GenesisNodesSetupHandler,
	shardCoordinator sharding.Coordinator,
	store dataRetriever.StorageService,
	blkc data.ChainHandler,
	marshalizer marshal.Marshalizer,
	hasher hashing.Hasher,
	uint64Converter typeConverters.Uint64ByteSliceConverter,
	dataPool dataRetriever.PoolsHolder,
	economics process.EconomicsDataHandler,
	enableEpochsConfig config.EnableEpochs,
) data.MetaHeaderHandler

CreateGenesisMetaBlock creates a new mock meta genesis block

func CreateHeaderIntegrityVerifier

func CreateHeaderIntegrityVerifier() process.HeaderIntegrityVerifier

CreateHeaderIntegrityVerifier outputs a valid header integrity verifier handler

func CreateMemUnit

func CreateMemUnit() storage.Storer

CreateMemUnit returns an in-memory storer implementation (the vast majority of tests do not require effective disk I/O)

func CreateMessengerFromConfig

func CreateMessengerFromConfig(p2pConfig p2pConfig.P2PConfig) p2p.Messenger

CreateMessengerFromConfig creates a new libp2p messenger with provided configuration

func CreateMessengerFromConfigWithPeersRatingHandler

func CreateMessengerFromConfigWithPeersRatingHandler(p2pConfig p2pConfig.P2PConfig, peersRatingHandler p2p.PeersRatingHandler, p2pKey crypto.PrivateKey) p2p.Messenger

CreateMessengerFromConfigWithPeersRatingHandler creates a new libp2p messenger with provided configuration

func CreateMessengerWithKadDht

func CreateMessengerWithKadDht(initialAddr string) p2p.Messenger

CreateMessengerWithKadDht creates a new libp2p messenger with kad-dht peer discovery

func CreateMessengerWithNoDiscovery

func CreateMessengerWithNoDiscovery() p2p.Messenger

CreateMessengerWithNoDiscovery creates a new libp2p messenger with no peer discovery

func CreateMessengerWithNoDiscoveryAndPeersRatingHandler

func CreateMessengerWithNoDiscoveryAndPeersRatingHandler(peersRatingHanlder p2p.PeersRatingHandler, p2pKey crypto.PrivateKey) p2p.Messenger

CreateMessengerWithNoDiscoveryAndPeersRatingHandler creates a new libp2p messenger with no peer discovery

func CreateMetaChain

func CreateMetaChain() data.ChainHandler

CreateMetaChain creates a blockchain implementation used by the meta nodes

func CreateMintingForSenders

func CreateMintingForSenders(
	nodes []*TestProcessorNode,
	senderShard uint32,
	sendersPrivateKeys []crypto.PrivateKey,
	value *big.Int,
)

CreateMintingForSenders creates account with balances for every node in a given shard

func CreateMintingFromAddresses

func CreateMintingFromAddresses(
	nodes []*TestProcessorNode,
	addresses [][]byte,
	value *big.Int,
)

CreateMintingFromAddresses creates account with balances for given address

func CreateNewDefaultTrie

func CreateNewDefaultTrie() common.Trie

CreateNewDefaultTrie returns a new trie with test hasher and marsahalizer

func CreateNodesWithFullGenesis

func CreateNodesWithFullGenesis(
	numOfShards int,
	nodesPerShard int,
	numMetaChainNodes int,
	genesisFile string,
) ([]*TestProcessorNode, *TestProcessorNode)

CreateNodesWithFullGenesis creates multiple nodes in different shards

func CreateNodesWithFullGenesisCustomEnableEpochs

func CreateNodesWithFullGenesisCustomEnableEpochs(
	numOfShards int,
	nodesPerShard int,
	numMetaChainNodes int,
	genesisFile string,
	enableEpochsConfig *config.EnableEpochs,
) ([]*TestProcessorNode, *TestProcessorNode)

CreateNodesWithFullGenesisCustomEnableEpochs creates multiple nodes in different shards

func CreateNodesWithNodesCoordinator

func CreateNodesWithNodesCoordinator(
	nodesPerShard int,
	nbMetaNodes int,
	nbShards int,
	shardConsensusGroupSize int,
	metaConsensusGroupSize int,
) map[uint32][]*TestProcessorNode

CreateNodesWithNodesCoordinator returns a map with nodes per shard each using a real nodes coordinator

func CreateNodesWithNodesCoordinatorAndHeaderSigVerifier

func CreateNodesWithNodesCoordinatorAndHeaderSigVerifier(
	nodesPerShard int,
	nbMetaNodes int,
	nbShards int,
	shardConsensusGroupSize int,
	metaConsensusGroupSize int,
	signer crypto.SingleSigner,
	keyGen crypto.KeyGenerator,
) map[uint32][]*TestProcessorNode

CreateNodesWithNodesCoordinatorAndHeaderSigVerifier returns a map with nodes per shard each using a real nodes coordinator and header sig verifier

func CreateNodesWithNodesCoordinatorAndTxKeys

func CreateNodesWithNodesCoordinatorAndTxKeys(
	nodesPerShard int,
	nbMetaNodes int,
	nbShards int,
	shardConsensusGroupSize int,
	metaConsensusGroupSize int,
) map[uint32][]*TestProcessorNode

CreateNodesWithNodesCoordinatorAndTxKeys -

func CreateNodesWithNodesCoordinatorFactory

func CreateNodesWithNodesCoordinatorFactory(
	nodesPerShard int,
	nbMetaNodes int,
	nbShards int,
	shardConsensusGroupSize int,
	metaConsensusGroupSize int,
	nodesCoordinatorFactory NodesCoordinatorFactory,
) map[uint32][]*TestProcessorNode

CreateNodesWithNodesCoordinatorFactory returns a map with nodes per shard each using a real nodes coordinator

func CreateNodesWithNodesCoordinatorKeygenAndSingleSigner

func CreateNodesWithNodesCoordinatorKeygenAndSingleSigner(
	nodesPerShard int,
	nbMetaNodes int,
	nbShards int,
	shardConsensusGroupSize int,
	metaConsensusGroupSize int,
	singleSigner crypto.SingleSigner,
	keyGenForBlocks crypto.KeyGenerator,
) map[uint32][]*TestProcessorNode

CreateNodesWithNodesCoordinatorKeygenAndSingleSigner returns a map with nodes per shard each using a real nodes coordinator and a given single signer for blocks and a given key gen for blocks

func CreateNodesWithNodesCoordinatorWithCacher

func CreateNodesWithNodesCoordinatorWithCacher(
	nodesPerShard int,
	nbMetaNodes int,
	nbShards int,
	shardConsensusGroupSize int,
	metaConsensusGroupSize int,
) map[uint32][]*TestProcessorNode

CreateNodesWithNodesCoordinatorWithCacher returns a map with nodes per shard each using a real nodes coordinator with cacher

func CreateNodesWithTestConsensusNode

func CreateNodesWithTestConsensusNode(
	numMetaNodes int,
	nodesPerShard int,
	consensusSize int,
	roundTime uint64,
	consensusType string,
	numKeysOnEachNode int,
) map[uint32][]*TestConsensusNode

CreateNodesWithTestConsensusNode returns a map with nodes per shard each using TestConsensusNode

func CreateNodesWithTestHeartbeatNode

func CreateNodesWithTestHeartbeatNode(
	nodesPerShard int,
	numMetaNodes int,
	numShards int,
	shardConsensusGroupSize int,
	metaConsensusGroupSize int,
	numObserversOnShard int,
	p2pConfig p2pConfig.P2PConfig,
) map[uint32][]*TestHeartbeatNode

CreateNodesWithTestHeartbeatNode returns a map with nodes per shard each using a real nodes coordinator and TestHeartbeatNode

func CreateP2PConfigWithNoDiscovery

func CreateP2PConfigWithNoDiscovery() p2pConfig.P2PConfig

CreateP2PConfigWithNoDiscovery creates a new libp2p messenger with no peer discovery

func CreatePkBytes

func CreatePkBytes(numShards uint32) map[uint32][]byte

CreatePkBytes creates 'numShards' public key-like byte slices

func CreateProcessorNodesWithNodesCoordinator

func CreateProcessorNodesWithNodesCoordinator(
	rewardsAddrsAssignments map[uint32][]uint32,
	shardConsensusGroupSize int,
	metaConsensusGroupSize int,
) (map[uint32][]*TestProcessorNode, uint32)

CreateProcessorNodesWithNodesCoordinator creates a map of nodes with a valid nodes coordinator implementation keeping the consistency of generated keys

func CreateRandomAddress

func CreateRandomAddress() []byte

CreateRandomAddress creates a random byte array with fixed size

func CreateRandomBytes

func CreateRandomBytes(chars int) []byte

CreateRandomBytes returns a random byte slice with the given size

func CreateRatingsData

func CreateRatingsData() *rating.RatingsData

CreateRatingsData creates a mock RatingsData object

func CreateRequesterDataPool

func CreateRequesterDataPool(recvTxs map[int]map[string]struct{}, mutRecvTxs *sync.Mutex, nodeIndex int, _ uint32) dataRetriever.PoolsHolder

CreateRequesterDataPool creates a datapool with a mock txPool

func CreateResolversDataPool

func CreateResolversDataPool(
	t *testing.T,
	maxTxs int,
	senderShardID uint32,
	recvShardId uint32,
	shardCoordinator sharding.Coordinator,
) (dataRetriever.PoolsHolder, [][]byte, [][]byte)

CreateResolversDataPool creates a datapool containing a given number of transactions

func CreateSendersAndReceiversInShard

func CreateSendersAndReceiversInShard(
	nodeInShard *TestProcessorNode,
	nbSenderReceiverPairs uint32,
) ([]crypto.PrivateKey, []crypto.PublicKey)

CreateSendersAndReceiversInShard creates given number of sender private key and receiver public key pairs, with account in same shard as given node

func CreateSendersWithInitialBalances

func CreateSendersWithInitialBalances(
	nodesMap map[uint32][]*TestProcessorNode,
	mintValue *big.Int,
) map[uint32][]crypto.PrivateKey

CreateSendersWithInitialBalances creates a map of 1 sender per shard with an initial balance

func CreateShardChain

func CreateShardChain() data.ChainHandler

CreateShardChain creates a blockchain implementation used by the shard nodes

func CreateSimpleGenesisBlock

func CreateSimpleGenesisBlock(shardId uint32) *dataBlock.Header

CreateSimpleGenesisBlock creates a new mock shard genesis block

func CreateSimpleGenesisBlocks

func CreateSimpleGenesisBlocks(shardCoordinator sharding.Coordinator) map[uint32]data.HeaderHandler

CreateSimpleGenesisBlocks creates empty genesis blocks for all known shards, including metachain

func CreateSimpleGenesisMetaBlock

func CreateSimpleGenesisMetaBlock() *dataBlock.MetaBlock

CreateSimpleGenesisMetaBlock creates a new mock meta genesis block

func CreateSimpleTxProcessor

func CreateSimpleTxProcessor(accnts state.AccountsAdapter) process.TransactionProcessor

CreateSimpleTxProcessor returns a transaction processor

func CreateStore

func CreateStore(numOfShards uint32) dataRetriever.StorageService

CreateStore creates a storage service for shard nodes

func CreateTrieStorageManager

func CreateTrieStorageManager(store storage.Storer) (common.StorageManager, storage.Storer)

CreateTrieStorageManager creates the trie storage manager for the tests

func CreateTrieStorageManagerWithPruningStorer

func CreateTrieStorageManagerWithPruningStorer(coordinator sharding.Coordinator, notifier pruning.EpochStartNotifier) common.StorageManager

CreateTrieStorageManagerWithPruningStorer creates the trie storage manager for the tests

func DeployScTx

func DeployScTx(nodes []*TestProcessorNode, senderIdx int, scCode string, vmType []byte, initArguments string)

DeployScTx creates and sends a SC tx

func DisplayAndStartNodes

func DisplayAndStartNodes(nodes []*TestProcessorNode)

DisplayAndStartNodes prints each nodes shard ID, sk and pk, and then starts the node

func DoConsensusSigningOnBlock

func DoConsensusSigningOnBlock(
	blockHeader data.HeaderHandler,
	consensusNodes []*TestProcessorNode,
	pubKeys []string,
) data.HeaderHandler

DoConsensusSigningOnBlock simulates a consensus aggregated signature on the provided block

func EmptyDataPools

func EmptyDataPools(nodes []*TestProcessorNode, shardId uint32)

EmptyDataPools clears all the data pools

func ForkChoiceOneBlock

func ForkChoiceOneBlock(nodes []*TestProcessorNode, shardId uint32)

ForkChoiceOneBlock rollbacks a block from the given shard

func GenValidatorsFromPubKeys

func GenValidatorsFromPubKeys(pubKeysMap map[uint32][]string, _ uint32) map[uint32][]nodesCoordinator.GenesisNodeInfoHandler

GenValidatorsFromPubKeys generates a map of validators per shard out of public keys map

func GenValidatorsFromPubKeysAndTxPubKeys

func GenValidatorsFromPubKeysAndTxPubKeys(
	blsPubKeysMap map[uint32][]string,
	txPubKeysMap map[uint32][]string,
) map[uint32][]nodesCoordinator.GenesisNodeInfoHandler

GenValidatorsFromPubKeysAndTxPubKeys generates a map of validators per shard out of public keys map

func GenerateAddressJournalAccountAccountsDB

func GenerateAddressJournalAccountAccountsDB() ([]byte, state.UserAccountHandler, *state.AccountsDB)

GenerateAddressJournalAccountAccountsDB returns an account, the accounts address, and the accounts database

func GenerateAndDisseminateTxs

func GenerateAndDisseminateTxs(
	n *TestProcessorNode,
	senders []crypto.PrivateKey,
	receiversPublicKeysMap map[uint32][]crypto.PublicKey,
	valToTransfer *big.Int,
	gasPrice uint64,
	gasLimit uint64,
	chainID []byte,
	version uint32,
)

GenerateAndDisseminateTxs generates and sends multiple txs

func GenerateIntraShardTransactions

func GenerateIntraShardTransactions(
	nodesMap map[uint32][]*TestProcessorNode,
	nbTxsPerShard uint32,
	mintValue *big.Int,
	valToTransfer *big.Int,
	gasPrice uint64,
	gasLimit uint64,
)

GenerateIntraShardTransactions generates intra shard transactions

func GenerateOneAddressPerShard

func GenerateOneAddressPerShard(shardCoordinator sharding.Coordinator) [][]byte

GenerateOneAddressPerShard -

func GenerateRandomSlice

func GenerateRandomSlice(size int) []byte

GenerateRandomSlice returns a random byte slice with the given size

func GenerateSkAndPkInShard

func GenerateSkAndPkInShard(
	coordinator sharding.Coordinator,
	shardId uint32,
) (crypto.PrivateKey, crypto.PublicKey, crypto.KeyGenerator)

GenerateSkAndPkInShard generates and returns a private and a public key that reside in a given shard. It also returns the key generator

func GenerateTransferTx

func GenerateTransferTx(
	nonce uint64,
	senderPrivateKey crypto.PrivateKey,
	receiverPublicKey crypto.PublicKey,
	valToTransfer *big.Int,
	gasPrice uint64,
	gasLimit uint64,
	chainID []byte,
	version uint32,
) *transaction.Transaction

GenerateTransferTx will generate a move balance transaction

func GenerateTrieKeysForMaxLevel

func GenerateTrieKeysForMaxLevel(numTrieLevels int, numChildrenPerBranch int) [][]byte

GenerateTrieKeysForMaxLevel generates a list of keys that will fill a trie until the given level is reached

func GetConnectableAddress

func GetConnectableAddress(mes p2p.Messenger) string

GetConnectableAddress returns a non circuit, non windows default connectable address for provided messenger

func GetDefaultCoreComponents

func GetDefaultCoreComponents(enableEpochsConfig config.EnableEpochs) *mock.CoreComponentsStub

GetDefaultCoreComponents -

func GetDefaultCryptoComponents

func GetDefaultCryptoComponents() *mock.CryptoComponentsStub

GetDefaultCryptoComponents -

func GetDefaultDataComponents

func GetDefaultDataComponents() *mock.DataComponentsStub

GetDefaultDataComponents -

func GetDefaultEnableEpochsConfig

func GetDefaultEnableEpochsConfig() *config.EnableEpochs

GetDefaultEnableEpochsConfig returns a default EnableEpochs config

func GetDefaultNetworkComponents

func GetDefaultNetworkComponents() *mock.NetworkComponentsStub

GetDefaultNetworkComponents -

func GetDefaultProcessComponents

func GetDefaultProcessComponents() *mock.ProcessComponentsStub

GetDefaultProcessComponents -

func GetDefaultStateComponents

func GetDefaultStateComponents() *testFactory.StateComponentsMock

GetDefaultStateComponents -

func GetDefaultStatusComponents

func GetDefaultStatusComponents() *mock.StatusComponentsStub

GetDefaultStatusComponents -

func GetMiniBlocksHashesFromShardIds

func GetMiniBlocksHashesFromShardIds(body *dataBlock.Body, shardIds ...uint32) [][]byte

GetMiniBlocksHashesFromShardIds returns miniblock hashes from body

func GetTokenIdentifier

func GetTokenIdentifier(nodes []*TestProcessorNode, ticker []byte) []byte

GetTokenIdentifier returns the token identifier from the metachain for the given ticker

func IncrementAndPrintRound

func IncrementAndPrintRound(round uint64) uint64

IncrementAndPrintRound increments the given variable, and prints the message for the beginning of the round

func IncrementNonces

func IncrementNonces(nonces []*uint64)

IncrementNonces increments all the nonces

func IsIntInSlice

func IsIntInSlice(idx int, slice []int) bool

IsIntInSlice returns true if idx is found on any position in the provided slice

func MakeDisplayTable

func MakeDisplayTable(nodes []*TestProcessorNode) string

MakeDisplayTable will output a string containing counters for received transactions, headers, miniblocks and meta headers for all provided test nodes

func MakeDisplayTableForHeartbeatNodes

func MakeDisplayTableForHeartbeatNodes(nodes map[uint32][]*TestHeartbeatNode) string

MakeDisplayTableForHeartbeatNodes returns a string containing counters for received messages for all provided test nodes

func MintAddress

func MintAddress(accnts state.AccountsAdapter, addressBytes []byte, value *big.Int)

MintAddress will create an account (if it does not exist), update the balance with required value, save the account and commit the trie.

func MintAllNodes

func MintAllNodes(nodes []*TestProcessorNode, value *big.Int)

MintAllNodes will take each shard node (n) and will mint all nodes that have their pk managed by the iterating node n

func MintAllPlayers

func MintAllPlayers(nodes []*TestProcessorNode, players []*TestWalletAccount, value *big.Int)

MintAllPlayers mints addresses for all players

func PlayerSendsTransaction

func PlayerSendsTransaction(
	nodes []*TestProcessorNode,
	player *TestWalletAccount,
	scAddress []byte,
	value *big.Int,
	txData string,
	gasLimit uint64,
)

PlayerSendsTransaction creates and sends a transaction to the SC

func PrepareRelayedTxDataV1

func PrepareRelayedTxDataV1(innerTx *transaction.Transaction) []byte

PrepareRelayedTxDataV1 repares the data for a relayed transaction V1

func PrepareRelayedTxDataV2

func PrepareRelayedTxDataV2(innerTx *transaction.Transaction) []byte

PrepareRelayedTxDataV2 prepares the data for a relayed transaction V2

func PrintShardAccount

func PrintShardAccount(accnt state.UserAccountHandler, tag string)

PrintShardAccount outputs on console a shard account data contained

func ProcessSCOutputAccounts

func ProcessSCOutputAccounts(vmOutput *vmcommon.VMOutput, accountsDB state.AccountsAdapter) error

ProcessSCOutputAccounts will save account changes in accounts db from vmOutput

func ProposeAndSyncOneBlock

func ProposeAndSyncOneBlock(
	t *testing.T,
	nodes []*TestProcessorNode,
	idxProposers []int,
	round uint64,
	nonce uint64,
) (uint64, uint64)

ProposeAndSyncOneBlock proposes a block, syncs the block and then increments the round

func ProposeBlock

func ProposeBlock(nodes []*TestProcessorNode, idxProposers []int, round uint64, nonce uint64)

ProposeBlock proposes a block for every shard

func ProposeBlockSignalsEmptyBlock

func ProposeBlockSignalsEmptyBlock(
	node *TestProcessorNode,
	round uint64,
	nonce uint64,
) (data.HeaderHandler, data.BodyHandler, bool)

ProposeBlockSignalsEmptyBlock proposes and broadcasts a block

func ProposeBlocks

func ProposeBlocks(
	nodes []*TestProcessorNode,
	round *uint64,
	idxProposers []int,
	nonces []*uint64,
	numOfRounds int,
)

ProposeBlocks proposes blocks for a given number of rounds

func PubKeysMapFromNodesKeysMap

func PubKeysMapFromNodesKeysMap(keyPairMap map[uint32][]*TestNodeKeys) map[uint32][]string

PubKeysMapFromNodesKeysMap returns a map of public keys per shard from the key pairs per shard map.

func PubKeysMapFromTxKeysMap

func PubKeysMapFromTxKeysMap(keyPairMap map[uint32][]*TestKeyPair) map[uint32][]string

PubKeysMapFromTxKeysMap returns a map of public keys per shard from the key pairs per shard map.

func ResetHighestProbableNonce

func ResetHighestProbableNonce(nodes []*TestProcessorNode, shardId uint32, targetNonce uint64)

ResetHighestProbableNonce resets the highest probable nonce

func SaveDelegationContractsList

func SaveDelegationContractsList(nodes []*TestProcessorNode)

SaveDelegationContractsList will save a mock configuration for the delegation contracts list

func