@@ -54,7 +54,6 @@ func newV1TestHandler(tb testing.TB, goldenATXID types.ATXID) *v1TestHandler {
54
54
beacon : mocks .mBeacon ,
55
55
tortoise : mocks .mTortoise ,
56
56
malPublisher : mocks .mLegacyMalPublish ,
57
- signers : make (map [types.NodeID ]* signing.EdSigner ),
58
57
},
59
58
handlerMocks : mocks ,
60
59
}
@@ -583,7 +582,7 @@ func TestHandlerV1_StoreAtx(t *testing.T) {
583
582
return atx .ID () == watx .ID ()
584
583
}))
585
584
atxHdlr .mTortoise .EXPECT ().OnAtx (watx .PublishEpoch + 1 , watx .ID (), gomock .Any ())
586
- require .NoError (t , atxHdlr .storeAtx (context .Background (), atx , watx ))
585
+ require .NoError (t , atxHdlr .storeAtx (context .Background (), atx , watx , p2p . Peer ( "other" ) ))
587
586
588
587
atxFromDb , err := atxs .Get (atxHdlr .cdb , atx .ID ())
589
588
require .NoError (t , err )
@@ -602,13 +601,13 @@ func TestHandlerV1_StoreAtx(t *testing.T) {
602
601
return atx .ID () == watx .ID ()
603
602
}))
604
603
atxHdlr .mTortoise .EXPECT ().OnAtx (watx .PublishEpoch + 1 , watx .ID (), gomock .Any ())
605
- require .NoError (t , atxHdlr .storeAtx (context .Background (), atx , watx ))
604
+ require .NoError (t , atxHdlr .storeAtx (context .Background (), atx , watx , p2p . Peer ( "other" ) ))
606
605
607
606
atxHdlr .mBeacon .EXPECT ().OnAtx (gomock .Cond (func (atx * types.ActivationTx ) bool {
608
607
return atx .ID () == watx .ID ()
609
608
}))
610
609
// Note: tortoise is not informed about the same ATX again
611
- require .NoError (t , atxHdlr .storeAtx (context .Background (), atx , watx ))
610
+ require .NoError (t , atxHdlr .storeAtx (context .Background (), atx , watx , p2p . Peer ( "other" ) ))
612
611
})
613
612
614
613
t .Run ("stores ATX of malicious identity" , func (t * testing.T ) {
@@ -626,7 +625,7 @@ func TestHandlerV1_StoreAtx(t *testing.T) {
626
625
return atx .ID () == watx .ID ()
627
626
}))
628
627
atxHdlr .mTortoise .EXPECT ().OnAtx (watx .PublishEpoch + 1 , watx .ID (), gomock .Any ())
629
- require .NoError (t , atxHdlr .storeAtx (context .Background (), atx , watx ))
628
+ require .NoError (t , atxHdlr .storeAtx (context .Background (), atx , watx , p2p . Peer ( "other" ) ))
630
629
631
630
atxFromDb , err := atxs .Get (atxHdlr .cdb , atx .ID ())
632
631
require .NoError (t , err )
@@ -645,7 +644,7 @@ func TestHandlerV1_StoreAtx(t *testing.T) {
645
644
return atx .ID () == watx0 .ID ()
646
645
}))
647
646
atxHdlr .mTortoise .EXPECT ().OnAtx (watx0 .PublishEpoch + 1 , watx0 .ID (), gomock .Any ())
648
- require .NoError (t , atxHdlr .storeAtx (context .Background (), atx0 , watx0 ))
647
+ require .NoError (t , atxHdlr .storeAtx (context .Background (), atx0 , watx0 , p2p . Peer ( "other" ) ))
649
648
650
649
watx1 := newInitialATXv1 (t , goldenATXID )
651
650
watx1 .Coinbase = types .GenerateAddress ([]byte ("aaaa" ))
@@ -668,12 +667,11 @@ func TestHandlerV1_StoreAtx(t *testing.T) {
668
667
return nil
669
668
},
670
669
)
671
- require .NoError (t , atxHdlr .storeAtx (context .Background (), atx1 , watx1 ))
670
+ require .NoError (t , atxHdlr .storeAtx (context .Background (), atx1 , watx1 , p2p . Peer ( "other" ) ))
672
671
})
673
672
674
673
t .Run ("another atx for the same epoch for registered ID doesn't create a malfeasance proof" , func (t * testing.T ) {
675
674
atxHdlr := newV1TestHandler (t , goldenATXID )
676
- atxHdlr .Register (sig )
677
675
678
676
watx0 := newInitialATXv1 (t , goldenATXID )
679
677
watx0 .Sign (sig )
@@ -683,15 +681,15 @@ func TestHandlerV1_StoreAtx(t *testing.T) {
683
681
return atx .ID () == watx0 .ID ()
684
682
}))
685
683
atxHdlr .mTortoise .EXPECT ().OnAtx (watx0 .PublishEpoch + 1 , watx0 .ID (), gomock .Any ())
686
- require .NoError (t , atxHdlr .storeAtx (context .Background (), atx0 , watx0 ))
684
+ require .NoError (t , atxHdlr .storeAtx (context .Background (), atx0 , watx0 , atxHdlr . local ))
687
685
688
686
watx1 := newInitialATXv1 (t , goldenATXID )
689
687
watx1 .Coinbase = types .GenerateAddress ([]byte ("aaaa" ))
690
688
watx1 .Sign (sig )
691
689
atx1 := toAtx (t , watx1 )
692
690
693
691
require .ErrorContains (t ,
694
- atxHdlr .storeAtx (context .Background (), atx1 , watx1 ),
692
+ atxHdlr .storeAtx (context .Background (), atx1 , watx1 , atxHdlr . local ),
695
693
fmt .Sprintf ("%s already published an ATX" , sig .NodeID ().ShortString ()),
696
694
)
697
695
})
@@ -707,7 +705,7 @@ func TestHandlerV1_StoreAtx(t *testing.T) {
707
705
return atx .ID () == initialATX .ID ()
708
706
}))
709
707
atxHdlr .mTortoise .EXPECT ().OnAtx (initialATX .PublishEpoch + 1 , initialATX .ID (), gomock .Any ())
710
- require .NoError (t , atxHdlr .storeAtx (context .Background (), wInitialATX , initialATX ))
708
+ require .NoError (t , atxHdlr .storeAtx (context .Background (), wInitialATX , initialATX , p2p . Peer ( "other" ) ))
711
709
712
710
// valid first non-initial ATX
713
711
watx1 := newChainedActivationTxV1 (t , initialATX , goldenATXID )
@@ -718,7 +716,7 @@ func TestHandlerV1_StoreAtx(t *testing.T) {
718
716
return atx .ID () == watx1 .ID ()
719
717
}))
720
718
atxHdlr .mTortoise .EXPECT ().OnAtx (watx1 .PublishEpoch + 1 , watx1 .ID (), gomock .Any ())
721
- require .NoError (t , atxHdlr .storeAtx (context .Background (), atx1 , watx1 ))
719
+ require .NoError (t , atxHdlr .storeAtx (context .Background (), atx1 , watx1 , p2p . Peer ( "other" ) ))
722
720
723
721
watx2 := newChainedActivationTxV1 (t , watx1 , goldenATXID )
724
722
watx2 .Sign (sig )
@@ -728,7 +726,7 @@ func TestHandlerV1_StoreAtx(t *testing.T) {
728
726
return atx .ID () == watx2 .ID ()
729
727
}))
730
728
atxHdlr .mTortoise .EXPECT ().OnAtx (watx2 .PublishEpoch + 1 , watx2 .ID (), gomock .Any ())
731
- require .NoError (t , atxHdlr .storeAtx (context .Background (), atx2 , watx2 ))
729
+ require .NoError (t , atxHdlr .storeAtx (context .Background (), atx2 , watx2 , p2p . Peer ( "other" ) ))
732
730
733
731
// third non-initial ATX references initial ATX as prevATX
734
732
watx3 := newChainedActivationTxV1 (t , initialATX , goldenATXID )
@@ -753,7 +751,7 @@ func TestHandlerV1_StoreAtx(t *testing.T) {
753
751
},
754
752
)
755
753
756
- require .NoError (t , atxHdlr .storeAtx (context .Background (), atx3 , watx3 ))
754
+ require .NoError (t , atxHdlr .storeAtx (context .Background (), atx3 , watx3 , p2p . Peer ( "other" ) ))
757
755
})
758
756
759
757
t .Run ("another atx of v2 with the same prevatx is considered malicious" , func (t * testing.T ) {
@@ -767,7 +765,7 @@ func TestHandlerV1_StoreAtx(t *testing.T) {
767
765
return atx .ID () == initialATX .ID ()
768
766
}))
769
767
atxHdlr .mTortoise .EXPECT ().OnAtx (initialATX .PublishEpoch + 1 , initialATX .ID (), gomock .Any ())
770
- require .NoError (t , atxHdlr .v1 .storeAtx (context .Background (), wInitialATX , initialATX ))
768
+ require .NoError (t , atxHdlr .v1 .storeAtx (context .Background (), wInitialATX , initialATX , p2p . Peer ( "other" ) ))
771
769
772
770
// valid first non-initial ATX
773
771
watx1 := newChainedActivationTxV1 (t , initialATX , goldenATXID )
@@ -778,7 +776,7 @@ func TestHandlerV1_StoreAtx(t *testing.T) {
778
776
return atx .ID () == watx1 .ID ()
779
777
}))
780
778
atxHdlr .mTortoise .EXPECT ().OnAtx (watx1 .PublishEpoch + 1 , watx1 .ID (), gomock .Any ())
781
- require .NoError (t , atxHdlr .v1 .storeAtx (context .Background (), atx1 , watx1 ))
779
+ require .NoError (t , atxHdlr .v1 .storeAtx (context .Background (), atx1 , watx1 , p2p . Peer ( "other" ) ))
782
780
783
781
watx2 := newSoloATXv2 (t , watx1 .PublishEpoch + 1 , watx1 .ID (), watx1 .ID ())
784
782
watx2 .Sign (sig )
@@ -814,12 +812,11 @@ func TestHandlerV1_StoreAtx(t *testing.T) {
814
812
},
815
813
)
816
814
817
- require .NoError (t , atxHdlr .v1 .storeAtx (context .Background (), atx3 , watx3 ))
815
+ require .NoError (t , atxHdlr .v1 .storeAtx (context .Background (), atx3 , watx3 , p2p . Peer ( "other" ) ))
818
816
})
819
817
820
- t .Run ("another atx with the same prevatx for registered ID doesn't create a malfeasance proof" , func (t * testing.T ) {
818
+ t .Run ("another atx with the same prevatx when publishing doesn't create a malfeasance proof" , func (t * testing.T ) {
821
819
atxHdlr := newV1TestHandler (t , goldenATXID )
822
- atxHdlr .Register (sig )
823
820
824
821
// Act & Assert
825
822
wInitialATX := newInitialATXv1 (t , goldenATXID )
@@ -830,7 +827,7 @@ func TestHandlerV1_StoreAtx(t *testing.T) {
830
827
return atx .ID () == wInitialATX .ID ()
831
828
}))
832
829
atxHdlr .mTortoise .EXPECT ().OnAtx (wInitialATX .PublishEpoch + 1 , wInitialATX .ID (), gomock .Any ())
833
- require .NoError (t , atxHdlr .storeAtx (context .Background (), initialAtx , wInitialATX ))
830
+ require .NoError (t , atxHdlr .storeAtx (context .Background (), initialAtx , wInitialATX , atxHdlr . local ))
834
831
835
832
// valid first non-initial ATX
836
833
watx1 := newChainedActivationTxV1 (t , wInitialATX , goldenATXID )
@@ -841,7 +838,7 @@ func TestHandlerV1_StoreAtx(t *testing.T) {
841
838
return atx .ID () == watx1 .ID ()
842
839
}))
843
840
atxHdlr .mTortoise .EXPECT ().OnAtx (watx1 .PublishEpoch + 1 , watx1 .ID (), gomock .Any ())
844
- require .NoError (t , atxHdlr .storeAtx (context .Background (), atx1 , watx1 ))
841
+ require .NoError (t , atxHdlr .storeAtx (context .Background (), atx1 , watx1 , atxHdlr . local ))
845
842
846
843
// second non-initial ATX references empty as prevATX
847
844
watx2 := newInitialATXv1 (t , goldenATXID )
@@ -850,7 +847,7 @@ func TestHandlerV1_StoreAtx(t *testing.T) {
850
847
atx2 := toAtx (t , watx2 )
851
848
852
849
require .ErrorContains (t ,
853
- atxHdlr .storeAtx (context .Background (), atx2 , watx2 ),
850
+ atxHdlr .storeAtx (context .Background (), atx2 , watx2 , atxHdlr . local ),
854
851
fmt .Sprintf ("%s referenced incorrect previous ATX" , sig .NodeID ().ShortString ()),
855
852
)
856
853
})
0 commit comments