integrationTests

package
v1.7.16 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: GPL-3.0 Imports: 203 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 = "erd"

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 = "erd1vxy22x0fj4zv6hktmydg8vpfh6euv02cz4yg0aaws6rrad5a5awqgqky80"

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 added in v1.6.0

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 added in v1.6.0

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 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 CreateFixedNetworkOf8Peers

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

CreateFixedNetworkOf8Peers assembles a network as following:

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

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 added in v1.6.0

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 added in v1.6.0

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 added in v1.4.17

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

PrepareRelayedTxDataV1 repares the data for a relayed transaction V1

func PrepareRelayedTxDataV2 added in v1.4.17

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 added in v1.7.0

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 added in v1.6.0

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 added in v1.6.0

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 SaveDelegationManagerConfig

func SaveDelegationManagerConfig(nodes []*TestProcessorNode)

SaveDelegationManagerConfig will save a mock configuration for the delegation manager SC

func ScCallTxWithParams

func ScCallTxWithParams(
	senderNode *TestProcessorNode,
	sk crypto.PrivateKey,
	nonce uint64,
	data string,
	value *big.Int,
	gasLimit uint64,
	gasPrice uint64,
)

ScCallTxWithParams creates and sends a SC tx call or deploy with all major parameters provided

func SetEconomicsParameters

func SetEconomicsParameters(nodes []*TestProcessorNode, maxGasLimitPerBlock uint64, minGasPrice uint64, minGasLimit uint64)

SetEconomicsParameters will set maxGasLimitPerBlock, minGasPrice and minGasLimits to provided nodes

func StartSyncingBlocks

func StartSyncingBlocks(nodes []*TestProcessorNode)

StartSyncingBlocks starts the syncing process of all the nodes

func SyncAllShardsWithRoundBlock

func SyncAllShardsWithRoundBlock(
	t *testing.T,
	nodesMap map[uint32][]*TestProcessorNode,
	indexProposers map[uint32]int,
	round uint64,
)

SyncAllShardsWithRoundBlock enforces all nodes in each shard synchronizing the block for the given round

func SyncBlock

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

SyncBlock synchronizes the proposed block in all the other shard nodes

func TestPrivateKeyHasBalance

func TestPrivateKeyHasBalance(t *testing.T, n *TestProcessorNode, sk crypto.PrivateKey, expectedBalance *big.Int)

TestPrivateKeyHasBalance checks if the private key has the expected balance

func TestPublicKeyHasBalance

func TestPublicKeyHasBalance(t *testing.T, n *TestProcessorNode, pk crypto.PublicKey, expectedBalance *big.Int)

TestPublicKeyHasBalance checks if the account corresponding to the given public key has the expected balance

func Uint32InSlice

func Uint32InSlice(searched uint32, list []uint32) bool

Uint32InSlice checks if a uint32 value is in a slice

func UpdateRound

func UpdateRound(nodes []*TestProcessorNode, round uint64)

UpdateRound updates the round for every node

func WaitOperationToBeDone

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

WaitOperationToBeDone -

func WhiteListTxs

func WhiteListTxs(nodes []*TestProcessorNode, txs []*transaction.Transaction)

WhiteListTxs -

Types

type Address

type Address = []byte

Address is a slice of bytes used to identify an account

type ArgIndexHashedNodesCoordinatorFactory

type ArgIndexHashedNodesCoordinatorFactory struct {
	// contains filtered or unexported fields
}

ArgIndexHashedNodesCoordinatorFactory -

type ArgTestProcessorNode

type ArgTestProcessorNode struct {
	MaxShards               uint32
	NodeShardId             uint32
	TxSignPrivKeyShardId    uint32
	WithBLSSigVerifier      bool
	WithSync                bool
	GasScheduleMap          GasScheduleMap
	RoundsConfig            *config.RoundConfig
	EpochsConfig            *config.EnableEpochs
	VMConfig                *config.VirtualMachineConfig
	EconomicsConfig         *config.EconomicsConfig
	DataPool                dataRetriever.PoolsHolder
	TrieStore               storage.Storer
	HardforkPk              crypto.PublicKey
	GenesisFile             string
	NodeKeys                *TestNodeKeys
	NodesSetup              sharding.GenesisNodesSetupHandler
	NodesCoordinator        nodesCoordinator.NodesCoordinator
	MultiSigner             crypto.MultiSigner
	RatingsData             *rating.RatingsData
	HeaderSigVerifier       process.InterceptedHeaderSigVerifier
	HeaderIntegrityVerifier process.HeaderIntegrityVerifier
	OwnAccount              *TestWalletAccount
	EpochStartSubscriber    notifier.EpochStartNotifier
	AppStatusHandler        core.AppStatusHandler
	StatusMetrics           external.StatusMetricsHandler
	WithPeersRatingHandler  bool
	NodeOperationMode       common.NodeOperation
}

ArgTestProcessorNode represents the DTO used to create a new TestProcessorNode

type ArgsTestConsensusNode added in v1.6.0

type ArgsTestConsensusNode struct {
	ShardID       uint32
	ConsensusSize int
	RoundTime     uint64
	ConsensusType string
	NodeKeys      *TestNodeKeys
	EligibleMap   map[uint32][]nodesCoordinator.Validator
	WaitingMap    map[uint32][]nodesCoordinator.Validator
	KeyGen        crypto.KeyGenerator
	P2PKeyGen     crypto.KeyGenerator
	MultiSigner   *cryptoMocks.MultisignerMock
	StartTime     int64
}

ArgsTestConsensusNode represents the arguments for the test consensus node constructor(s)

type Connectable

type Connectable interface {
	ConnectOnMain(connectable Connectable) error
	ConnectOnFullArchive(connectable Connectable) error
	GetMainConnectableAddress() string
	GetFullArchiveConnectableAddress() string
	IsInterfaceNil() bool
}

Connectable defines the operations for a struct to become connectable by other struct In other words, all instances that implement this interface are able to connect with each other

type CountInterceptor

type CountInterceptor struct {
	// contains filtered or unexported fields
}

CountInterceptor represents an interceptors that counts received messages on topics

func NewCountInterceptor

func NewCountInterceptor() *CountInterceptor

NewCountInterceptor creates a new CountInterceptor instance

func (*CountInterceptor) IsInterfaceNil

func (ci *CountInterceptor) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*CountInterceptor) MessageCount

func (ci *CountInterceptor) MessageCount(topic string) int

MessageCount returns the number of messages received on the provided topic

func (*CountInterceptor) ProcessReceivedMessage

func (ci *CountInterceptor) ProcessReceivedMessage(message p2p.MessageP2P, _ core.PeerID, _ p2p.MessageHandler) error

ProcessReceivedMessage is called each time a new message is received

func (*CountInterceptor) Reset

func (ci *CountInterceptor) Reset()

Reset resets the counters values

