Skip to content

Commit

Permalink
Merge pull request #5964 from multiversx/chain_simulator_processor_tests
Browse files Browse the repository at this point in the history
Chain simulator processor tests
  • Loading branch information
sstanculeanu authored Feb 16, 2024
2 parents a4206f6 + 3ede23c commit c1ba821
Show file tree
Hide file tree
Showing 8 changed files with 848 additions and 30 deletions.
2 changes: 1 addition & 1 deletion integrationTests/testProcessorNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -3493,7 +3493,7 @@ func getDefaultNodesSetup(maxShards, numNodes uint32, address []byte, pksBytes m

func getDefaultNodesCoordinator(maxShards uint32, pksBytes map[uint32][]byte) nodesCoordinator.NodesCoordinator {
return &shardingMocks.NodesCoordinatorStub{
ComputeValidatorsGroupCalled: func(randomness []byte, round uint64, shardId uint32, epoch uint32) (validators []nodesCoordinator.Validator, err error) {
ComputeConsensusGroupCalled: func(randomness []byte, round uint64, shardId uint32, epoch uint32) (validators []nodesCoordinator.Validator, err error) {
v, _ := nodesCoordinator.NewValidator(pksBytes[shardId], 1, defaultChancesSelection)
return []nodesCoordinator.Validator{v}, nil
},
Expand Down
6 changes: 6 additions & 0 deletions node/chainSimulator/process/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package process

import "errors"

// ErrNilNodeHandler signals that a nil node handler has been provided
var ErrNilNodeHandler = errors.New("nil node handler")
7 changes: 6 additions & 1 deletion node/chainSimulator/process/processor.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package process

import (
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/data"
"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/consensus/spos"
Expand All @@ -20,6 +21,10 @@ type blocksCreator struct {

// NewBlocksCreator will create a new instance of blocksCreator
func NewBlocksCreator(nodeHandler NodeHandler) (*blocksCreator, error) {
if check.IfNil(nodeHandler) {
return nil, ErrNilNodeHandler
}

return &blocksCreator{
nodeHandler: nodeHandler,
}, nil
Expand Down Expand Up @@ -70,7 +75,7 @@ func (creator *blocksCreator) CreateNewBlock() error {
return err
}

headerCreationTime := creator.nodeHandler.GetProcessComponents().RoundHandler().TimeStamp()
headerCreationTime := creator.nodeHandler.GetCoreComponents().RoundHandler().TimeStamp()
err = newHeader.SetTimeStamp(uint64(headerCreationTime.Unix()))
if err != nil {
return err
Expand Down
Loading

0 comments on commit c1ba821

Please sign in to comment.