integrationTests

package
v1.0.28 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2019 License: GPL-3.0 Imports: 79 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MinTxGasLimit = uint64(4)

MinTxGasLimit minimum gas limit required by a transaction

View Source
var MinTxGasPrice = uint64(0)

MinTxGasPrice minimum gas price required by a transaction TODO refactor all tests to pass with a non zero value

View Source
var TestAddressConverter, _ = addressConverters.NewPlainAddressConverter(32, "0x")

TestAddressConverter represents a plain address converter

View Source
var TestHasher = sha256.Sha256{}

TestHasher represents a Sha256 hasher

View Source
var TestMarshalizer = &marshal.JsonMarshalizer{}

TestMarshalizer represents a JSON marshalizer

View Source
var TestMultiSig = mock.NewMultiSigner(1)

TestMultiSig represents a mock multisig

View Source
var TestUint64Converter = uint64ByteSlice.NewBigEndianConverter()

TestUint64Converter represents an uint64 to byte slice converter

Functions

func AdbEmulateBalanceTxExecution

func AdbEmulateBalanceTxExecution(acntSrc, acntDest *state.Account, 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.Account, accounts state.AccountsAdapter, value *big.Int)

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

func AllShardsProposeBlock

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

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

func CreateAccount(accnts state.AccountsAdapter, nonce uint64, balance *big.Int) state.AddressContainer

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 factory.Type) (*state.AccountsDB, data.Trie, storage.Storer)

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

func CreateAddressFromAddrBytes

func CreateAddressFromAddrBytes(addressBytes []byte) state.AddressContainer

CreateAddressFromAddrBytes creates an address container object from address bytes provided

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

func CreateGenesisBlock(shardId uint32) *dataBlock.Header

CreateGenesisBlock creates a new mock shard genesis block

func CreateGenesisBlocks

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

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

func CreateGenesisMetaBlock

func CreateGenesisMetaBlock() *dataBlock.MetaBlock

CreateGenesisMetaBlock creates a new mock meta genesis block

func CreateIeleVMAndBlockchainHook added in v1.0.11

func CreateIeleVMAndBlockchainHook(
	accnts state.AccountsAdapter,
) (vmcommon.VMExecutionHandler, *hooks.VMAccountsDB)

CreateIeleVMAndBlockchainHook creates a new instance of a iele VM

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 CreateMessengerWithKadDht

func CreateMessengerWithKadDht(ctx context.Context, initialAddr string) p2p.Messenger

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

func CreateMetaChain

func CreateMetaChain() data.ChainHandler

CreateMetaChain creates a blockchain implementation used by the meta nodes

func CreateMetaStore

func CreateMetaStore(coordinator sharding.Coordinator) dataRetriever.StorageService

CreateMetaStore creates a storage service for 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() data.Trie

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 CreateRandomAddress

func CreateRandomAddress() state.AddressContainer

CreateRandomAddress creates a random byte array with fixed size

func CreateRandomHexString

func CreateRandomHexString(chars int) string

CreateRandomHexString returns a string encoded in hex with the given size

func CreateRequesterDataPool

func CreateRequesterDataPool(t *testing.T, recvTxs map[int]map[string]struct{}, mutRecvTxs *sync.Mutex, nodeIndex int) 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 CreateShardChain

func CreateShardChain() *blockchain.BlockChain

CreateShardChain creates a blockchain implementation used by the shard nodes

func CreateShardStore

func CreateShardStore(numOfShards uint32) dataRetriever.StorageService

CreateShardStore creates a storage service for shard nodes

func CreateSimpleTxProcessor

func CreateSimpleTxProcessor(accnts state.AccountsAdapter) process.TransactionProcessor

CreateSimpleTxProcessor returns a transaction processor

func CreateTestMetaDataPool added in v1.0.11

func CreateTestMetaDataPool() dataRetriever.MetaPoolsHolder

CreateTestMetaDataPool creates a test data pool for meta nodes

func CreateTestShardDataPool added in v1.0.11

func CreateTestShardDataPool(txPool dataRetriever.ShardedDataCacherNotifier) dataRetriever.PoolsHolder

CreateTestShardDataPool creates a test data pool for shard nodes

func DeployScTx