type CryptoParams

type CryptoParams struct {
	KeyGen       crypto.KeyGenerator
	P2PKeyGen    crypto.KeyGenerator
	NodesKeys    map[uint32][]*TestNodeKeys
	SingleSigner crypto.SingleSigner
	TxKeyGen     crypto.KeyGenerator
	TxKeys       map[uint32][]*TestKeyPair
}

CryptoParams holds crypto parameters

func CreateCryptoParams

func CreateCryptoParams(nodesPerShard int, nbMetaNodes int, nbShards uint32, numKeysOnEachNode int) *CryptoParams

CreateCryptoParams generates the crypto parameters (key pairs, key generator and suite) for multiple nodes

type Facade

type Facade interface {
	GetBalance(address string, options api.AccountQueryOptions) (*big.Int, api.BlockInfo, error)
	GetUsername(address string, options api.AccountQueryOptions) (string, api.BlockInfo, error)
	GetCodeHash(address string, options api.AccountQueryOptions) ([]byte, api.BlockInfo, error)
	GetValueForKey(address string, key string, options api.AccountQueryOptions) (string, api.BlockInfo, error)
	GetAccount(address string, options api.AccountQueryOptions) (dataApi.AccountResponse, api.BlockInfo, error)
	GetAccounts(addresses []string, options api.AccountQueryOptions) (map[string]*api.AccountResponse, api.BlockInfo, error)
	GetESDTData(address string, key string, nonce uint64, options api.AccountQueryOptions) (*esdt.ESDigitalToken, api.BlockInfo, error)
	GetNFTTokenIDsRegisteredByAddress(address string, options api.AccountQueryOptions) ([]string, api.BlockInfo, error)
	GetESDTsWithRole(address string, role string, options api.AccountQueryOptions) ([]string, api.BlockInfo, error)
	GetAllESDTTokens(address string, options api.AccountQueryOptions) (map[string]*esdt.ESDigitalToken, api.BlockInfo, error)
	GetESDTsRoles(address string, options api.AccountQueryOptions) (map[string][]string, api.BlockInfo, error)
	GetKeyValuePairs(address string, options api.AccountQueryOptions) (map[string]string, api.BlockInfo, error)
	GetGuardianData(address string, options api.AccountQueryOptions) (api.GuardianData, api.BlockInfo, error)
	GetBlockByHash(hash string, options api.BlockQueryOptions) (*dataApi.Block, error)
	GetBlockByNonce(nonce uint64, options api.BlockQueryOptions) (*dataApi.Block, error)
	GetBlockByRound(round uint64, options api.BlockQueryOptions) (*dataApi.Block, error)
	Trigger(epoch uint32, withEarlyEndOfEpoch bool) error
	IsSelfTrigger() bool
	GetTotalStakedValue() (*dataApi.StakeValues, error)
	GetDirectStakedList() ([]*dataApi.DirectStakedValue, error)
	GetDelegatorsList() ([]*dataApi.Delegator, error)
	GetAllIssuedESDTs(tokenType string) ([]string, error)
	GetTokenSupply(token string) (*dataApi.ESDTSupply, error)
	GetHeartbeats() ([]data.PubKeyHeartbeat, error)
	StatusMetrics() external.StatusMetricsHandler
	GetQueryHandler(name string) (debug.QueryHandler, error)
	GetEpochStartDataAPI(epoch uint32) (*common.EpochStartDataAPI, error)
	GetPeerInfo(pid string) ([]core.QueryP2PPeerInfo, error)
	GetConnectedPeersRatingsOnMainNetwork() (string, error)
	CreateTransaction(txArgs *external.ArgsCreateTransaction) (*transaction.Transaction, []byte, error)
	ValidateTransaction(tx *transaction.Transaction) error
	ValidateTransactionForSimulation(tx *transaction.Transaction, bypassSignature bool) error
	SendBulkTransactions([]*transaction.Transaction) (uint64, error)
	SimulateTransactionExecution(tx *transaction.Transaction) (*txSimData.SimulationResultsWithVMOutput, error)
	GetTransaction(hash string, withResults bool) (*transaction.ApiTransactionResult, error)
	ComputeTransactionGasLimit(tx *transaction.Transaction) (*transaction.CostResponse, error)
	EncodeAddressPubkey(pk []byte) (string, error)
	GetThrottlerForEndpoint(endpoint string) (core.Throttler, bool)
	ValidatorStatisticsApi() (map[string]*validator.ValidatorStatistics, error)
	AuctionListApi() ([]*common.AuctionListValidatorAPIResponse, error)
	ExecuteSCQuery(*process.SCQuery) (*vm.VMOutputApi, api.BlockInfo, error)
	DecodeAddressPubkey(pk string) ([]byte, error)
	GetProof(rootHash string, address string) (*common.GetProofResponse, error)
	GetProofDataTrie(rootHash string, address string, key string) (*common.GetProofResponse, *common.GetProofResponse, error)
	GetProofCurrentRootHash(address string) (*common.GetProofResponse, error)
	VerifyProof(rootHash string, address string, proof [][]byte) (bool, error)
	GetGenesisNodesPubKeys() (map[uint32][]string, map[uint32][]string, error)
	GetGenesisBalances() ([]*common.InitialAccountAPI, error)
	GetGasConfigs() (map[string]map[string]uint64, error)
	GetTransactionsPool(fields string) (*common.TransactionsPoolAPIResponse, error)
	GetTransactionsPoolForSender(sender, fields string) (*common.TransactionsPoolForSenderApiResponse, error)
	GetLastPoolNonceForSender(sender string) (uint64, error)
	GetTransactionsPoolNonceGapsForSender(sender string) (*common.TransactionsPoolNonceGapsForSenderApiResponse, error)
	GetAlteredAccountsForBlock(options dataApi.GetAlteredAccountsForBlockOptions) ([]*alteredAccount.AlteredAccount, error)
	IsDataTrieMigrated(address string, options api.AccountQueryOptions) (bool, error)
	GetManagedKeysCount() int
	GetManagedKeys() []string
	GetLoadedKeys() []string
	GetEligibleManagedKeys() ([]string, error)
	GetWaitingManagedKeys() ([]string, error)
	GetWaitingEpochsLeftForPublicKey(publicKey string) (uint32, error)
	IsInterfaceNil() bool
}

Facade is the node facade used to decouple the node implementation with the web server. Used in integration tests

type GasScheduleMap

type GasScheduleMap = map[string]map[string]uint64

GasScheduleMap is a map containing the predefined gas costs

type IndexHashedNodesCoordinatorFactory

type IndexHashedNodesCoordinatorFactory struct {
}

IndexHashedNodesCoordinatorFactory -

func (*IndexHashedNodesCoordinatorFactory) CreateNodesCoordinator

CreateNodesCoordinator -

