integrationTests

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: GPL-3.0 Imports: 62 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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 CreateAccountsDB

func CreateAccountsDB(shardCoordinator sharding.Coordinator) *state.AccountsDB

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

func CreateAddresFromAddrBytes added in v1.0.11

func CreateAddresFromAddrBytes(addressBytes []byte) state.AddressContainer

CreateAddresFromAddrBytes creates a n address container object from address bytes provided

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 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 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() dataRetriever.PoolsHolder

CreateTestShardDataPool creates a test data pool for shard nodes

func GetConnectableAddress

func GetConnectableAddress(mes p2p.Messenger) string

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

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), updated the balance with required value, saves 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 PrintShardAccount

func PrintShardAccount(accnt *state.Account)

PrintShardAccount outputs on console a shard account data contained

Types

type TestProcessorNode

type TestProcessorNode struct {
	ShardCoordinator sharding.Coordinator
	Messenger        p2p.Messenger

	SingleSigner  crypto.SingleSigner
	SkTxSign      crypto.PrivateKey
	PkTxSign      crypto.PublicKey
	PkTxSignBytes []byte
	KeygenTxSign  crypto.KeyGenerator
	TxSignAddress state.AddressContainer

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

	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
	PreProcessorsContainer process.PreProcessorsContainer

	ForkDetector       process.ForkDetector
	BlockTracker       process.BlocksTracker
	BlockProcessor     process.BlockProcessor
	BroadcastMessenger consensus.BroadcastMessenger

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

func NewTestProcessorNode(maxShards uint32, nodeShardId uint32, txSignPrivKeyShardId uint32, initialNodeAddr string) *TestProcessorNode

NewTestProcessorNode returns a new TestProcessorNode instance

func (*TestProcessorNode) BroadcastAndCommit added in v1.0.11

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

BroadcastAndCommit broadcasts and 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) ProposeBlock

func (tpn *TestProcessorNode) ProposeBlock(round uint32) (data.BodyHandler, data.HeaderHandler)

ProposeBlock proposes a new block

func (*TestProcessorNode) SendTransaction

func (tpn *TestProcessorNode) SendTransaction(tx *dataTransaction.Transaction)

SendTransaction can send a transaction (it does the dispatching)

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

Directories

Path Synopsis
frontend
multiShard
p2p
singleShard

Jump to

Keyboard shortcuts

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