func DeployScTx(nodes []*TestProcessorNode, senderIdx int, scCode 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 GenValidatorsFromPubKeys

func GenValidatorsFromPubKeys(pubKeysMap map[uint32][]string, nbShards uint32) map[uint32][]sharding.Validator

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

func GenerateAddressJournalAccountAccountsDB

func GenerateAddressJournalAccountAccountsDB() (state.AddressContainer, state.AccountHandler, *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,
)

GenerateAndDisseminateTxs generates and sends multiple txs

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 GetConnectableAddress

func GetConnectableAddress(mes p2p.Messenger) string

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

func GetMiniBlocksHashesFromShardIds

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

GetMiniBlocksHashesFromShardIds returns miniblock hashes from body

func GetNumTxsWithDst

func GetNumTxsWithDst(dstShardId uint32, dataPool dataRetriever.PoolsHolder, nrShards uint32) int

GetNumTxsWithDst returns the total number of transactions that have a certain destination shard

func IncrementAndPrintRound

func IncrementAndPrintRound(round uint64) uint64

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

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

func NodeCallsRewardAndSend(
	nodes []*TestProcessorNode,
	idxNodeOwner int,
	winnerPlayer *TestWalletAccount,
	prize *big.Int,
	round string,
	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 string,
	scAddress []byte,
)

PlayerJoinsGame creates and sends a join game transaction to the SC

func PrintShardAccount

func PrintShardAccount(accnt *state.Account, tag string)

PrintShardAccount outputs on console a shard account data contained

func ProposeAndSyncBlocks

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

ProposeAndSyncBlocks proposes and syncs blocks until all transaction pools are empty

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

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

SetEconomicsParameters will set minGasPrice and minGasLimits to provided nodes

func StartP2pBootstrapOnProcessorNodes added in v1.0.24

func StartP2pBootstrapOnProcessorNodes(nodes []*TestProcessorNode)

StartP2pBootstrapOnProcessorNodes will start the p2p discovery on processor nodes and wait a predefined time

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

func VerifyNodesHaveHeaders(
	t *testing.T,
	headers map[uint32]data.HeaderHandler,
	nodesMap map[uint32][]*TestProcessorNode,
)

VerifyNodesHaveHeaders verifies that each node has the corresponding header

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

Types

type CryptoParams

type CryptoParams struct {
	KeyGen       crypto.KeyGenerator
	Keys         map[uint32][]*TestKeyPair
	SingleSigner crypto.SingleSigner
}

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 TestBootstrapper

type TestBootstrapper interface {
	process.Bootstrapper
	ForkChoice(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 TestKeyPair

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

TestKeyPair holds a pair of private/public Keys

type TestProcessorNode

type TestProcessorNode struct {
	ShardCoordinator      sharding.Coordinator
	NodesCoordinator      sharding.NodesCoordinator
	SpecialAddressHandler process.SpecialAddressHandler
	Messenger             p2p.Messenger

	OwnAccount *TestWalletAccount
	NodeKeys   *TestKeyPair

	ShardDataPool dataRetriever.PoolsHolder
	MetaDataPool  dataRetriever.MetaPoolsHolder
	Storage       dataRetriever.StorageService
	AccntState    state.AccountsAdapter
	BlockChain    data.ChainHandler
	GenesisBlocks map[uint32]data.HeaderHandler

	EconomicsData *economics.TestEconomicsData

	InterceptorsContainer process.InterceptorsContainer
	ResolversContainer    dataRetriever.ResolversContainer
	ResolverFinder        dataRetriever.ResolversFinder
	RequestHandler        process.RequestHandler

	InterimProcContainer   process.IntermediateProcessorContainer
	TxProcessor            process.TransactionProcessor
	TxCoordinator          process.TransactionCoordinator
	ScrForwarder           process.IntermediateTransactionHandler
	VmProcessor            vmcommon.VMExecutionHandler
	VmDataGetter           vmcommon.VMExecutionHandler
	BlockchainHook         vmcommon.BlockchainHook
	ArgsParser             process.ArgumentsParser
	ScProcessor            process.SmartContractProcessor
	RewardsProcessor       process.RewardTransactionProcessor
	PreProcessorsContainer process.PreProcessorsContainer

	ForkDetector       process.ForkDetector
	BlockProcessor     process.BlockProcessor
	BroadcastMessenger consensus.BroadcastMessenger
	Bootstrapper       TestBootstrapper
	Rounder            *mock.RounderMock

	MultiSigner crypto.MultiSigner

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

	CounterHdrRecv int32
	CounterMbRecv  int32
	CounterTxRecv  int32
	CounterMetaRcv int32
}

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

func CreateNodes

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

CreateNodes 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

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,
	nodesCoordinator sharding.NodesCoordinator,
	cp *CryptoParams,
	keyIndex int,
) *TestProcessorNode

NewTestProcessorNodeWithCustomNodesCoordinator returns a new TestProcessorNode instance with custom NodesCoordinator

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,
) (data.BodyHandler, data.HeaderHandler, [][]byte, []*TestProcessorNode)

ProposeBlockWithConsensusSignature proposes

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

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

GetBlockBody 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) 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

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
	SkTxSign      crypto.PrivateKey
	PkTxSign      crypto.PublicKey
	PkTxSignBytes []byte
	KeygenTxSign  crypto.KeyGenerator

	Address state.AddressContainer
	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 wallett account in a selected shard

func (*TestWalletAccount) LoadTxSignSkBytes

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

LoadTxSignSkBytes alters the already generated sk/pk pair

Directories

Path Synopsis
multiShard
p2p

Jump to

Keyboard shortcuts

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