type IndexHashedNodesCoordinatorWithRaterFactory

type IndexHashedNodesCoordinatorWithRaterFactory struct {
	sharding.PeerAccountListAndRatingHandler
}

IndexHashedNodesCoordinatorWithRaterFactory -

func (*IndexHashedNodesCoordinatorWithRaterFactory) CreateNodesCoordinator

CreateNodesCoordinator is used for creating a nodes coordinator in the integration tests based on the provided parameters

type IntWrapper

type IntWrapper struct {
	Value uint
}

IntWrapper defines a wrapped int used as an optional parameter

type MiniNetwork added in v1.6.16

type MiniNetwork struct {
	Round uint64
	Nonce uint64

	Nodes         []*TestProcessorNode
	ShardNode     *TestProcessorNode
	MetachainNode *TestProcessorNode
	Users         map[string]*TestWalletAccount
}

MiniNetwork is a mini network, useful for some integration tests

func NewMiniNetwork added in v1.6.16

func NewMiniNetwork() *MiniNetwork

NewMiniNetwork creates a MiniNetwork

func (*MiniNetwork) AddUser added in v1.6.16

func (n *MiniNetwork) AddUser(balance *big.Int) *TestWalletAccount

AddUser adds a user (account) to the mini network

func (*MiniNetwork) Continue added in v1.6.16

func (n *MiniNetwork) Continue(t *testing.T, numRounds int)

Continue advances processing with a number of rounds

func (*MiniNetwork) FundAccount added in v1.6.16

func (n *MiniNetwork) FundAccount(address []byte, value *big.Int)

FundAccount funds an account

func (*MiniNetwork) SendTransaction added in v1.6.16

func (n *MiniNetwork) SendTransaction(
	senderPubkey []byte,
	receiverPubkey []byte,
	value *big.Int,
	data string,
	additionalGasLimit uint64,
) (string, error)

SendTransaction sends a transaction

func (*MiniNetwork) Start added in v1.6.16

func (n *MiniNetwork) Start()

Start starts the mini network

func (*MiniNetwork) Stop added in v1.6.16

func (n *MiniNetwork) Stop()

Stop stops the mini network

type NetworkShardingUpdater

type NetworkShardingUpdater interface {
	GetPeerInfo(pid core.PeerID) core.P2PPeerInfo
	UpdatePeerIDPublicKeyPair(pid core.PeerID, pk []byte)
	PutPeerIdShardId(pid core.PeerID, shardID uint32)
	UpdatePeerIDInfo(pid core.PeerID, pk []byte, shardID uint32)
	PutPeerIdSubType(pid core.PeerID, peerSubType core.P2PPeerSubType)
	IsInterfaceNil() bool
}

NetworkShardingUpdater defines the updating methods used by the network sharding component

type NodeSlice

type NodeSlice = []*TestProcessorNode

NodeSlice is a slice of TestProcessorNode instances

type NodesByShardMap

type NodesByShardMap = map[ShardIdentifier]NodeSlice

NodesByShardMap is a map that groups TestProcessorNodes by their shard ID

type NodesCoordinatorFactory

type NodesCoordinatorFactory interface {
	CreateNodesCoordinator(arg ArgIndexHashedNodesCoordinatorFactory) nodesCoordinator.NodesCoordinator
}

NodesCoordinatorFactory is used for creating a nodesCoordinator in the integration tests

type NodesWithRater

type NodesWithRater struct {
	nodesCoordinator.NodesCoordinator
	// contains filtered or unexported fields
}

NodesWithRater -

func (*NodesWithRater) IsInterfaceNil

func (nwr *NodesWithRater) IsInterfaceNil() bool

IsInterfaceNil -

type ShardIdentifier

type ShardIdentifier = uint32

ShardIdentifier is the numeric index of a shard

type TestBootstrapper

type TestBootstrapper interface {
	process.Bootstrapper
	RollBack(revertUsingForkNonce bool) error
	SetProbableHighestNonce(nonce uint64)
}

TestBootstrapper extends the Bootstrapper interface with some functions intended to be used only in tests as it simplifies the reproduction of edge cases

type TestBuiltinFunction

