Skip to content

Commit

Permalink
integration tests meta chain fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ssd04 committed Jan 28, 2025
1 parent 976b413 commit 0e9adb9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
14 changes: 7 additions & 7 deletions integrationTests/consensus/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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...")

Expand Down Expand Up @@ -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)
}
}
}
Expand Down
36 changes: 35 additions & 1 deletion integrationTests/testFullNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -110,6 +111,7 @@ func CreateNodesWithTestFullNode(
EpochsConfig: &enableEpochsConfig,
NodeKeys: keysPair,
},
ShardID: shardID,
ConsensusSize: consensusSize,
RoundTime: roundTime,
ConsensusType: consensusType,
Expand Down Expand Up @@ -137,6 +139,7 @@ func CreateNodesWithTestFullNode(
type ArgsTestFullNode struct {
*ArgTestProcessorNode

ShardID uint32
ConsensusSize int
RoundTime uint64
ConsensusType string
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 0e9adb9

Please sign in to comment.