diff --git a/integrationTests/consensus/consensus_test.go b/integrationTests/consensus/consensus_test.go index 1d18f7d191..96fb5ae36a 100644 --- a/integrationTests/consensus/consensus_test.go +++ b/integrationTests/consensus/consensus_test.go @@ -210,9 +210,9 @@ func TestConsensusBLSWithFullProcessing(t *testing.T) { logger.ToggleLoggerName(true) numKeysOnEachNode := 1 - numMetaNodes := uint32(4) - numNodes := uint32(4) - consensusSize := uint32(4 * numKeysOnEachNode) + numMetaNodes := uint32(2) + numNodes := uint32(2) + consensusSize := uint32(2 * numKeysOnEachNode) roundTime := uint64(1000) // maxShards := uint32(1) @@ -227,10 +227,10 @@ func TestConsensusBLSWithFullProcessing(t *testing.T) { enableEpochsConfig := integrationTests.CreateEnableEpochsConfig() - equivalentProodsActivationEpoch := uint32(10) + equivalentProofsActivationEpoch := uint32(0) - enableEpochsConfig.EquivalentMessagesEnableEpoch = equivalentProodsActivationEpoch - enableEpochsConfig.FixedOrderInConsensusEnableEpoch = equivalentProodsActivationEpoch + enableEpochsConfig.EquivalentMessagesEnableEpoch = equivalentProofsActivationEpoch + enableEpochsConfig.FixedOrderInConsensusEnableEpoch = equivalentProofsActivationEpoch fmt.Println("Step 1. Setup nodes...") @@ -332,7 +332,7 @@ func TestConsensusBLSWithFullProcessing(t *testing.T) { assert.Fail(t, fmt.Sprintf("Node with idx %d does not have a current block", i)) } else { fmt.Println("FOUND") - assert.Equal(t, expectedNonce, n.Node.GetDataComponents().Blockchain().GetCurrentBlockHeader().GetNonce()) + assert.GreaterOrEqual(t, n.Node.GetDataComponents().Blockchain().GetCurrentBlockHeader().GetNonce(), expectedNonce) } } } diff --git a/integrationTests/testFullNode.go b/integrationTests/testFullNode.go index 9638459af8..0ca2d58a60 100644 --- a/integrationTests/testFullNode.go +++ b/integrationTests/testFullNode.go @@ -48,6 +48,7 @@ import ( "github.com/multiversx/mx-chain-go/process/smartContract" processSync "github.com/multiversx/mx-chain-go/process/sync" "github.com/multiversx/mx-chain-go/process/track" + "github.com/multiversx/mx-chain-go/sharding" chainShardingMocks "github.com/multiversx/mx-chain-go/sharding/mock" "github.com/multiversx/mx-chain-go/sharding/nodesCoordinator" "github.com/multiversx/mx-chain-go/state" @@ -110,6 +111,7 @@ func CreateNodesWithTestFullNode( EpochsConfig: &enableEpochsConfig, NodeKeys: keysPair, }, + ShardID: shardID, ConsensusSize: consensusSize, RoundTime: roundTime, ConsensusType: consensusType, @@ -137,6 +139,7 @@ func CreateNodesWithTestFullNode( type ArgsTestFullNode struct { *ArgTestProcessorNode + ShardID uint32 ConsensusSize int RoundTime uint64 ConsensusType string @@ -150,13 +153,18 @@ type ArgsTestFullNode struct { type TestFullNode struct { *TestProcessorNode + + ShardCoordinator sharding.Coordinator } func NewTestFullNode(args ArgsTestFullNode) *TestFullNode { tpn := newBaseTestProcessorNode(*args.ArgTestProcessorNode) + shardCoordinator, _ := sharding.NewMultiShardCoordinator(maxShards, args.ShardID) + tfn := &TestFullNode{ TestProcessorNode: tpn, + ShardCoordinator: shardCoordinator, } tfn.initTestNodeWithArgs(*args.ArgTestProcessorNode, args) @@ -345,6 +353,25 @@ func (tpn *TestFullNode) initTestNodeWithArgs(args ArgTestProcessorNode, fullArg } } +func (tpn *TestFullNode) setGenesisBlock() { + genesisBlock := tpn.GenesisBlocks[tpn.ShardCoordinator.SelfId()] + _ = tpn.BlockChain.SetGenesisHeader(genesisBlock) + hash, _ := core.CalculateHash(TestMarshalizer, TestHasher, genesisBlock) + tpn.BlockChain.SetGenesisHeaderHash(hash) + log.Info("set genesis", + "shard ID", tpn.ShardCoordinator.SelfId(), + "hash", hex.EncodeToString(hash), + ) +} + +func (tpn *TestFullNode) initChainHandler() { + if tpn.ShardCoordinator.SelfId() == core.MetachainShardId { + tpn.BlockChain = CreateMetaChain() + } else { + tpn.BlockChain = CreateShardChain() + } +} + func (tpn *TestFullNode) initNode( args ArgsTestFullNode, syncer ntp.SyncTimer, @@ -957,6 +984,10 @@ func (tpn *TestFullNode) initBlockProcessor( log.Error("initBlockProcessor tpn.VMContainer.Get", "error", errGet) } + if systemVM == nil { + systemVM, _ = mock.NewOneSCExecutorMockVM(tpn.BlockchainHook, TestHasher) + } + argsStakingDataProvider := metachain.StakingDataProviderArgs{ EnableEpochsHandler: coreComponents.EnableEpochsHandler(), SystemVM: systemVM, @@ -988,7 +1019,10 @@ func (tpn *TestFullNode) initBlockProcessor( RewardsHandler: tpn.EconomicsData, EconomicsDataProvider: economicsDataProvider, } - epochStartRewards, _ := metachain.NewRewardsCreatorProxy(argsEpochRewards) + epochStartRewards, err := metachain.NewRewardsCreatorProxy(argsEpochRewards) + if err != nil { + panic(fmt.Sprintf("error creating rewards creator proxy: %s", err.Error())) + } validatorInfoStorage, _ := tpn.Storage.GetStorer(dataRetriever.UnsignedTransactionUnit) argsEpochValidatorInfo := metachain.ArgsNewValidatorInfoCreator{