@@ -1844,6 +1844,8 @@ func TestSubroundBlock_TriggerCreateSignaturesForManagedKeys(t *testing.T) {
18441844 t .Run ("should work" , func (t * testing.T ) {
18451845 t .Parallel ()
18461846
1847+ currEpoch := uint32 (2 )
1848+
18471849 container := consensusMocks .InitConsensusCore ()
18481850 enableEpochsHandler := & enableEpochsHandlerMock.EnableEpochsHandlerStub {
18491851 IsFlagEnabledInEpochCalled : func (flag core.EnableEpochFlag , epoch uint32 ) bool {
@@ -1857,6 +1859,8 @@ func TestSubroundBlock_TriggerCreateSignaturesForManagedKeys(t *testing.T) {
18571859 signingHandler := & consensusMocks.SigningHandlerStub {
18581860 CreateSignatureShareForPublicKeyCalled : func (_ context.Context , msg []byte , index uint16 , epoch uint32 , publicKeyBytes []byte ) ([]byte , error ) {
18591861 atomic .AddInt32 (& numMultiKeysSignaturesCreated , 1 )
1862+ require .Equal (t , currEpoch , epoch )
1863+
18601864 return []byte ("SIG" ), nil
18611865 },
18621866 }
@@ -1895,7 +1899,7 @@ func TestSubroundBlock_TriggerCreateSignaturesForManagedKeys(t *testing.T) {
18951899 & dataRetrieverMock.ThrottlerStub {},
18961900 )
18971901
1898- sr .SetHeader (& block.Header {})
1902+ sr .SetHeader (& block.Header {Epoch : currEpoch })
18991903 sr .SetSelfPubKey ("OTHER" )
19001904
19011905 srBlock .TriggerCreateSignaturesForManagedKeys (context .TODO ())
@@ -1974,6 +1978,76 @@ func TestSubroundBlock_TriggerCreateSignaturesForManagedKeys(t *testing.T) {
19741978
19751979 assert .Equal (t , int32 (0 ), atomic .LoadInt32 (& numMultiKeysSignaturesCreated ))
19761980 })
1981+
1982+ t .Run ("should return early if header not set" , func (t * testing.T ) {
1983+ t .Parallel ()
1984+
1985+ container := consensusMocks .InitConsensusCore ()
1986+ enableEpochsHandler := & enableEpochsHandlerMock.EnableEpochsHandlerStub {
1987+ IsFlagEnabledInEpochCalled : func (flag core.EnableEpochFlag , epoch uint32 ) bool {
1988+ return flag == common .AndromedaFlag
1989+ },
1990+ }
1991+ container .SetEnableEpochsHandler (enableEpochsHandler )
1992+
1993+ numMultiKeysSignaturesCreated := int32 (0 )
1994+
1995+ signingHandler := & consensusMocks.SigningHandlerStub {
1996+ CreateSignatureShareForPublicKeyCalled : func (_ context.Context , msg []byte , index uint16 , epoch uint32 , publicKeyBytes []byte ) ([]byte , error ) {
1997+ atomic .AddInt32 (& numMultiKeysSignaturesCreated , 1 )
1998+ return []byte ("SIG" ), nil
1999+ },
2000+ }
2001+ container .SetSigningHandler (signingHandler )
2002+ consensusState := initializers .InitConsensusStateWithKeysHandler (
2003+ & testscommon.KeysHandlerStub {
2004+ IsKeyManagedByCurrentNodeCalled : func (pkBytes []byte ) bool {
2005+ return true
2006+ },
2007+ },
2008+ )
2009+ ch := make (chan bool , 1 )
2010+
2011+ sr , _ := spos .NewSubround (
2012+ bls .SrBlock ,
2013+ bls .SrSignature ,
2014+ bls .SrEndRound ,
2015+ roundTimeDuration ,
2016+ 0.7 ,
2017+ 0.85 ,
2018+ "(SIGNATURE)" ,
2019+ consensusState ,
2020+ ch ,
2021+ executeStoredMessages ,
2022+ container ,
2023+ chainID ,
2024+ currentPid ,
2025+ & statusHandler.AppStatusHandlerStub {},
2026+ )
2027+
2028+ srBlock , _ := v2 .NewSubroundBlock (
2029+ sr ,
2030+ v2 .ProcessingThresholdPercent ,
2031+ & consensusMocks.SposWorkerMock {},
2032+ & consensusMocks.NtpSyncControllerMock {},
2033+ & dataRetrieverMock.ThrottlerStub {
2034+ CanProcessCalled : func () bool {
2035+ return false
2036+ },
2037+ },
2038+ )
2039+
2040+ sr .SetHeader (nil )
2041+ sr .SetSelfPubKey ("OTHER" )
2042+
2043+ ctx , cancel := context .WithCancel (context .TODO ())
2044+ cancel ()
2045+ srBlock .TriggerCreateSignaturesForManagedKeys (ctx )
2046+
2047+ srBlock .SignaturesWaitGroup ().Wait ()
2048+
2049+ assert .Equal (t , int32 (0 ), atomic .LoadInt32 (& numMultiKeysSignaturesCreated ))
2050+ })
19772051}
19782052
19792053func TestSubroundBlock_IsInterfaceNil (t * testing.T ) {
0 commit comments