@@ -10,6 +10,7 @@ import (
1010 p2pMessage "github.com/multiversx/mx-chain-communication-go/p2p/message"
1111 "github.com/multiversx/mx-chain-core-go/core"
1212 "github.com/multiversx/mx-chain-core-go/data/block"
13+ "github.com/multiversx/mx-chain-go/consensus/mock"
1314 "github.com/stretchr/testify/assert"
1415 "github.com/stretchr/testify/require"
1516
@@ -58,6 +59,7 @@ func internalInitConsensusStateWithKeysHandler(keysHandler consensus.KeysHandler
5859 rcns ,
5960 rthr ,
6061 rstatus ,
62+ & mock.NodeRedundancyHandlerStub {},
6163 )
6264
6365 return cns
@@ -423,11 +425,52 @@ func TestConsensusState_CanProcessReceivedMessageShouldReturnFalseWhenMessageIsR
423425func TestConsensusState_CanProcessReceivedMessageShouldReturnFalseWhenMessageIsReceivedForOtherRound (t * testing.T ) {
424426 t .Parallel ()
425427
426- cns := internalInitConsensusState ()
428+ eligibleList := []string {"1" , "2" , "3" }
429+
430+ eligibleNodesPubKeys := make (map [string ]struct {})
431+ for _ , key := range eligibleList {
432+ eligibleNodesPubKeys [key ] = struct {}{}
433+ }
434+
435+ rcns , _ := spos .NewRoundConsensus (
436+ eligibleNodesPubKeys ,
437+ 3 ,
438+ "2" ,
439+ & testscommon.KeysHandlerStub {},
440+ )
441+
442+ rcns .SetConsensusGroup (eligibleList )
443+ rcns .SetLeader (eligibleList [0 ])
444+ rcns .ResetRoundState ()
445+
446+ rthr := spos .NewRoundThreshold ()
447+
448+ rthr .SetThreshold (bls .SrBlock , 1 )
449+ rthr .SetThreshold (bls .SrSignature , 3 )
450+ rthr .SetFallbackThreshold (bls .SrBlock , 1 )
451+ rthr .SetFallbackThreshold (bls .SrSignature , 2 )
452+
453+ rstatus := spos .NewRoundStatus ()
454+ rstatus .ResetRoundStatus ()
455+
456+ // force backup case for coverage
457+ cns := spos .NewConsensusState (
458+ rcns ,
459+ rthr ,
460+ rstatus ,
461+ & mock.NodeRedundancyHandlerStub {
462+ IsRedundancyNodeCalled : func () bool {
463+ return true
464+ },
465+ IsMainMachineActiveCalled : func () bool {
466+ return false
467+ },
468+ },
469+ )
427470
428471 cnsDta := & consensus.Message {
429472 RoundIndex : 0 ,
430- PubKey : []byte ("1" ),
473+ PubKey : []byte (cns . SelfPubKey () ),
431474 }
432475
433476 assert .False (t , cns .CanProcessReceivedMessage (cnsDta , 1 , bls .SrBlock ))
0 commit comments