type TestBuiltinFunction struct {
	Function func(acntSnd, acntDst vmcommon.UserAccountHandler, vmInput *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
}

TestBuiltinFunction wraps a builtin function defined ad-hoc, for testing

func (*TestBuiltinFunction) IsActive

func (bf *TestBuiltinFunction) IsActive() bool

IsActive -

func (*TestBuiltinFunction) IsInterfaceNil

func (bf *TestBuiltinFunction) IsInterfaceNil() bool

IsInterfaceNil -

func (*TestBuiltinFunction) ProcessBuiltinFunction

func (bf *TestBuiltinFunction) ProcessBuiltinFunction(acntSnd, acntDst vmcommon.UserAccountHandler, vmInput *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)

ProcessBuiltinFunction is a method implementation required by the BuiltinFunction interface

func (*TestBuiltinFunction) SetNewGasConfig

func (bf *TestBuiltinFunction) SetNewGasConfig(_ *vmcommon.GasCost)

SetNewGasConfig -

type TestConsensusNode

type TestConsensusNode struct {
	Node                 *node.Node
	MainMessenger        p2p.Messenger
	FullArchiveMessenger p2p.Messenger
	NodesCoordinator     nodesCoordinator.NodesCoordinator
	ShardCoordinator     sharding.Coordinator
	ChainHandler         data.ChainHandler
	BlockProcessor       *mock.BlockProcessorMock
	RequestersFinder     dataRetriever.RequestersFinder
	AccountsDB           *state.AccountsDB
	NodeKeys             *TestKeyPair
	MultiSigner          *cryptoMocks.MultisignerMock
}

TestConsensusNode represents a structure used in integration tests used for consensus tests

func NewTestConsensusNode

func NewTestConsensusNode(args ArgsTestConsensusNode) *TestConsensusNode

NewTestConsensusNode returns a new TestConsensusNode

func (*TestConsensusNode) ConnectOnFullArchive added in v1.6.0

func (tcn *TestConsensusNode) ConnectOnFullArchive(connectable Connectable) error

ConnectOnFullArchive will try to initiate a connection to the provided parameter on the full archive messenger

func (*TestConsensusNode) ConnectOnMain added in v1.6.0

func (tcn *TestConsensusNode) ConnectOnMain(connectable Connectable) error

ConnectOnMain will try to initiate a connection to the provided parameter on the main messenger

func (*TestConsensusNode) GetFullArchiveConnectableAddress added in v1.6.0

func (tcn *TestConsensusNode) GetFullArchiveConnectableAddress() string

GetFullArchiveConnectableAddress returns a non circuit, non windows default connectable p2p address of the full archive network

func (*TestConsensusNode) GetMainConnectableAddress added in v1.6.0

func (tcn *TestConsensusNode) GetMainConnectableAddress() string

GetMainConnectableAddress returns a non circuit, non windows default connectable p2p address

func (*TestConsensusNode) IsInterfaceNil

func (tcn *TestConsensusNode) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

type TestEpochStartTrigger

type TestEpochStartTrigger interface {
	epochStart.TriggerHandler
	GetRoundsPerEpoch() uint64
	SetTrigger(triggerHandler epochStart.TriggerHandler)
	SetRoundsPerEpoch(roundsPerEpoch uint64)
	SetMinRoundsBetweenEpochs(minRoundsPerEpoch uint64)
	SetEpoch(epoch uint32)
}

TestEpochStartTrigger extends the epochStart trigger interface with some functions intended to by used only in tests as it simplifies the reproduction of test scenarios

type TestHeartbeatNode

type TestHeartbeatNode struct {
	ShardCoordinator                     sharding.Coordinator
	NodesCoordinator                     nodesCoordinator.NodesCoordinator
	MainPeerShardMapper                  process.NetworkShardingCollector
	FullArchivePeerShardMapper           process.NetworkShardingCollector
	MainMessenger                        p2p.Messenger
	FullArchiveMessenger                 p2p.Messenger
	NodeKeys                             *TestNodeKeys
	DataPool                             dataRetriever.PoolsHolder
	Sender                               update.Closer
	PeerAuthInterceptor                  *interceptors.MultiDataInterceptor
	HeartbeatInterceptor                 *interceptors.SingleDataInterceptor
	FullArchiveHeartbeatInterceptor      *interceptors.SingleDataInterceptor
	PeerShardInterceptor                 *interceptors.SingleDataInterceptor
	FullArchivePeerShardInterceptor      *interceptors.SingleDataInterceptor
	PeerSigHandler                       crypto.PeerSignatureHandler
	WhiteListHandler                     process.WhiteListHandler
	Storage                              dataRetriever.StorageService
	ResolversContainer                   dataRetriever.ResolversContainer
	RequestersContainer                  dataRetriever.RequestersContainer
	RequestersFinder                     dataRetriever.RequestersFinder
	RequestHandler                       process.RequestHandler
	RequestedItemsHandler                dataRetriever.RequestedItemsHandler
	RequestsProcessor                    update.Closer
	ShardSender                          update.Closer
	MainDirectConnectionProcessor        update.Closer
	FullArchiveDirectConnectionProcessor update.Closer
	Interceptor                          *CountInterceptor
	ManagedPeersHolder                   common.ManagedPeersHolder
	// contains filtered or unexported fields
}

TestHeartbeatNode represents a container type of class used in integration tests with all its fields exported

func NewTestHeartbeatNode

func NewTestHeartbeatNode(
	tb testing.TB,
	maxShards uint32,
	nodeShardId uint32,
	minPeersWaiting int,
	p2pConfig p2pConfig.P2PConfig,
	heartbeatExpiryTimespanInSec int64,
	nodeKeys *TestNodeKeys,
	validatorsKeys []*TestKeyPair,
) *TestHeartbeatNode

NewTestHeartbeatNode returns a new TestHeartbeatNode instance with a libp2p messenger

func NewTestHeartbeatNodeWithCoordinator

func NewTestHeartbeatNodeWithCoordinator(
	maxShards uint32,
	nodeShardId uint32,
	p2pConfig p2pConfig.P2PConfig,
	coordinator nodesCoordinator.NodesCoordinator,
	keys *TestNodeKeys,
) *TestHeartbeatNode

NewTestHeartbeatNodeWithCoordinator returns a new TestHeartbeatNode instance with a libp2p messenger using provided coordinator and keys

func (*TestHeartbeatNode) Close

func (thn *TestHeartbeatNode) Close()

Close -

func (*TestHeartbeatNode) ConnectOnFullArchive added in v1.6.0

func (thn *TestHeartbeatNode) ConnectOnFullArchive(connectable Connectable) error

ConnectOnFullArchive will try to initiate a connection to the provided parameter on the full archive messenger

func (*TestHeartbeatNode) ConnectOnMain added in v1.6.0

func (thn *TestHeartbeatNode) ConnectOnMain(connectable Connectable) error

ConnectOnMain will try to initiate a connection to the provided parameter on the main messenger

func (*TestHeartbeatNode) CountCrossShardMessages

func (thn *TestHeartbeatNode) CountCrossShardMessages() int

CountCrossShardMessages returns the messages count on the cross-shard topics

func (*TestHeartbeatNode) CountGlobalMessages

func (thn *TestHeartbeatNode) CountGlobalMessages() int

CountGlobalMessages returns the messages count on the global topic

func (*TestHeartbeatNode) CountIntraShardMessages

func (thn *TestHeartbeatNode) CountIntraShardMessages() int

CountIntraShardMessages returns the messages count on the intra-shard topic

func (*TestHeartbeatNode) CreateTestInterceptors

func (thn *TestHeartbeatNode) CreateTestInterceptors()

CreateTestInterceptors creates test interceptors that count the number of received messages

func (*TestHeartbeatNode) GetFullArchiveConnectableAddress added in v1.6.0

func (thn *TestHeartbeatNode) GetFullArchiveConnectableAddress() string

GetFullArchiveConnectableAddress returns a non circuit, non windows default connectable p2p address of the full archive network

func (*TestHeartbeatNode) GetMainConnectableAddress added in v1.6.0

func (thn *TestHeartbeatNode) GetMainConnectableAddress() string

GetMainConnectableAddress returns a non circuit, non windows default connectable p2p address

func (*TestHeartbeatNode) InitTestHeartbeatNode

func (thn *TestHeartbeatNode) InitTestHeartbeatNode(tb testing.TB, minPeersWaiting int)

InitTestHeartbeatNode initializes all the components and starts sender

func (*TestHeartbeatNode) IsInterfaceNil

func (thn *TestHeartbeatNode) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

type TestKeyPair

type TestKeyPair struct {
	Sk crypto.PrivateKey
	Pk crypto.PublicKey
}

TestKeyPair holds a pair of private/public Keys

type TestNetwork

type TestNetwork struct {
	NumShards          int
	NodesPerShard      int
	NodesInMetashard   int
	Nodes              NodeSlice
	NodesSharded       NodesByShardMap
	Wallets            []*TestWalletAccount
	DeploymentAddress  Address
	Proposers          []int
	Round              uint64
	Nonce              uint64
	T                  *testing.T
	DefaultNode        *TestProcessorNode
	DefaultGasPrice    uint64
	MinGasLimit        uint64
	MaxGasLimit        uint64
	DefaultVM          []byte
	DefaultGasSchedule GasScheduleMap
	BypassErrorsOnce   bool
}

TestNetwork wraps a set of TestProcessorNodes along with a set of test Wallets, instantiates them, controls them and provides operations with them; designed to be used in integration tests. TODO combine TestNetwork with the preexisting TestContext and MiniNetwork into a single struct containing the functionality of all three

func NewTestNetwork

func NewTestNetwork(t *testing.T) *TestNetwork

NewTestNetwork creates an unsized TestNetwork; topology must be configured afterwards, before starting.

func NewTestNetworkSized

func NewTestNetworkSized(
	t *testing.T,
	numShards int,
	nodesPerShard int,
	nodesInMetashard int,
) *TestNetwork

NewTestNetworkSized creates a new TestNetwork containing topology information; can be started immediately.

func (*TestNetwork) Close

func (net *TestNetwork) Close()

Close shuts down the test network.

func (*TestNetwork) ComputeGasLimit

func (net *TestNetwork) ComputeGasLimit(tx *transaction.Transaction) uint64

ComputeGasLimit calculates the base gas limit of the provided transaction, smart contract execution or built-in function calls notwithstanding.

func (*TestNetwork) ComputeTxFee

func (net *TestNetwork) ComputeTxFee(tx *transaction.Transaction) *big.Int

ComputeTxFee calculates the cost of the provided transaction, smart contract execution or built-in function calls notwithstanding.

func (*TestNetwork) ComputeTxFeeUint64

func (net *TestNetwork) ComputeTxFeeUint64(tx *transaction.Transaction) uint64

ComputeTxFeeUint64 calculates the cost of the provided transaction, smart contract execution or built-in function calls notwithstanding.

func (*TestNetwork) CreateSignedTx

func (net *TestNetwork) CreateSignedTx(
	sender *TestWalletAccount,
	recvAddress Address,
	value *big.Int,
	txData []byte,
) *transaction.Transaction

CreateSignedTx creates a new transaction from provided information and signs it with the `sender` wallet; if modified, a transaction must be sent to the network using SignAndSendTx instead of SendTx.

func (*TestNetwork) CreateSignedTxUint64

func (net *TestNetwork) CreateSignedTxUint64(
	sender *TestWalletAccount,
	recvAddress Address,
	value uint64,
	txData []byte,
) *transaction.Transaction

CreateSignedTxUint64 creates a new transaction from provided information and signs it with the `sender` wallet; if modified, a transaction must be sent to the network using SignAndSendTx instead of SendTx.

func (*TestNetwork) CreateTx

func (net *TestNetwork) CreateTx(
	sender *TestWalletAccount,
	recvAddress Address,
	value *big.Int,
	txData []byte,
) *transaction.Transaction

CreateTx creates a new transaction from the provided information; must be signed before sending; the nonce of the `sender` wallet is incremented.

func (*TestNetwork) CreateTxUint64

func (net *TestNetwork) CreateTxUint64(
	sender *TestWalletAccount,
	recvAddress Address,
	value uint64,
	txData []byte,
) *transaction.Transaction

CreateTxUint64 creates a new transaction from the provided information; must be signed before sending; the nonce of the `sender` wallet is incremented.

func (*TestNetwork) CreateUninitializedWallets added in v1.6.0

func (net *TestNetwork) CreateUninitializedWallets(count int)

CreateUninitializedWallets -

func (*TestNetwork) CreateWalletOnShard added in v1.6.0

func (net *TestNetwork) CreateWalletOnShard(walletIndex int, shardID uint32) *TestWalletAccount

CreateWalletOnShard -

func (*TestNetwork) CreateWallets

func (net *TestNetwork) CreateWallets(count int)

CreateWallets initializes the internal test wallets

func (*TestNetwork) DeployNonpayableSC

func (net *TestNetwork) DeployNonpayableSC(owner *TestWalletAccount, fileName string) []byte

DeployNonpayableSC deploys a non-payable contract with the bytecode specified by fileName.

func (*TestNetwork) DeployPayableSC

func (net *TestNetwork) DeployPayableSC(owner *TestWalletAccount, fileName string) []byte

DeployPayableSC deploys a payable contract with the bytecode specified by fileName.

func (*TestNetwork) DeploySC

func (net *TestNetwork) DeploySC(owner *TestWalletAccount, fileName string, payable bool) []byte

DeploySC deploys a contract with the bytecode specified by fileName.

func (*TestNetwork) DeploySCWithInitArgs

func (net *TestNetwork) DeploySCWithInitArgs(
	owner *TestWalletAccount,
	fileName string,
	payable bool,
	args ...[]byte,
) []byte

DeploySCWithInitArgs deploy a contract with initial arguments.

func (*TestNetwork) GetAccountHandler

func (net *TestNetwork) GetAccountHandler(address Address) state.UserAccountHandler

GetAccountHandler retrieves the `state.UserAccountHandler` instance for the specified address by querying a node belonging to the shard of the address.

func (*TestNetwork) Increment

func (net *TestNetwork) Increment()

Increment only increments the Round and the Nonce, without triggering the processing of a block; use Step to process a block as well.

func (*TestNetwork) MintNodeAccounts

func (net *TestNetwork) MintNodeAccounts(value *big.Int)

MintNodeAccounts adds the specified value to the accounts owned by the nodes of the TestNetwork.

func (*TestNetwork) MintNodeAccountsUint64

func (net *TestNetwork) MintNodeAccountsUint64(value uint64)

MintNodeAccountsUint64 adds the specified value to the accounts owned by the nodes of the TestNetwork.

func (*TestNetwork) MintWallets

func (net *TestNetwork) MintWallets(value *big.Int)

MintWallets adds the specified value to the test wallets.

func (*TestNetwork) MintWalletsUint64

func (net *TestNetwork) MintWalletsUint64(value uint64)

MintWalletsUint64 adds the specified value to the test wallets.

func (*TestNetwork) NewAddress

func (net *TestNetwork) NewAddress(creator *TestWalletAccount) Address

NewAddress creates a new child address of the provided wallet; used to compute the address of newly deployed smart contracts.

func (*TestNetwork) NewAddressWithVM added in v1.6.0

func (net *TestNetwork) NewAddressWithVM(creator *TestWalletAccount, vmType []byte) Address

NewAddressWithVM creates a new child address of the provided wallet; used to compute the address of newly deployed smart contracts.

func (*TestNetwork) RequireWalletNoncesInSyncWithState

func (net *TestNetwork) RequireWalletNoncesInSyncWithState()

RequireWalletNoncesInSyncWithState asserts that the nonces of all wallets managed by the test network are in sync with the actual nonces in the blockchain state.

func (*TestNetwork) SendTx

func (net *TestNetwork) SendTx(tx *transaction.Transaction) string

SendTx submits the provided transaction to the test network; transaction must be already signed. Returns the transaction hash.

func (*TestNetwork) SendTxFromNode

func (net *TestNetwork) SendTxFromNode(tx *transaction.Transaction, node *TestProcessorNode) string

SendTxFromNode submits the provided transaction via the specified node; transaction must be already signed. Returns the transaction hash.

func (*TestNetwork) SetWallet added in v1.6.0

func (net *TestNetwork) SetWallet(walletIndex int, wallet *TestWalletAccount)

SetWallet -

func (*TestNetwork) ShardOfAddress

func (net *TestNetwork) ShardOfAddress(address Address) ShardIdentifier

ShardOfAddress returns the shard ID of the specified address.

func (*TestNetwork) SignAndSendTx

func (net *TestNetwork) SignAndSendTx(signer *TestWalletAccount, tx *transaction.Transaction) string

SignAndSendTx signs then submits the provided transaction to the test network, using the provided signer account; use it to send transactions that have been modified after being created. Returns the transaction hash.

func (*TestNetwork) SignTx

func (net *TestNetwork) SignTx(signer *TestWalletAccount, tx *transaction.Transaction)

SignTx signs a transaction with the provided `signer` wallet.

func (*TestNetwork) Start

func (net *TestNetwork) Start() *TestNetwork

Start initializes the test network and starts its nodes

func (*TestNetwork) Step

func (net *TestNetwork) Step()

Step increments the Round and Nonce and triggers the production and synchronization of a single block.

func (*TestNetwork) Steps

func (net *TestNetwork) Steps(steps int)

Steps repeatedly increments the Round and Nonce and processes blocks.

type TestNodeKeys added in v1.6.0

type TestNodeKeys struct {
	MainKey     *TestKeyPair
	HandledKeys []*TestKeyPair
}

TestNodeKeys will hold the main key along the handled keys of a node

type TestProcessorNode

type TestProcessorNode struct {
	ShardCoordinator           sharding.Coordinator
	NodesCoordinator           nodesCoordinator.NodesCoordinator
	MainPeerShardMapper        process.PeerShardMapper
	FullArchivePeerShardMapper process.PeerShardMapper
	NodesSetup                 sharding.GenesisNodesSetupHandler
	MainMessenger              p2p.Messenger
	FullArchiveMessenger       p2p.Messenger
	NodeOperationMode          common.NodeOperation

	OwnAccount *TestWalletAccount
	NodeKeys   *TestNodeKeys

	ExportFolder        string
	DataPool            dataRetriever.PoolsHolder
	Storage             dataRetriever.StorageService
	PeerState           state.AccountsAdapter
	AccntState          state.AccountsAdapter
	TrieStorageManagers map[string]common.StorageManager
	TrieContainer       common.TriesHolder
	BlockChain          data.ChainHandler
	GenesisBlocks       map[uint32]data.HeaderHandler

	EconomicsData *economics.TestEconomicsData
	RatingsData   *rating.RatingsData

	BlockBlackListHandler            process.TimeCacher
	HeaderValidator                  process.HeaderConstructionValidator
	BlockTracker                     process.BlockTracker
	MainInterceptorsContainer        process.InterceptorsContainer
	FullArchiveInterceptorsContainer process.InterceptorsContainer
	ResolversContainer               dataRetriever.ResolversContainer
	RequestersContainer              dataRetriever.RequestersContainer
	RequestersFinder                 dataRetriever.RequestersFinder
	RequestHandler                   process.RequestHandler
	WasmVMChangeLocker               common.Locker

	InterimProcContainer   process.IntermediateProcessorContainer
	TxProcessor            process.TransactionProcessor
	TxCoordinator          process.TransactionCoordinator
	ScrForwarder           process.IntermediateTransactionHandler
	BlockchainHook         *hooks.BlockChainHookImpl
	VMFactory              process.VirtualMachinesContainerFactory
	VMContainer            process.VirtualMachinesContainer
	ArgsParser             process.ArgumentsParser
	ScProcessor            process.SmartContractProcessorFacade
	RewardsProcessor       process.RewardTransactionProcessor
	PreProcessorsContainer process.PreProcessorsContainer
	GasHandler             process.GasHandler
	FeeAccumulator         process.TransactionFeeHandler
	SmartContractParser    genesis.InitialSmartContractParser
	SystemSCFactory        vm.SystemSCContainerFactory

	ForkDetector             process.ForkDetector
	BlockProcessor           process.BlockProcessor
	BroadcastMessenger       consensus.BroadcastMessenger
	MiniblocksProvider       process.MiniBlockProvider
	Bootstrapper             TestBootstrapper
	RoundHandler             *mock.RoundHandlerMock
	BootstrapStorer          *mock.BoostrapStorerMock
	StorageBootstrapper      *mock.StorageBootstrapperMock
	RequestedItemsHandler    dataRetriever.RequestedItemsHandler
	WhiteListHandler         process.WhiteListHandler
	WhiteListerVerifiedTxs   process.WhiteListHandler
	NetworkShardingCollector consensus.NetworkShardingCollector

	EpochStartTrigger  TestEpochStartTrigger
	EpochStartNotifier notifier.EpochStartNotifier
	EpochProvider      dataRetriever.CurrentNetworkEpochProviderHandler

	MultiSigner             crypto.MultiSigner
	HeaderSigVerifier       process.InterceptedHeaderSigVerifier
	HeaderIntegrityVerifier process.HeaderIntegrityVerifier
	GuardedAccountHandler   process.GuardedAccountHandler

	ValidatorStatisticsProcessor process.ValidatorStatisticsProcessor
	Rater                        sharding.PeerAccountListAndRatingHandler

	EpochStartSystemSCProcessor process.EpochStartSystemSCProcessor
	TxExecutionOrderHandler     common.TxExecutionOrderHandler

	// Node is used to call the functionality already implemented in it
	Node           *node.Node
	SCQueryService external.SCQueryService

	CounterHdrRecv       int32
	CounterMbRecv        int32
	CounterTxRecv        int32
	CounterMetaRcv       int32
	ReceivedTransactions sync.Map

	InitialNodes []*sharding.InitialNode

	ChainID               []byte
	MinTransactionVersion uint32

	ExportHandler            update.ExportHandler
	WaitTime                 time.Duration
	HistoryRepository        dblookupext.HistoryRepository
	EpochNotifier            process.EpochNotifier
	RoundNotifier            process.RoundNotifier
	EnableEpochs             config.EnableEpochs
	EnableRoundsHandler      process.EnableRoundsHandler
	EnableEpochsHandler      common.EnableEpochsHandler
	UseValidVmBlsSigVerifier bool

	TransactionLogProcessor process.TransactionLogProcessor
	PeersRatingHandler      p2p.PeersRatingHandler
	PeersRatingMonitor      p2p.PeersRatingMonitor
	HardforkTrigger         node.HardforkTrigger
	AppStatusHandler        core.AppStatusHandler
	StatusMetrics           external.StatusMetricsHandler
}

TestProcessorNode represents a container type of class used in integration tests with all its fields exported

func CreateNode

func CreateNode(
	nodesPerShard int,
	nbMetaNodes int,
	shardConsensusGroupSize int,
	metaConsensusGroupSize int,
	shardId uint32,
	nbShards int,
	validatorsMap map[uint32][]nodesCoordinator.Validator,
	waitingMap map[uint32][]nodesCoordinator.Validator,
	keyIndex int,
	cp *CryptoParams,
	cache nodesCoordinator.Cacher,
	coordinatorFactory NodesCoordinatorFactory,
	nodesSetup sharding.GenesisNodesSetupHandler,
	ratingsData *rating.RatingsData,
	ownAccount *TestWalletAccount,
	epochsConfig config.EnableEpochs,
) *TestProcessorNode

CreateNode -

func CreateNodeWithBLSAndTxKeys

func CreateNodeWithBLSAndTxKeys(
	nodesPerShard int,
	nbMetaNodes int,
	shardConsensusGroupSize int,
	metaConsensusGroupSize int,
	shardId uint32,
	nbShards int,
	validatorsMap map[uint32][]nodesCoordinator.Validator,
	waitingMap map[uint32][]nodesCoordinator.Validator,
	keyIndex int,
	cp *CryptoParams,
	cache nodesCoordinator.Cacher,
	coordinatorFactory NodesCoordinatorFactory,
	nodesSetup sharding.GenesisNodesSetupHandler,
	ratingsData *rating.RatingsData,
) *TestProcessorNode

CreateNodeWithBLSAndTxKeys -

func CreateNodes

func CreateNodes(
	numOfShards int,
	nodesPerShard int,
	numMetaChainNodes int,
) []*TestProcessorNode

CreateNodes creates multiple nodes in different shards

func CreateNodesWithBLSSigVerifier

func CreateNodesWithBLSSigVerifier(
	numOfShards int,
	nodesPerShard int,
	numMetaChainNodes int,
) []*TestProcessorNode

CreateNodesWithBLSSigVerifier creates multiple nodes in different shards

func CreateNodesWithEnableEpochs

func CreateNodesWithEnableEpochs(
	numOfShards int,
	nodesPerShard int,
	numMetaChainNodes int,
	epochConfig config.EnableEpochs,
) []*TestProcessorNode

CreateNodesWithEnableEpochs creates multiple nodes with custom epoch config

func CreateNodesWithEnableEpochsAndVmConfig added in v1.6.0

func CreateNodesWithEnableEpochsAndVmConfig(
	numOfShards int,
	nodesPerShard int,
	numMetaChainNodes int,
	epochConfig config.EnableEpochs,
	vmConfig *config.VirtualMachineConfig,
) []*TestProcessorNode

CreateNodesWithEnableEpochsAndVmConfig creates multiple nodes with custom epoch and vm config

func CreateNodesWithEnableEpochsAndVmConfigWithRoundsConfig added in v1.6.0

func CreateNodesWithEnableEpochsAndVmConfigWithRoundsConfig(
	numOfShards int,
	nodesPerShard int,
	numMetaChainNodes int,
	epochConfig config.EnableEpochs,
	roundsConfig config.RoundConfig,
	vmConfig *config.VirtualMachineConfig,
) []*TestProcessorNode

CreateNodesWithEnableEpochsAndVmConfigWithRoundsConfig creates multiple nodes with custom epoch and vm config

func CreateNodesWithEnableEpochsConfig

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

CreateNodesWithEnableEpochsConfig creates multiple nodes in different shards but with custom enable epochs config

func NewTestProcessorNode

func NewTestProcessorNode(args ArgTestProcessorNode) *TestProcessorNode

NewTestProcessorNode returns a new TestProcessorNode instance with a libp2p messenger and the provided arguments

func ProposeBlockWithConsensusSignature

func ProposeBlockWithConsensusSignature(
	shardId uint32,
	nodesMap map[uint32][]*TestProcessorNode,
	round uint64,
	nonce uint64,
	randomness []byte,
	epoch uint32,
) (data.BodyHandler, data.HeaderHandler, [][]byte, []*TestProcessorNode)

ProposeBlockWithConsensusSignature proposes

func SetupSyncNodesOneShardAndMeta

func SetupSyncNodesOneShardAndMeta(
	numNodesPerShard int,
	numNodesMeta int,
) ([]*TestProcessorNode, []int)

SetupSyncNodesOneShardAndMeta creates nodes with sync capabilities divided into one shard and a metachain

func (*TestProcessorNode) BroadcastBlock

func (tpn *TestProcessorNode) BroadcastBlock(body data.BodyHandler, header data.HeaderHandler, publicKey crypto.PublicKey)

BroadcastBlock broadcasts the block and body to the connected peers

func (*TestProcessorNode) Close

func (tpn *TestProcessorNode) Close()

Close -

func (*TestProcessorNode) CommitBlock

func (tpn *TestProcessorNode) CommitBlock(body data.BodyHandler, header data.HeaderHandler)

CommitBlock commits the block and body

func (*TestProcessorNode) ConnectOnFullArchive added in v1.6.0

func (tpn *TestProcessorNode) ConnectOnFullArchive(connectable Connectable) error

ConnectOnFullArchive will try to initiate a connection to the provided parameter on the full archive messenger

func (*TestProcessorNode) ConnectOnMain added in v1.6.0

func (tpn *TestProcessorNode) ConnectOnMain(connectable Connectable) error

ConnectOnMain will try to initiate a connection to the provided parameter on the main messenger

func (*TestProcessorNode) GetBlockBody

func (tpn *TestProcessorNode) GetBlockBody(header data.HeaderHandler) (*dataBlock.Body, error)

GetBlockBody returns the body for provided header parameter

func (*TestProcessorNode) GetFullArchiveConnectableAddress added in v1.6.0

func (tpn *TestProcessorNode) GetFullArchiveConnectableAddress() string

GetFullArchiveConnectableAddress returns a non circuit, non windows default connectable p2p address of the full archive network

func (*TestProcessorNode) GetMainConnectableAddress added in v1.6.0

func (tpn *TestProcessorNode) GetMainConnectableAddress() string

GetMainConnectableAddress returns a non circuit, non windows default connectable p2p address main network

func (*TestProcessorNode) GetMetaBlockBody

func (tpn *TestProcessorNode) GetMetaBlockBody(header *dataBlock.MetaBlock) (*dataBlock.Body, error)

GetMetaBlockBody returns the body for provided header parameter

func (*TestProcessorNode) GetMetaHeader

func (tpn *TestProcessorNode) GetMetaHeader(nonce uint64) (*dataBlock.MetaBlock, error)

GetMetaHeader returns the first *dataBlock.MetaBlock stored in datapools having the nonce provided as parameter

func (*TestProcessorNode) GetShardHeader

func (tpn *TestProcessorNode) GetShardHeader(nonce uint64) (data.HeaderHandler, error)

GetShardHeader returns the first *dataBlock.Header stored in datapools having the nonce provided as parameter

func (*TestProcessorNode) InitDelegationManager

func (tpn *TestProcessorNode) InitDelegationManager()

InitDelegationManager will initialize the delegation manager whenever required

func (*TestProcessorNode) InitializeProcessors

func (tpn *TestProcessorNode) InitializeProcessors(gasMap map[string]map[string]uint64)

InitializeProcessors will reinitialize processors

func (*TestProcessorNode) IsInterfaceNil

func (tpn *TestProcessorNode) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*TestProcessorNode) LoadTxSignSkBytes

