Skip to content

Commit

Permalink
add custom log ids for integration tests sync
Browse files Browse the repository at this point in the history
  • Loading branch information
ssd04 committed Jan 9, 2025
1 parent ec5be33 commit 95df853
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
15 changes: 13 additions & 2 deletions integrationTests/testProcessorNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -2174,7 +2174,10 @@ func (tpn *TestProcessorNode) addMockVm(blockchainHook vmcommon.BlockchainHook)
func (tpn *TestProcessorNode) initBlockProcessor() {
var err error

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

log := logger.GetOrCreate(fmt.Sprintf("p/sync/%s", id))

Expand Down Expand Up @@ -2216,6 +2219,13 @@ func (tpn *TestProcessorNode) initBlockProcessor() {
AppStatusHandlerField: &statusHandlerMock.AppStatusHandlerStub{},
}

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

logger := logger.GetOrCreate(fmt.Sprintf("p/b/%s", id))

argumentsBase := block.ArgBaseProcessor{
CoreComponents: coreComponents,
DataComponents: dataComponents,
Expand Down Expand Up @@ -2246,6 +2256,7 @@ func (tpn *TestProcessorNode) initBlockProcessor() {
BlockProcessingCutoffHandler: &testscommon.BlockProcessingCutoffStub{},
ManagedPeersHolder: &testscommon.ManagedPeersHolderStub{},
SentSignaturesTracker: &testscommon.SentSignatureTrackerStub{},
Logger: logger,
}

if check.IfNil(tpn.EpochStartNotifier) {
Expand Down Expand Up @@ -3105,7 +3116,7 @@ func (tpn *TestProcessorNode) initRequestedItemsHandler() {
}

func (tpn *TestProcessorNode) initBlockTracker() {
id := hex.EncodeToString(tpn.NodesCoordinator.GetOwnPublicKey())
id := hex.EncodeToString(tpn.OwnAccount.PkTxSignBytes)
if len(id) > 8 {
id = id[0:8]
}
Expand Down
17 changes: 13 additions & 4 deletions integrationTests/testSyncNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ func (tpn *TestProcessorNode) initBlockProcessorWithSync() {
AppStatusHandlerField: &statusHandlerMock.AppStatusHandlerStub{},
}

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

log := logger.GetOrCreate(fmt.Sprintf("p/sync/%s", id))
blockProcessorLogger := logger.GetOrCreate(fmt.Sprintf("p/b/%s", id))

argumentsBase := block.ArgBaseProcessor{
CoreComponents: coreComponents,
DataComponents: dataComponents,
Expand Down Expand Up @@ -107,10 +115,11 @@ func (tpn *TestProcessorNode) initBlockProcessorWithSync() {
BlockProcessingCutoffHandler: &testscommon.BlockProcessingCutoffStub{},
ManagedPeersHolder: &testscommon.ManagedPeersHolderStub{},
SentSignaturesTracker: &testscommon.SentSignatureTrackerStub{},
Logger: blockProcessorLogger,
}

if tpn.ShardCoordinator.SelfId() == core.MetachainShardId {
tpn.ForkDetector, _ = sync.NewMetaForkDetector(nil, tpn.RoundHandler, tpn.BlockBlackListHandler, tpn.BlockTracker, 0)
tpn.ForkDetector, _ = sync.NewMetaForkDetector(log, tpn.RoundHandler, tpn.BlockBlackListHandler, tpn.BlockTracker, 0)
argumentsBase.ForkDetector = tpn.ForkDetector
argumentsBase.TxCoordinator = &mock.TransactionCoordinatorMock{}
arguments := block.ArgMetaProcessor{
Expand All @@ -131,7 +140,7 @@ func (tpn *TestProcessorNode) initBlockProcessorWithSync() {

tpn.BlockProcessor, err = block.NewMetaProcessor(arguments)
} else {
tpn.ForkDetector, _ = sync.NewShardForkDetector(nil, tpn.RoundHandler, tpn.BlockBlackListHandler, tpn.BlockTracker, 0)
tpn.ForkDetector, _ = sync.NewShardForkDetector(log, tpn.RoundHandler, tpn.BlockBlackListHandler, tpn.BlockTracker, 0)
argumentsBase.ForkDetector = tpn.ForkDetector
argumentsBase.BlockChainHook = tpn.BlockchainHook
argumentsBase.TxCoordinator = tpn.TxCoordinator
Expand All @@ -149,7 +158,7 @@ func (tpn *TestProcessorNode) initBlockProcessorWithSync() {
}

func (tpn *TestProcessorNode) createShardBootstrapper() (TestBootstrapper, error) {
id := hex.EncodeToString(tpn.NodesCoordinator.GetOwnPublicKey())
id := hex.EncodeToString(tpn.OwnAccount.PkTxSignBytes)
if len(id) > 8 {
id = id[0:8]
}
Expand Down Expand Up @@ -204,7 +213,7 @@ func (tpn *TestProcessorNode) createShardBootstrapper() (TestBootstrapper, error
}

func (tpn *TestProcessorNode) createMetaChainBootstrapper() (TestBootstrapper, error) {
id := hex.EncodeToString(tpn.NodesCoordinator.GetOwnPublicKey())
id := hex.EncodeToString(tpn.OwnAccount.PkTxSignBytes)
if len(id) > 8 {
id = id[0:8]
}
Expand Down

0 comments on commit 95df853

Please sign in to comment.