Documentation ¶
Index ¶
- Constants
- Variables
- func AdbEmulateBalanceTxExecution(accounts state.AccountsAdapter, acntSrc, acntDest state.UserAccountHandler, ...) error
- func AdbEmulateBalanceTxSafeExecution(acntSrc, acntDest state.UserAccountHandler, accounts state.AccountsAdapter, ...)
- func AddSelfNotarizedHeaderByMetachain(nodes []*TestProcessorNode)
- func AllShardsProposeBlock(round uint64, nonce uint64, nodesMap map[uint32][]*TestProcessorNode) (map[uint32]data.BodyHandler, map[uint32]data.HeaderHandler, ...)
- func CheckBalanceIsDoneCorrectlySCSideAndReturnExpectedVal(t *testing.T, nodes []*TestProcessorNode, idxNodeScExists int, ...) *big.Int
- func CheckJoinGame(t *testing.T, nodes []*TestProcessorNode, players []*TestWalletAccount, ...)
- func CheckPlayerBalanceTheSameWithBlockchain(t *testing.T, nodes []*TestProcessorNode, player *TestWalletAccount)
- func CheckRewardsDistribution(t *testing.T, nodes []*TestProcessorNode, players []*TestWalletAccount, ...)
- func CheckRootHashes(t *testing.T, nodes []*TestProcessorNode, idxProposers []int)
- func CheckScBalanceOf(t *testing.T, nodeWithSc *TestProcessorNode, nodeWithCaller *TestProcessorNode, ...)
- func CheckScTopUp(t *testing.T, nodeWithSc *TestProcessorNode, topUpVal *big.Int, ...)
- func CheckSenderBalanceOkAfterTopUp(t *testing.T, nodeWithCaller *TestProcessorNode, initialVal *big.Int, ...)
- func CheckSenderBalanceOkAfterTopUpAndWithdraw(t *testing.T, nodeWithCaller *TestProcessorNode, initialVal *big.Int, ...)
- func CheckTxPresentAndRightNonce(t *testing.T, startingNonce uint64, noOfTxs int, txHashes [][]byte, ...)
- func ClosePeers(peers []p2p.Messenger)
- func CloseProcessorNodes(nodes []*TestProcessorNode, advertiser p2p.Messenger)
- func ComputeAndRequestMissingTransactions(nodes []*TestProcessorNode, generatedTxHashes [][]byte, shardResolver uint32, ...)
- func CreateAccount(accnts state.AccountsAdapter, nonce uint64, balance *big.Int) []byte
- func CreateAccountForNode(node *TestProcessorNode)
- func CreateAccountForNodes(nodes []*TestProcessorNode)
- func CreateAccountsDB(accountType Type, trieStorageManager data.StorageManager) (*state.AccountsDB, data.Trie)
- func CreateAndSendTransaction(node *TestProcessorNode, txValue *big.Int, rcvAddress []byte, txData string)
- func CreateAndSendTransactionWithGasLimit(node *TestProcessorNode, txValue *big.Int, gasLimit uint64, rcvAddress []byte, ...)
- func CreateAndSendTransactions(nodes map[uint32][]*TestProcessorNode, ...)
- func CreateEconomicsData() *economics.EconomicsData
- func CreateFixedNetworkOf14Peers() ([]p2p.Messenger, error)
- func CreateFixedNetworkOf8Peers() ([]p2p.Messenger, error)
- func CreateFullGenesisBlocks(accounts state.AccountsAdapter, validatorAccounts state.AccountsAdapter, ...) map[uint32]data.HeaderHandler
- func CreateGenesisBlocks(accounts state.AccountsAdapter, validatorAccounts state.AccountsAdapter, ...) map[uint32]data.HeaderHandler
- func CreateGenesisMetaBlock(accounts state.AccountsAdapter, validatorAccounts state.AccountsAdapter, ...) data.HeaderHandler
- func CreateMemUnit() storage.Storer
- func CreateMessengerFromConfig(p2pConfig config.P2PConfig) p2p.Messenger
- func CreateMessengerWithKadDht(initialAddr string) p2p.Messenger
- func CreateMessengerWithKadDhtAndProtocolID(initialAddr string, protocolID string) p2p.Messenger
- func CreateMessengerWithNoDiscovery() p2p.Messenger
- func CreateMetaChain() data.ChainHandler
- func CreateMintingForSenders(nodes []*TestProcessorNode, senderShard uint32, ...)
- func CreateMintingFromAddresses(nodes []*TestProcessorNode, addresses [][]byte, value *big.Int)
- func CreateNewDefaultTrie() data.Trie
- func CreateNodesWithNodesCoordinator(nodesPerShard int, nbMetaNodes int, nbShards int, shardConsensusGroupSize int, ...) map[uint32][]*TestProcessorNode
- func CreateNodesWithNodesCoordinatorAndHeaderSigVerifier(nodesPerShard int, nbMetaNodes int, nbShards int, shardConsensusGroupSize int, ...) map[uint32][]*TestProcessorNode
- func CreateNodesWithNodesCoordinatorAndTxKeys(nodesPerShard int, nbMetaNodes int, nbShards int, shardConsensusGroupSize int, ...) map[uint32][]*TestProcessorNode
- func CreateNodesWithNodesCoordinatorFactory(nodesPerShard int, nbMetaNodes int, nbShards int, shardConsensusGroupSize int, ...) map[uint32][]*TestProcessorNode
- func CreateNodesWithNodesCoordinatorKeygenAndSingleSigner(nodesPerShard int, nbMetaNodes int, nbShards int, shardConsensusGroupSize int, ...) map[uint32][]*TestProcessorNode
- func CreateNodesWithNodesCoordinatorWithCacher(nodesPerShard int, nbMetaNodes int, nbShards int, shardConsensusGroupSize int, ...) map[uint32][]*TestProcessorNode
- func CreateNodesWithTestP2PNodes(nodesPerShard int, numMetaNodes int, numShards int, ...) map[uint32][]*TestP2PNode
- func CreatePkBytes(numShards uint32) map[uint32][]byte
- func CreateProcessorNodesWithNodesCoordinator(rewardsAddrsAssignments map[uint32][]uint32, shardConsensusGroupSize int, ...) (map[uint32][]*TestProcessorNode, uint32)
- func CreateRandomAddress() []byte
- func CreateRandomBytes(chars int) []byte
- func CreateRatingsData() *rating.RatingsData
- func CreateRequesterDataPool(recvTxs map[int]map[string]struct{}, mutRecvTxs *sync.Mutex, nodeIndex int, ...) dataRetriever.PoolsHolder
- func CreateResolversDataPool(t *testing.T, maxTxs int, senderShardID uint32, recvShardId uint32, ...) (dataRetriever.PoolsHolder, [][]byte, [][]byte)
- func CreateSendersAndReceiversInShard(nodeInShard *TestProcessorNode, nbSenderReceiverPairs uint32) ([]crypto.PrivateKey, []crypto.PublicKey)
- func CreateSendersWithInitialBalances(nodesMap map[uint32][]*TestProcessorNode, mintValue *big.Int) map[uint32][]crypto.PrivateKey
- func CreateShardChain() data.ChainHandler
- func CreateSimpleGenesisBlock(shardId uint32) *dataBlock.Header
- func CreateSimpleGenesisBlocks(shardCoordinator sharding.Coordinator) map[uint32]data.HeaderHandler
- func CreateSimpleGenesisMetaBlock() *dataBlock.MetaBlock
- func CreateSimpleTxProcessor(accnts state.AccountsAdapter) process.TransactionProcessor
- func CreateStore(numOfShards uint32) dataRetriever.StorageService
- func CreateTrieStorageManager() (data.StorageManager, storage.Storer)
- func DeployScTx(nodes []*TestProcessorNode, senderIdx int, scCode string, vmType []byte, ...)
- func DisplayAndStartNodes(nodes []*TestProcessorNode)
- func DoConsensusSigningOnBlock(blockHeader data.HeaderHandler, consensusNodes []*TestProcessorNode, ...) data.HeaderHandler
- func EmptyDataPools(nodes []*TestProcessorNode, shardId uint32)
- func ForkChoiceOneBlock(nodes []*TestProcessorNode, shardId uint32)
- func GenValidatorsFromPubKeys(pubKeysMap map[uint32][]string, _ uint32) map[uint32][]sharding.GenesisNodeInfoHandler
- func GenValidatorsFromPubKeysAndTxPubKeys(blsPubKeysMap map[uint32][]string, txPubKeysMap map[uint32][]string) map[uint32][]sharding.GenesisNodeInfoHandler
- func GenerateAddressJournalAccountAccountsDB() ([]byte, state.UserAccountHandler, *state.AccountsDB)
- func GenerateAndDisseminateTxs(n *TestProcessorNode, senders []crypto.PrivateKey, ...)
- func GenerateIntraShardTransactions(nodesMap map[uint32][]*TestProcessorNode, nbTxsPerShard uint32, ...)
- func GenerateRandomSlice(size int) []byte
- func GenerateSkAndPkInShard(coordinator sharding.Coordinator, shardId uint32) (crypto.PrivateKey, crypto.PublicKey, crypto.KeyGenerator)
- func GenerateTransferTx(nonce uint64, senderPrivateKey crypto.PrivateKey, ...) *transaction.Transaction
- func GetConnectableAddress(mes p2p.Messenger) string
- func GetMiniBlocksHashesFromShardIds(body *dataBlock.Body, shardIds ...uint32) [][]byte
- func IncrementAndPrintRound(round uint64) uint64
- func IncrementNonces(nonces []*uint64)
- func IsIntInSlice(idx int, slice []int) bool
- func MakeDisplayTable(nodes []*TestProcessorNode) string
- func MakeDisplayTableForP2PNodes(nodes map[uint32][]*TestP2PNode) string
- func MintAddress(accnts state.AccountsAdapter, addressBytes []byte, value *big.Int)
- func MintAllNodes(nodes []*TestProcessorNode, value *big.Int)
- func MintAllPlayers(nodes []*TestProcessorNode, players []*TestWalletAccount, value *big.Int)
- func NewOneNodeNetwork() *oneNodeNetwork
- func NodeCallsRewardAndSend(nodes []*TestProcessorNode, idxNodeOwner int, winnerPlayer *TestWalletAccount, ...)
- func NodeDoesTopUp(nodes []*TestProcessorNode, idxNode int, topUpValue *big.Int, scAddress []byte)
- func NodeDoesWithdraw(nodes []*TestProcessorNode, idxNode int, withdrawValue *big.Int, ...)
- func PlayerJoinsGame(nodes []*TestProcessorNode, player *TestWalletAccount, joinGameVal *big.Int, ...)
- func PlayerSendsTransaction(nodes []*TestProcessorNode, player *TestWalletAccount, scAddress []byte, ...)
- func PrintShardAccount(accnt state.UserAccountHandler, tag string)
- func ProposeAndSyncOneBlock(t *testing.T, nodes []*TestProcessorNode, idxProposers []int, round uint64, ...) (uint64, uint64)
- func ProposeBlock(nodes []*TestProcessorNode, idxProposers []int, round uint64, nonce uint64)
- func ProposeBlockSignalsEmptyBlock(node *TestProcessorNode, round uint64, nonce uint64) (data.HeaderHandler, data.BodyHandler, bool)
- func ProposeBlocks(nodes []*TestProcessorNode, round *uint64, idxProposers []int, ...)
- func PubKeysMapFromKeysMap(keyPairMap map[uint32][]*TestKeyPair) map[uint32][]string
- func ResetHighestProbableNonce(nodes []*TestProcessorNode, shardId uint32, targetNonce uint64)
- func ScCallTxWithParams(senderNode *TestProcessorNode, sk crypto.PrivateKey, nonce uint64, data string, ...)
- func SetEconomicsParameters(nodes []*TestProcessorNode, maxGasLimitPerBlock uint64, minGasPrice uint64, ...)
- func StartP2PBootstrapOnProcessorNodes(nodes []*TestProcessorNode)
- func StartSyncingBlocks(nodes []*TestProcessorNode)
- func SyncAllShardsWithRoundBlock(t *testing.T, nodesMap map[uint32][]*TestProcessorNode, ...)
- func SyncBlock(t *testing.T, nodes []*TestProcessorNode, idxProposers []int, round uint64)
- func TestPrivateKeyHasBalance(t *testing.T, n *TestProcessorNode, sk crypto.PrivateKey, ...)
- func TestPublicKeyHasBalance(t *testing.T, n *TestProcessorNode, pk crypto.PublicKey, ...)
- func Uint32InSlice(searched uint32, list []uint32) bool
- func UpdateRound(nodes []*TestProcessorNode, round uint64)
- func WaitForBootstrapAndShowConnected(peers []p2p.Messenger, durationBootstrapingTime time.Duration)
- func WaitOperationToBeDone(t *testing.T, nodes []*TestProcessorNode, nrOfRounds int, nonce, round uint64, ...) (uint64, uint64)
- func WhiteListTxs(nodes []*TestProcessorNode, txs []*transaction.Transaction)
- type ArgIndexHashedNodesCoordinatorFactory
- type CountInterceptor
- type CryptoParams
- type IndexHashedNodesCoordinatorFactory
- type IndexHashedNodesCoordinatorWithRaterFactory
- type NetworkShardingUpdater
- type NodesCoordinatorFactory
- type NodesWithRater
- type TestBootstrapper
- type TestEpochStartTrigger
- type TestKeyPair
- type TestP2PNode
- func (tP2pNode *TestP2PNode) CountCrossShardMessages() int
- func (tP2pNode *TestP2PNode) CountGlobalMessages() int
- func (tP2pNode *TestP2PNode) CountIntraShardMessages() int
- func (tP2pNode *TestP2PNode) CreateTestInterceptors()
- func (tP2pNode *TestP2PNode) RegisterTopicValidator(topic string, processor p2p.MessageProcessor)
- type TestProcessorNode
- func CreateNode(nodesPerShard int, nbMetaNodes int, shardConsensusGroupSize int, ...) *TestProcessorNode
- func CreateNodeWithBLSAndTxKeys(nodesPerShard int, nbMetaNodes int, shardConsensusGroupSize int, ...) *TestProcessorNode
- func CreateNodes(numOfShards int, nodesPerShard int, numMetaChainNodes int, serviceID string) []*TestProcessorNode
- func CreateNodesWithCustomStateCheckpointModulus(numOfShards int, nodesPerShard int, numMetaChainNodes int, serviceID string, ...) []*TestProcessorNode
- func CreateNodesWithFullGenesis(numOfShards int, nodesPerShard int, numMetaChainNodes int, serviceID string, ...) []*TestProcessorNode
- func NewTestProcessorNode(maxShards uint32, nodeShardId uint32, txSignPrivKeyShardId uint32, ...) *TestProcessorNode
- func NewTestProcessorNodeWithCustomDataPool(maxShards uint32, nodeShardId uint32, txSignPrivKeyShardId uint32, ...) *TestProcessorNode
- func NewTestProcessorNodeWithCustomNodesCoordinator(maxShards uint32, nodeShardId uint32, initialNodeAddr string, ...) *TestProcessorNode
- func NewTestProcessorNodeWithFullGenesis(maxShards uint32, nodeShardId uint32, txSignPrivKeyShardId uint32, ...) *TestProcessorNode
- func NewTestProcessorNodeWithStateCheckpointModulus(maxShards uint32, nodeShardId uint32, txSignPrivKeyShardId uint32, ...) *TestProcessorNode
- func NewTestSyncNode(maxShards uint32, nodeShardId uint32, txSignPrivKeyShardId uint32, ...) *TestProcessorNode
- func ProposeBlockWithConsensusSignature(shardId uint32, nodesMap map[uint32][]*TestProcessorNode, round uint64, ...) (data.BodyHandler, data.HeaderHandler, [][]byte, []*TestProcessorNode)
- func SetupSyncNodesOneShardAndMeta(numNodesPerShard int, numNodesMeta int) ([]*TestProcessorNode, p2p.Messenger, []int)
- func (tpn *TestProcessorNode) BroadcastBlock(body data.BodyHandler, header data.HeaderHandler)
- func (tpn *TestProcessorNode) CommitBlock(body data.BodyHandler, header data.HeaderHandler)
- func (tpn *TestProcessorNode) GetBlockBody(header *dataBlock.Header) (*dataBlock.Body, error)
- func (tpn *TestProcessorNode) GetMetaBlockBody(header *dataBlock.MetaBlock) (*dataBlock.Body, error)
- func (tpn *TestProcessorNode) GetMetaHeader(nonce uint64) (*dataBlock.MetaBlock, error)
- func (tpn *TestProcessorNode) GetShardHeader(nonce uint64) (*dataBlock.Header, error)
- func (tpn *TestProcessorNode) InitializeProcessors()
- func (tpn *TestProcessorNode) LoadTxSignSkBytes(skBytes []byte)
- func (tpn *TestProcessorNode) MiniBlocksPresent(hashes [][]byte) bool
- func (tpn *TestProcessorNode) ProposeBlock(round uint64, nonce uint64) (data.BodyHandler, data.HeaderHandler, [][]byte)
- func (tpn *TestProcessorNode) SendTransaction(tx *dataTransaction.Transaction) (string, error)
- func (tpn *TestProcessorNode) SetAccountNonce(nonce uint64) error
- func (tpn *TestProcessorNode) StartSync() error
- func (tpn *TestProcessorNode) SyncNode(nonce uint64) error
- func (tpn *TestProcessorNode) WhiteListBody(nodes []*TestProcessorNode, bodyHandler data.BodyHandler)
- type TestStorage
- func (ts *TestStorage) CreateStorageLevelDB() storage.Storer
- func (ts *TestStorage) CreateStorageLevelDBSerial() storage.Storer
- func (ts *TestStorage) CreateStoredData(nonce uint64) ([]byte, []byte)
- func (ts *TestStorage) InitAdditionalFieldsForStorageOperations(nbTxsWrite int, mapRemovedKeys *sync.Map, maxWritten *uint64)
- func (ts *TestStorage) ReadMultiple(store storage.Storer, wg *sync.WaitGroup, chStartTrigger chan struct{}, ...)
- func (ts *TestStorage) RemoveMultiple(store storage.Storer, wg *sync.WaitGroup, chEndRemove chan struct{}, ...)
- func (ts *TestStorage) WriteMultipleWithNotif(store storage.Storer, wg *sync.WaitGroup, chWriteDone chan struct{}, ...)
- type TestWalletAccount
- type Type
Constants ¶
const GlobalTopic = "global"
GlobalTopic is a global testing that all nodes will bind an interceptor
const MaxGasLimitPerBlock = uint64(3000000)
MaxGasLimitPerBlock defines maximum gas limit allowed per one block
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
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
Variables ¶
var ChainID = []byte("integration tests chain ID")
ChainID is the chain ID identifier used in integration tests, processing nodes
var InitialRating = uint32(50)
InitialRating is used to initiate a node's info
var MinTransactionVersion = uint32(999)
MinTransactionVersion is the minimum transaction version used in integration testes, processing nodes
var MinTxGasLimit = uint64(1000)
MinTxGasLimit defines minimum gas limit required by a transaction
var MinTxGasPrice = uint64(10)
MinTxGasPrice defines minimum gas price required by a transaction
var P2pBootstrapDelay = 5 * time.Second
P2pBootstrapDelay is used so that nodes have enough time to bootstrap
var SoftwareVersion = []byte("intT")
SoftwareVersion is the software version identifier used in integration tests, processing nodes
var StepDelay = time.Second
StepDelay is used so that transactions can disseminate properly
var SyncDelay = time.Second * 2
SyncDelay is used so that nodes have enough time to sync
var TestAddressPubkeyConverter, _ = pubkeyConverter.NewBech32PubkeyConverter(32)
TestAddressPubkeyConverter represents an address public key converter
var TestBalanceComputationHandler, _ = preprocess.NewBalanceComputation()
TestBalanceComputationHandler represents a balance computation handler
var TestBlockSizeComputationHandler, _ = preprocess.NewBlockSizeComputation(TestMarshalizer, TestBlockSizeThrottler, uint32(core.MegabyteSize*90/100))
TestBlockSizeComputation represents a block size computation handler
var TestBlockSizeThrottler = &mock.BlockSizeThrottlerStub{}
TestBlockSizeThrottler represents a block size throttler used in adaptive block size computation
var TestHasher = sha256.Sha256{}
TestHasher represents a Sha256 hasher
var TestKeyGenForAccounts = signing.NewKeyGenerator(ed25519.NewEd25519())
TestKeyGenForAccounts represents a mock key generator for balances
var TestMarshalizer = &marshal.GogoProtoMarshalizer{}
TestMarshalizer represents the main marshalizer
var TestMultiSig = mock.NewMultiSigner(1)
TestMultiSig represents a mock multisig
var TestTxSignMarshalizer = &marshal.JsonMarshalizer{}
TestTxSignMarshalizer represents the marshalizer used in vm communication
var TestUint64Converter = uint64ByteSlice.NewBigEndianConverter()
TestUint64Converter represents an uint64 to byte slice converter
var TestValidatorPubkeyConverter, _ = pubkeyConverter.NewHexPubkeyConverter(96)
TestValidatorPubkeyConverter represents an address public key converter
var TestVmMarshalizer = &marshal.JsonMarshalizer{}
TestVmMarshalizer represents the marshalizer used in vm communication
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 CheckBalanceIsDoneCorrectlySCSideAndReturnExpectedVal ¶
func CheckBalanceIsDoneCorrectlySCSideAndReturnExpectedVal( t *testing.T, nodes []*TestProcessorNode, idxNodeScExists int, topUpVal *big.Int, withdraw *big.Int, scAddressBytes []byte, ) *big.Int
CheckBalanceIsDoneCorrectlySCSideAndReturnExpectedVal verifies is smart contract balance is correct according to top-up and withdraw and returns the expected value
func CheckJoinGame ¶
func CheckJoinGame( t *testing.T, nodes []*TestProcessorNode, players []*TestWalletAccount, topUpValue *big.Int, idxProposer int, hardCodedScResultingAddress []byte, )
CheckJoinGame verifies if joinGame was done correctly by players
func CheckPlayerBalanceTheSameWithBlockchain ¶
func CheckPlayerBalanceTheSameWithBlockchain( t *testing.T, nodes []*TestProcessorNode, player *TestWalletAccount, )
CheckPlayerBalanceTheSameWithBlockchain verifies if player balance is the same as in the blockchain
func CheckRewardsDistribution ¶
func CheckRewardsDistribution( t *testing.T, nodes []*TestProcessorNode, players []*TestWalletAccount, topUpValue *big.Int, withdrawValue *big.Int, hardCodedScResultingAddress []byte, idxProposer int, )
CheckRewardsDistribution checks that players and smart contract balances are correct
func CheckRootHashes ¶
func CheckRootHashes(t *testing.T, nodes []*TestProcessorNode, idxProposers []int)
CheckRootHashes checks the root hash of the proposer in every shard
func CheckScBalanceOf ¶
func CheckScBalanceOf( t *testing.T, nodeWithSc *TestProcessorNode, nodeWithCaller *TestProcessorNode, expectedSC *big.Int, scAddressBytes []byte, )
CheckScBalanceOf checks the balance of a SC
func CheckScTopUp ¶
func CheckScTopUp( t *testing.T, nodeWithSc *TestProcessorNode, topUpVal *big.Int, scAddressBytes []byte, )
CheckScTopUp checks if sc received the top-up value
func CheckSenderBalanceOkAfterTopUp ¶
func CheckSenderBalanceOkAfterTopUp( t *testing.T, nodeWithCaller *TestProcessorNode, initialVal *big.Int, topUpVal *big.Int, )
CheckSenderBalanceOkAfterTopUp checks if sender balance is ok after top-up
func CheckSenderBalanceOkAfterTopUpAndWithdraw ¶
func CheckSenderBalanceOkAfterTopUpAndWithdraw( t *testing.T, nodeWithCaller *TestProcessorNode, initialVal *big.Int, topUpVal *big.Int, withdraw *big.Int, )
CheckSenderBalanceOkAfterTopUpAndWithdraw checks if sender balance is ok after top-up and withdraw
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 ¶
ClosePeers calls Messenger.Close on the provided peers
func CloseProcessorNodes ¶
func CloseProcessorNodes(nodes []*TestProcessorNode, advertiser p2p.Messenger)
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 CreateAccount ¶
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 data.StorageManager, ) (*state.AccountsDB, data.Trie)
CreateAccountsDB creates an account state with a valid trie implementation but with a memory storage
func CreateAndSendTransaction ¶
func CreateAndSendTransaction( node *TestProcessorNode, txValue *big.Int, rcvAddress []byte, txData string, )
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
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 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 CreateEconomicsData ¶
func CreateEconomicsData() *economics.EconomicsData
CreateEconomicsData creates a mock EconomicsData object
func CreateFixedNetworkOf14Peers ¶
CreateFixedNetworkOf14Peers assembles a network as following:
0 | 1 | +--+--+--+--+--2--+--+--+--+--+ | | | | | | | | | | | 3 4 5 6 7 8 9 10 11 12 13
func CreateFixedNetworkOf8Peers ¶
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]data.StorageManager, nodesSetup sharding.GenesisNodesSetupHandler, shardCoordinator sharding.Coordinator, store dataRetriever.StorageService, blkc data.ChainHandler, dataPool dataRetriever.PoolsHolder, economics *economics.EconomicsData, accountsParser genesis.AccountsParser, smartContractParser genesis.InitialSmartContractParser, ) 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]data.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 *economics.EconomicsData, ) 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]data.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 *economics.EconomicsData, ) data.HeaderHandler
CreateGenesisMetaBlock creates a new mock meta genesis block
func CreateMemUnit ¶
CreateMemUnit returns an in-memory storer implementation (the vast majority of tests do not require effective disk I/O)
func CreateMessengerFromConfig ¶
CreateMessengerFromConfig creates a new libp2p messenger with provided configuration
func CreateMessengerWithKadDht ¶
CreateMessengerWithKadDht creates a new libp2p messenger with kad-dht peer discovery
func CreateMessengerWithKadDhtAndProtocolID ¶
CreateMessengerWithKadDhtAndProtocolID creates a new libp2p messenger with kad-dht peer discovery and peer ID
func CreateMessengerWithNoDiscovery ¶
CreateMessengerWithNoDiscovery 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 ¶
CreateNewDefaultTrie returns a new trie with test hasher and marsahalizer
func CreateNodesWithNodesCoordinator ¶
func CreateNodesWithNodesCoordinator( nodesPerShard int, nbMetaNodes int, nbShards int, shardConsensusGroupSize int, metaConsensusGroupSize int, seedAddress string, ) 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, seedAddress string, 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, seedAddress string, ) map[uint32][]*TestProcessorNode
CreateNodesWithNodesCoordinatorAndTxKeys -
func CreateNodesWithNodesCoordinatorFactory ¶
func CreateNodesWithNodesCoordinatorFactory( nodesPerShard int, nbMetaNodes int, nbShards int, shardConsensusGroupSize int, metaConsensusGroupSize int, seedAddress string, 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, seedAddress string, 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, seedAddress string, ) map[uint32][]*TestProcessorNode
CreateNodesWithNodesCoordinatorWithCacher returns a map with nodes per shard each using a real nodes coordinator with cacher
func CreateNodesWithTestP2PNodes ¶
func CreateNodesWithTestP2PNodes( nodesPerShard int, numMetaNodes int, numShards int, shardConsensusGroupSize int, metaConsensusGroupSize int, numObserversOnShard int, p2pConfig config.P2PConfig, ) map[uint32][]*TestP2PNode
CreateNodesWithTestP2PNodes returns a map with nodes per shard each using a real nodes coordinator and TestP2PNodes
func CreatePkBytes ¶
CreatePkBytes creates 'numShards' public key-like byte slices
func CreateProcessorNodesWithNodesCoordinator ¶
func CreateProcessorNodesWithNodesCoordinator( rewardsAddrsAssignments map[uint32][]uint32, shardConsensusGroupSize int, metaConsensusGroupSize int, seedAddress string, ) (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 ¶
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 ¶
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 ¶
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() (data.StorageManager, storage.Storer)
CreateTrieStorageManager 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][]sharding.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][]sharding.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 GenerateRandomSlice ¶
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 GetConnectableAddress ¶
GetConnectableAddress returns a non circuit, non windows default connectable address for provided messenger
func GetMiniBlocksHashesFromShardIds ¶
GetMiniBlocksHashesFromShardIds returns miniblock hashes from body
func IncrementAndPrintRound ¶
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 ¶
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 MakeDisplayTableForP2PNodes ¶
func MakeDisplayTableForP2PNodes(nodes map[uint32][]*TestP2PNode) string
MakeDisplayTableForP2PNodes will output 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 exists), 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 NewOneNodeNetwork ¶ added in v0.0.2
func NewOneNodeNetwork() *oneNodeNetwork
NewOneNodeNetwork creates a one-node network, useful for some integration tests
func NodeCallsRewardAndSend ¶
func NodeCallsRewardAndSend( nodes []*TestProcessorNode, idxNodeOwner int, winnerPlayer *TestWalletAccount, prize *big.Int, round int32, scAddress []byte, )
NodeCallsRewardAndSend - smart contract owner sends reward transaction
func NodeDoesTopUp ¶
func NodeDoesTopUp( nodes []*TestProcessorNode, idxNode int, topUpValue *big.Int, scAddress []byte, )
NodeDoesTopUp creates and sends a
func NodeDoesWithdraw ¶
func NodeDoesWithdraw( nodes []*TestProcessorNode, idxNode int, withdrawValue *big.Int, scAddress []byte, )
NodeDoesWithdraw creates and sends a withdraw tx to the SC
func PlayerJoinsGame ¶
func PlayerJoinsGame( nodes []*TestProcessorNode, player *TestWalletAccount, joinGameVal *big.Int, round int32, scAddress []byte, )
PlayerJoinsGame creates and sends a join game transaction to the SC
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 PrintShardAccount ¶
func PrintShardAccount(accnt state.UserAccountHandler, tag string)
PrintShardAccount outputs on console a shard account data contained
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 PubKeysMapFromKeysMap ¶
func PubKeysMapFromKeysMap(keyPairMap map[uint32][]*TestKeyPair) map[uint32][]string
PubKeysMapFromKeysMap 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 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 StartP2PBootstrapOnProcessorNodes ¶
func StartP2PBootstrapOnProcessorNodes(nodes []*TestProcessorNode)
StartP2PBootstrapOnProcessorNodes will start the p2p discovery on processor nodes and wait a predefined time
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 ¶
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 WaitForBootstrapAndShowConnected ¶
func WaitForBootstrapAndShowConnected(peers []p2p.Messenger, durationBootstrapingTime time.Duration)
WaitForBootstrapAndShowConnected will delay a given duration in order to wait for bootstraping and print the number of peers that each node is connected to
func WaitOperationToBeDone ¶
func WaitOperationToBeDone(t *testing.T, nodes []*TestProcessorNode, nrOfRounds int, nonce, round uint64, idxProposers []int) (uint64, uint64)
WaitOperationToBeDone -
func WhiteListTxs ¶
func WhiteListTxs(nodes []*TestProcessorNode, txs []*transaction.Transaction)
WhiteListTxs -
Types ¶
type ArgIndexHashedNodesCoordinatorFactory ¶
type ArgIndexHashedNodesCoordinatorFactory struct {
// contains filtered or unexported fields
}
ArgIndexHashedNodesCoordinatorFactory -
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) 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 Keys map[uint32][]*TestKeyPair SingleSigner crypto.SingleSigner TxKeyGen crypto.KeyGenerator TxKeys map[uint32][]*TestKeyPair }
CryptoParams holds crypto parametres
func CreateCryptoParams ¶
func CreateCryptoParams(nodesPerShard int, nbMetaNodes int, nbShards uint32) *CryptoParams
CreateCryptoParams generates the crypto parameters (key pairs, key generator and suite) for multiple nodes
type IndexHashedNodesCoordinatorFactory ¶
type IndexHashedNodesCoordinatorFactory struct { }
IndexHashedNodesCoordinatorFactory -
func (*IndexHashedNodesCoordinatorFactory) CreateNodesCoordinator ¶
func (tpn *IndexHashedNodesCoordinatorFactory) CreateNodesCoordinator(arg ArgIndexHashedNodesCoordinatorFactory) sharding.NodesCoordinator
CreateNodesCoordinator -
type IndexHashedNodesCoordinatorWithRaterFactory ¶
type IndexHashedNodesCoordinatorWithRaterFactory struct {
sharding.PeerAccountListAndRatingHandler
}
IndexHashedNodesCoordinatorWithRaterFactory -
func (*IndexHashedNodesCoordinatorWithRaterFactory) CreateNodesCoordinator ¶
func (ihncrf *IndexHashedNodesCoordinatorWithRaterFactory) CreateNodesCoordinator( arg ArgIndexHashedNodesCoordinatorFactory, ) sharding.NodesCoordinator
CreateNodesCoordinator is used for creating a nodes coordinator in the integration tests based on the provided parameters
type NetworkShardingUpdater ¶
type NetworkShardingUpdater interface { GetPeerInfo(pid core.PeerID) core.P2PPeerInfo UpdatePeerIdPublicKey(pid core.PeerID, pk []byte) UpdatePublicKeyShardId(pk []byte, shardId uint32) UpdatePeerIdShardId(pid core.PeerID, shardId uint32) IsInterfaceNil() bool }
NetworkShardingUpdater defines the updating methods used by the network sharding component
type NodesCoordinatorFactory ¶
type NodesCoordinatorFactory interface {
CreateNodesCoordinator(arg ArgIndexHashedNodesCoordinatorFactory) sharding.NodesCoordinator
}
NodesCoordinatorFactory is used for creating a nodesCoordinator in the integration tests
type NodesWithRater ¶
type NodesWithRater struct { sharding.NodesCoordinator // contains filtered or unexported fields }
NodesWithRater -
func (*NodesWithRater) IsInterfaceNil ¶
func (nwr *NodesWithRater) IsInterfaceNil() bool
IsInterfaceNil -
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 TestEpochStartTrigger ¶
type TestEpochStartTrigger interface { epochStart.TriggerHandler GetRoundsPerEpoch() uint64 SetTrigger(triggerHandler epochStart.TriggerHandler) SetRoundsPerEpoch(roundsPerEpoch 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 TestKeyPair ¶
type TestKeyPair struct { Sk crypto.PrivateKey Pk crypto.PublicKey }
TestKeyPair holds a pair of private/public Keys
type TestP2PNode ¶
type TestP2PNode struct { Messenger p2p.Messenger NodesCoordinator sharding.NodesCoordinator ShardCoordinator sharding.Coordinator NetworkShardingUpdater NetworkShardingUpdater Node *node.Node NodeKeys TestKeyPair SingleSigner crypto.SingleSigner KeyGen crypto.KeyGenerator Storage dataRetriever.StorageService Interceptor *CountInterceptor }
TestP2PNode represents a container type of class used in integration tests with all its fields exported, used mainly on P2P tests
func NewTestP2PNode ¶
func NewTestP2PNode( maxShards uint32, nodeShardId uint32, p2pConfig config.P2PConfig, coordinator sharding.NodesCoordinator, keys TestKeyPair, ) *TestP2PNode
NewTestP2PNode returns a new NewTestP2PNode instance
func (*TestP2PNode) CountCrossShardMessages ¶
func (tP2pNode *TestP2PNode) CountCrossShardMessages() int
CountCrossShardMessages returns the messages count on the cross-shard topics
func (*TestP2PNode) CountGlobalMessages ¶
func (tP2pNode *TestP2PNode) CountGlobalMessages() int
CountGlobalMessages returns the messages count on the global topic
func (*TestP2PNode) CountIntraShardMessages ¶
func (tP2pNode *TestP2PNode) CountIntraShardMessages() int
CountIntraShardMessages returns the messages count on the intra-shard topic
func (*TestP2PNode) CreateTestInterceptors ¶
func (tP2pNode *TestP2PNode) CreateTestInterceptors()
CreateTestInterceptors creates test interceptors that count the number of received messages
func (*TestP2PNode) RegisterTopicValidator ¶
func (tP2pNode *TestP2PNode) RegisterTopicValidator(topic string, processor p2p.MessageProcessor)
RegisterTopicValidator registers a message processor instance on the provided topic
type TestProcessorNode ¶
type TestProcessorNode struct { ShardCoordinator sharding.Coordinator NodesCoordinator sharding.NodesCoordinator NodesSetup sharding.GenesisNodesSetupHandler Messenger p2p.Messenger OwnAccount *TestWalletAccount NodeKeys *TestKeyPair ExportFolder string DataPool dataRetriever.PoolsHolder Storage dataRetriever.StorageService PeerState state.AccountsAdapter AccntState state.AccountsAdapter TrieStorageManagers map[string]data.StorageManager TrieContainer state.TriesHolder BlockChain data.ChainHandler GenesisBlocks map[uint32]data.HeaderHandler EconomicsData *economics.TestEconomicsData RatingsData *rating.RatingsData BlockBlackListHandler process.TimeCacher HeaderValidator process.HeaderConstructionValidator BlockTracker process.BlockTracker InterceptorsContainer process.InterceptorsContainer ResolversContainer dataRetriever.ResolversContainer ResolverFinder dataRetriever.ResolversFinder RequestHandler process.RequestHandler InterimProcContainer process.IntermediateProcessorContainer TxProcessor process.TransactionProcessor TxCoordinator process.TransactionCoordinator ScrForwarder process.IntermediateTransactionHandler BlockchainHook *hooks.BlockChainHookImpl VMContainer process.VirtualMachinesContainer ArgsParser process.ArgumentsParser ScProcessor process.SmartContractProcessor RewardsProcessor process.RewardTransactionProcessor PreProcessorsContainer process.PreProcessorsContainer GasHandler process.GasHandler FeeAccumulator process.TransactionFeeHandler SmartContractParser genesis.InitialSmartContractParser ForkDetector process.ForkDetector BlockProcessor process.BlockProcessor BroadcastMessenger consensus.BroadcastMessenger MiniblocksProvider process.MiniBlockProvider Bootstrapper TestBootstrapper Rounder *mock.RounderMock BootstrapStorer *mock.BoostrapStorerMock StorageBootstrapper *mock.StorageBootstrapperMock RequestedItemsHandler dataRetriever.RequestedItemsHandler WhiteListHandler process.WhiteListHandler WhiteListerVerifiedTxs process.WhiteListHandler NetworkShardingCollector consensus.NetworkShardingCollector EpochStartTrigger TestEpochStartTrigger EpochStartNotifier notifier.EpochStartNotifier MultiSigner crypto.MultiSigner HeaderSigVerifier process.InterceptedHeaderSigVerifier HeaderIntegrityVerifier process.InterceptedHeaderIntegrityVerifier ValidatorStatisticsProcessor process.ValidatorStatisticsProcessor Rater sharding.PeerAccountListAndRatingHandler //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 fullHistory.HistoryRepository }
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][]sharding.Validator, waitingMap map[uint32][]sharding.Validator, keyIndex int, seedAddress string, cp *CryptoParams, cache sharding.Cacher, coordinatorFactory NodesCoordinatorFactory, nodesSetup sharding.GenesisNodesSetupHandler, ratingsData *rating.RatingsData, ) *TestProcessorNode
CreateNode -
func CreateNodeWithBLSAndTxKeys ¶
func CreateNodeWithBLSAndTxKeys( nodesPerShard int, nbMetaNodes int, shardConsensusGroupSize int, metaConsensusGroupSize int, shardId uint32, nbShards int, validatorsMap map[uint32][]sharding.Validator, waitingMap map[uint32][]sharding.Validator, keyIndex int, seedAddress string, cp *CryptoParams, cache sharding.Cacher, coordinatorFactory NodesCoordinatorFactory, nodesSetup sharding.GenesisNodesSetupHandler, ratingsData *rating.RatingsData, ) *TestProcessorNode
CreateNodeWithBLSAndTxKeys -
func CreateNodes ¶
func CreateNodes( numOfShards int, nodesPerShard int, numMetaChainNodes int, serviceID string, ) []*TestProcessorNode
CreateNodes creates multiple nodes in different shards
func CreateNodesWithCustomStateCheckpointModulus ¶
func CreateNodesWithCustomStateCheckpointModulus( numOfShards int, nodesPerShard int, numMetaChainNodes int, serviceID string, stateCheckpointModulus uint, ) []*TestProcessorNode
CreateNodesWithCustomStateCheckpointModulus creates multiple nodes in different shards with custom stateCheckpointModulus
func CreateNodesWithFullGenesis ¶
func CreateNodesWithFullGenesis( numOfShards int, nodesPerShard int, numMetaChainNodes int, serviceID string, genesisFile string, ) []*TestProcessorNode
CreateNodesWithFullGenesis creates multiple nodes in different shards
func NewTestProcessorNode ¶
func NewTestProcessorNode( maxShards uint32, nodeShardId uint32, txSignPrivKeyShardId uint32, initialNodeAddr string, ) *TestProcessorNode
NewTestProcessorNode returns a new TestProcessorNode instance with a libp2p messenger
func NewTestProcessorNodeWithCustomDataPool ¶
func NewTestProcessorNodeWithCustomDataPool(maxShards uint32, nodeShardId uint32, txSignPrivKeyShardId uint32, initialNodeAddr string, dPool dataRetriever.PoolsHolder) *TestProcessorNode
NewTestProcessorNodeWithCustomDataPool returns a new TestProcessorNode instance with the given data pool
func NewTestProcessorNodeWithCustomNodesCoordinator ¶
func NewTestProcessorNodeWithCustomNodesCoordinator( maxShards uint32, nodeShardId uint32, initialNodeAddr string, epochStartNotifier notifier.EpochStartNotifier, nodesCoordinator sharding.NodesCoordinator, ratingsData *rating.RatingsData, cp *CryptoParams, keyIndex int, ownAccount *TestWalletAccount, headerSigVerifier process.InterceptedHeaderSigVerifier, headerIntegrityVerifier process.InterceptedHeaderIntegrityVerifier, nodeSetup sharding.GenesisNodesSetupHandler, ) *TestProcessorNode
NewTestProcessorNodeWithCustomNodesCoordinator returns a new TestProcessorNode instance with custom NodesCoordinator
func NewTestProcessorNodeWithFullGenesis ¶
func NewTestProcessorNodeWithFullGenesis( maxShards uint32, nodeShardId uint32, txSignPrivKeyShardId uint32, initialNodeAddr string, accountParser genesis.AccountsParser, smartContractParser genesis.InitialSmartContractParser, ) *TestProcessorNode
NewTestProcessorNodeWithFullGenesis returns a new TestProcessorNode instance with a libp2p messenger and a full genesis deploy
func NewTestProcessorNodeWithStateCheckpointModulus ¶
func NewTestProcessorNodeWithStateCheckpointModulus( maxShards uint32, nodeShardId uint32, txSignPrivKeyShardId uint32, initialNodeAddr string, stateCheckpointModulus uint, ) *TestProcessorNode
NewTestProcessorNodeWithStateCheckpointModulus creates a new testNodeProcessor with custom state checkpoint modulus
func NewTestSyncNode ¶
func NewTestSyncNode( maxShards uint32, nodeShardId uint32, txSignPrivKeyShardId uint32, initialNodeAddr string, ) *TestProcessorNode
NewTestSyncNode returns a new TestProcessorNode instance with sync capabilities
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, p2p.Messenger, []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)
BroadcastBlock broadcasts the block and body to the connected peers
func (*TestProcessorNode) CommitBlock ¶
func (tpn *TestProcessorNode) CommitBlock(body data.BodyHandler, header data.HeaderHandler)
CommitBlock commits the block and body
func (*TestProcessorNode) GetBlockBody ¶
GetBlockBody returns the body for provided header parameter
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) (*dataBlock.Header, error)
GetShardHeader returns the first *dataBlock.Header stored in datapools having the nonce provided as parameter
func (*TestProcessorNode) InitializeProcessors ¶ added in v0.0.2
func (tpn *TestProcessorNode) InitializeProcessors()
InitializeProcessors will reinitialize processors
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 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 an 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
Source Files ¶
- countInterceptor.go
- interface.go
- nodesCoordinatorFactory.go
- oneNodeNetwork.go
- testGameHelperFunctions.go
- testInitializer.go
- testP2PNode.go
- testProcessorNode.go
- testProcessorNodeWithCoordinator.go
- testProcessorNodeWithMultisigner.go
- testProcessorNodeWithStateCheckpointModulus.go
- testStorage.go
- testSyncNode.go
- testWalletAccount.go