func (tpn *TestProcessorNode) LoadTxSignSkBytes(skBytes []byte)

LoadTxSignSkBytes alters the already generated sk/pk pair

func (*TestProcessorNode) MiniBlocksPresent

func (tpn *TestProcessorNode) MiniBlocksPresent(hashes [][]byte) bool

MiniBlocksPresent checks if the all the miniblocks are present in the pool

func (*TestProcessorNode) ProposeBlock

func (tpn *TestProcessorNode) ProposeBlock(round uint64, nonce uint64) (data.BodyHandler, data.HeaderHandler, [][]byte)

ProposeBlock proposes a new block

func (*TestProcessorNode) SendTransaction

func (tpn *TestProcessorNode) SendTransaction(tx *dataTransaction.Transaction) (string, error)

SendTransaction can send a transaction (it does the dispatching)

func (*TestProcessorNode) SetAccountNonce

func (tpn *TestProcessorNode) SetAccountNonce(nonce uint64) error

SetAccountNonce sets the account nonce with journal

func (*TestProcessorNode) StartSync

func (tpn *TestProcessorNode) StartSync() error

StartSync calls Bootstrapper.StartSync. Errors if bootstrapper is not set

func (*TestProcessorNode) SyncNode

func (tpn *TestProcessorNode) SyncNode(nonce uint64) error

