Skip to content

Commit

Permalink
use common function for full node start
Browse files Browse the repository at this point in the history
  • Loading branch information
ssd04 committed Jan 31, 2025
1 parent 92c1f0b commit a32849b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 92 deletions.
46 changes: 1 addition & 45 deletions integrationTests/consensus/consensusSigning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-go/config"
consensusComp "github.com/multiversx/mx-chain-go/factory/consensus"
"github.com/multiversx/mx-chain-go/integrationTests"
consensusMocks "github.com/multiversx/mx-chain-go/testscommon/consensus"
)

func initNodesWithTestSigner(
Expand Down Expand Up @@ -99,48 +96,7 @@ func TestConsensusWithInvalidSigners(t *testing.T) {

for _, nodesList := range nodes {
for _, n := range nodesList {
statusComponents := integrationTests.GetDefaultStatusComponents()

consensusArgs := consensusComp.ConsensusComponentsFactoryArgs{
Config: config.Config{
Consensus: config.ConsensusConfig{
Type: blsConsensusType,
},
ValidatorPubkeyConverter: config.PubkeyConfig{
Length: 96,
Type: "bls",
SignatureLength: 48,
},
TrieSync: config.TrieSyncConfig{
NumConcurrentTrieSyncers: 5,
MaxHardCapForMissingNodes: 5,
TrieSyncerVersion: 2,
CheckNodesOnDisk: false,
},
GeneralSettings: config.GeneralSettingsConfig{
SyncProcessTimeInMillis: 6000,
},
},
BootstrapRoundIndex: 0,
CoreComponents: n.Node.GetCoreComponents(),
NetworkComponents: n.Node.GetNetworkComponents(),
CryptoComponents: n.Node.GetCryptoComponents(),
DataComponents: n.Node.GetDataComponents(),
ProcessComponents: n.Node.GetProcessComponents(),
StateComponents: n.Node.GetStateComponents(),
StatusComponents: statusComponents,
StatusCoreComponents: n.Node.GetStatusCoreComponents(),
ScheduledProcessor: &consensusMocks.ScheduledProcessorStub{},
IsInImportMode: n.Node.IsInImportMode(),
}

consensusFactory, err := consensusComp.NewConsensusComponentsFactory(consensusArgs)
require.Nil(t, err)

managedConsensusComponents, err := consensusComp.NewManagedConsensusComponents(consensusFactory)
require.Nil(t, err)

err = managedConsensusComponents.Create()
err := startFullConsensusNode(n)
require.Nil(t, err)
}
}
Expand Down
94 changes: 52 additions & 42 deletions integrationTests/consensus/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,48 +140,7 @@ func testConsensusBLSWithFullProcessing(t *testing.T, equivalentProofsActivation

for _, nodesList := range nodes {
for _, n := range nodesList {
statusComponents := integrationTests.GetDefaultStatusComponents()

consensusArgs := consensusComp.ConsensusComponentsFactoryArgs{
Config: config.Config{
Consensus: config.ConsensusConfig{
Type: blsConsensusType,
},
ValidatorPubkeyConverter: config.PubkeyConfig{
Length: 96,
Type: "bls",
SignatureLength: 48,
},
TrieSync: config.TrieSyncConfig{
NumConcurrentTrieSyncers: 5,
MaxHardCapForMissingNodes: 5,
TrieSyncerVersion: 2,
CheckNodesOnDisk: false,
},
GeneralSettings: config.GeneralSettingsConfig{
SyncProcessTimeInMillis: 6000,
},
},
BootstrapRoundIndex: 0,
CoreComponents: n.Node.GetCoreComponents(),
NetworkComponents: n.Node.GetNetworkComponents(),
CryptoComponents: n.Node.GetCryptoComponents(),
DataComponents: n.Node.GetDataComponents(),
ProcessComponents: n.Node.GetProcessComponents(),
StateComponents: n.Node.GetStateComponents(),
StatusComponents: statusComponents,
StatusCoreComponents: n.Node.GetStatusCoreComponents(),
ScheduledProcessor: &consensusMocks.ScheduledProcessorStub{},
IsInImportMode: n.Node.IsInImportMode(),
}

consensusFactory, err := consensusComp.NewConsensusComponentsFactory(consensusArgs)
require.Nil(t, err)

managedConsensusComponents, err := consensusComp.NewManagedConsensusComponents(consensusFactory)
require.Nil(t, err)

err = managedConsensusComponents.Create()
err := startFullConsensusNode(n)
require.Nil(t, err)
}
}
Expand All @@ -206,6 +165,57 @@ func testConsensusBLSWithFullProcessing(t *testing.T, equivalentProofsActivation
}
}

func startFullConsensusNode(
n *integrationTests.TestFullNode,
) error {
statusComponents := integrationTests.GetDefaultStatusComponents()

consensusArgs := consensusComp.ConsensusComponentsFactoryArgs{
Config: config.Config{
Consensus: config.ConsensusConfig{
Type: blsConsensusType,
},
ValidatorPubkeyConverter: config.PubkeyConfig{
Length: 96,
Type: "bls",
SignatureLength: 48,
},
TrieSync: config.TrieSyncConfig{
NumConcurrentTrieSyncers: 5,
MaxHardCapForMissingNodes: 5,
TrieSyncerVersion: 2,
CheckNodesOnDisk: false,
},
GeneralSettings: config.GeneralSettingsConfig{
SyncProcessTimeInMillis: 6000,
},
},
BootstrapRoundIndex: 0,
CoreComponents: n.Node.GetCoreComponents(),
NetworkComponents: n.Node.GetNetworkComponents(),
CryptoComponents: n.Node.GetCryptoComponents(),
DataComponents: n.Node.GetDataComponents(),
ProcessComponents: n.Node.GetProcessComponents(),
StateComponents: n.Node.GetStateComponents(),
StatusComponents: statusComponents,
StatusCoreComponents: n.Node.GetStatusCoreComponents(),
ScheduledProcessor: &consensusMocks.ScheduledProcessorStub{},
IsInImportMode: n.Node.IsInImportMode(),
}

consensusFactory, err := consensusComp.NewConsensusComponentsFactory(consensusArgs)
if err != nil {
return err
}

managedConsensusComponents, err := consensusComp.NewManagedConsensusComponents(consensusFactory)
if err != nil {
return err
}

return managedConsensusComponents.Create()
}

func initNodesAndTest(
numMetaNodes,
numNodes,
Expand Down
5 changes: 0 additions & 5 deletions integrationTests/testFullNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,6 @@ func (tpn *TestFullNode) initTestNodeWithArgs(args ArgTestProcessorNode, fullArg
tpn.AppStatusHandler = TestAppStatusHandler
}

id := hex.EncodeToString(tpn.OwnAccount.PkTxSignBytes)
if len(id) > 8 {
id = id[0:8]
}

tpn.MainMessenger = CreateMessengerWithNoDiscovery()

tpn.StatusMetrics = args.StatusMetrics
Expand Down

0 comments on commit a32849b

Please sign in to comment.