SyncNode tries to process and commit a block already stored in data pool with provided nonce

func (*TestProcessorNode) WhiteListBody

func (tpn *TestProcessorNode) WhiteListBody(nodes []*TestProcessorNode, bodyHandler data.BodyHandler)

WhiteListBody will whitelist all miniblocks from the given body for all the given nodes

type TestProcessorNodeWithTestWebServer

type TestProcessorNodeWithTestWebServer struct {
	*TestProcessorNode
	// contains filtered or unexported fields
}

TestProcessorNodeWithTestWebServer represents a TestProcessorNode with a test web server

func NewTestProcessorNodeWithTestWebServer

func NewTestProcessorNodeWithTestWebServer(
	maxShards uint32,
	nodeShardId uint32,
	txSignPrivKeyShardId uint32,
) *TestProcessorNodeWithTestWebServer

NewTestProcessorNodeWithTestWebServer returns a new TestProcessorNodeWithTestWebServer instance with a libp2p messenger

func (*TestProcessorNodeWithTestWebServer) DoRequest

DoRequest preforms a test request on the web server, returning the response ready to be parsed

type TestStorage

type TestStorage struct {
	// contains filtered or unexported fields
}

TestStorage represents a container type of class used in integration tests for storage

func NewTestStorage

func NewTestStorage() *TestStorage

NewTestStorage return an object of type TestStorage

func (*TestStorage) CreateStorageLevelDB

func (ts *TestStorage) CreateStorageLevelDB() storage.Storer

CreateStorageLevelDB creates a storage levelDB

func (*TestStorage) CreateStorageLevelDBSerial

func (ts *TestStorage) CreateStorageLevelDBSerial() storage.Storer

CreateStorageLevelDBSerial creates a storage levelDB serial

func (*TestStorage) CreateStoredData

func (ts *TestStorage) CreateStoredData(nonce uint64) ([]byte, []byte)

CreateStoredData creates stored data

func (*TestStorage) InitAdditionalFieldsForStorageOperations

func (ts *TestStorage) InitAdditionalFieldsForStorageOperations(nbTxsWrite int, mapRemovedKeys *sync.Map, maxWritten *uint64)

InitAdditionalFieldsForStorageOperations init additional structure fields to can do storage operations

func (*TestStorage) ReadMultiple

func (ts *TestStorage) ReadMultiple(
	store storage.Storer,
	wg *sync.WaitGroup,
	chStartTrigger chan struct{},
	errors *int32,
)

ReadMultiple read multiple data from storage

func (*TestStorage) RemoveMultiple

func (ts *TestStorage) RemoveMultiple(
	store storage.Storer,
	wg *sync.WaitGroup,
	chEndRemove chan struct{},
	errors *int32,
)

RemoveMultiple remove multiple data from storage

func (*TestStorage) WriteMultipleWithNotif

func (ts *TestStorage) WriteMultipleWithNotif(
	store storage.Storer,
	wg *sync.WaitGroup,
	chWriteDone chan struct{},
	nbNotifDone int,
	errors *int32,
)

WriteMultipleWithNotif write multiple data in storage without notification

type TestWalletAccount

type TestWalletAccount struct {
	SingleSigner      crypto.SingleSigner
	BlockSingleSigner crypto.SingleSigner
	SkTxSign          crypto.PrivateKey
	PkTxSign          crypto.PublicKey
	PkTxSignBytes     []byte
	KeygenTxSign      crypto.KeyGenerator
	KeygenBlockSign   crypto.KeyGenerator
	PeerSigHandler    crypto.PeerSignatureHandler

	Address []byte
	Nonce   uint64
	Balance *big.Int
}

TestWalletAccount creates and account with balance and crypto necessary to sign transactions

func CreateTestWalletAccount

func CreateTestWalletAccount(coordinator sharding.Coordinator, shardId uint32) *TestWalletAccount

CreateTestWalletAccount creates a wallet account in a selected shard

func CreateTestWalletAccountWithKeygenAndSingleSigner

func CreateTestWalletAccountWithKeygenAndSingleSigner(
	coordinator sharding.Coordinator,
	shardId uint32,
	blockSingleSigner crypto.SingleSigner,
	keyGenBlockSign crypto.KeyGenerator,
) *TestWalletAccount

CreateTestWalletAccountWithKeygenAndSingleSigner creates a wallet account in a selected shard

func (*TestWalletAccount) LoadTxSignSkBytes

func (twa *TestWalletAccount) LoadTxSignSkBytes(skBytes []byte)

LoadTxSignSkBytes alters the already generated sk/pk pair

type Type

type Type uint8

Type defines account types to save in accounts trie

const (
	// UserAccount identifies an account holding balance, storage updates, code
	UserAccount Type = 0
	// ValidatorAccount identifies an account holding stake, crypto public keys, assigned shard, rating
	ValidatorAccount Type = 1
)

Jump to

Keyboard shortcuts

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