@@ -19,6 +19,7 @@ import (
1919 "github.com/spacemeshos/go-spacemesh/activation/wire"
2020 "github.com/spacemeshos/go-spacemesh/atxsdata"
2121 "github.com/spacemeshos/go-spacemesh/codec"
22+ "github.com/spacemeshos/go-spacemesh/common/fixture"
2223 "github.com/spacemeshos/go-spacemesh/common/types"
2324 "github.com/spacemeshos/go-spacemesh/datastore"
2425 mwire "github.com/spacemeshos/go-spacemesh/malfeasance/wire"
@@ -121,8 +122,8 @@ func (h *handlerMocks) expectVerifyNIPoSTs(
121122}
122123
123124func (h * handlerMocks ) expectStoreAtxV2 (atx * wire.ActivationTxV2 ) {
124- h .mbeacon .EXPECT ().OnAtx (gomock . Any ( ))
125- h .mtortoise .EXPECT ().OnAtx (gomock . Any (), gomock . Any (), gomock .Any ())
125+ h .mbeacon .EXPECT ().OnAtx (fixture . MatchId ( atx . ID () ))
126+ h .mtortoise .EXPECT ().OnAtx (atx . PublishEpoch + 1 , atx . ID (), gomock .Any ())
126127 h .mValidator .EXPECT ().IsVerifyingFullPost ().Return (false )
127128}
128129
@@ -183,17 +184,24 @@ func (h *v2TestHandler) createAndProcessInitial(t *testing.T, sig *signing.EdSig
183184 t .Helper ()
184185 atx := newInitialATXv2 (t , h .handlerMocks .goldenATXID )
185186 atx .Sign (sig )
186- p , err := h .processInitial (atx )
187+ p , err := h .processInitial (t , atx )
187188 require .NoError (t , err )
188189 require .Nil (t , p )
189190 return atx
190191}
191192
192- func (h * v2TestHandler ) processInitial (atx * wire.ActivationTxV2 ) (* mwire.MalfeasanceProof , error ) {
193+ func (h * v2TestHandler ) processInitial (t * testing.T , atx * wire.ActivationTxV2 ) (* mwire.MalfeasanceProof , error ) {
194+ t .Helper ()
193195 h .expectInitialAtxV2 (atx )
194196 return h .processATX (context .Background (), peer .ID ("peer" ), atx , codec .MustEncode (atx ), time .Now ())
195197}
196198
199+ func (h * v2TestHandler ) processSoloAtx (t * testing.T , atx * wire.ActivationTxV2 ) (* mwire.MalfeasanceProof , error ) {
200+ t .Helper ()
201+ h .expectAtxV2 (atx )
202+ return h .processATX (context .Background (), peer .ID ("peer" ), atx , codec .MustEncode (atx ), time .Now ())
203+ }
204+
197205func TestHandlerV2_SyntacticallyValidate (t * testing.T ) {
198206 t .Parallel ()
199207 golden := types .RandomATXID ()
@@ -1234,7 +1242,7 @@ func Test_ValidateMarriages(t *testing.T) {
12341242 }
12351243 marriage .Sign (sig )
12361244
1237- p , err := atxHandler .processInitial (marriage )
1245+ p , err := atxHandler .processInitial (t , marriage )
12381246 require .NoError (t , err )
12391247 require .Nil (t , p )
12401248
@@ -1569,10 +1577,9 @@ func Test_Marriages(t *testing.T) {
15691577 Signature : otherSig .Sign (signing .MARRIAGE , sig .NodeID ().Bytes ()),
15701578 },
15711579 }
1572-
15731580 atx .Sign (sig )
15741581
1575- p , err := atxHandler .processInitial (atx )
1582+ p , err := atxHandler .processInitial (t , atx )
15761583 require .NoError (t , err )
15771584 require .Nil (t , p )
15781585
@@ -1588,7 +1595,39 @@ func Test_Marriages(t *testing.T) {
15881595 require .NoError (t , err )
15891596 require .ElementsMatch (t , []types.NodeID {sig .NodeID (), otherSig .NodeID ()}, set )
15901597 })
1591- t .Run ("can't marry twice" , func (t * testing.T ) {
1598+ t .Run ("can't marry twice in the same marriage ATX" , func (t * testing.T ) {
1599+ t .Parallel ()
1600+ atxHandler := newV2TestHandler (t , golden )
1601+
1602+ otherSig , err := signing .NewEdSigner ()
1603+ require .NoError (t , err )
1604+ othersAtx := atxHandler .createAndProcessInitial (t , otherSig )
1605+
1606+ othersSecondAtx := newSoloATXv2 (t , othersAtx .PublishEpoch + 1 , othersAtx .ID (), othersAtx .ID ())
1607+ othersSecondAtx .Sign (otherSig )
1608+ _ , err = atxHandler .processSoloAtx (t , othersSecondAtx )
1609+ require .NoError (t , err )
1610+
1611+ atx := newInitialATXv2 (t , golden )
1612+ atx .Marriages = []wire.MarriageCertificate {
1613+ {
1614+ Signature : sig .Sign (signing .MARRIAGE , sig .NodeID ().Bytes ()),
1615+ },
1616+ {
1617+ ReferenceAtx : othersAtx .ID (),
1618+ Signature : otherSig .Sign (signing .MARRIAGE , sig .NodeID ().Bytes ()),
1619+ },
1620+ {
1621+ ReferenceAtx : othersSecondAtx .ID (),
1622+ Signature : otherSig .Sign (signing .MARRIAGE , sig .NodeID ().Bytes ()),
1623+ },
1624+ }
1625+ atx .Sign (sig )
1626+
1627+ _ , err = atxHandler .validateMarriages (atx )
1628+ require .ErrorContains (t , err , "more than 1 marriage certificate for ID" )
1629+ })
1630+ t .Run ("can't marry twice (separate marriages)" , func (t * testing.T ) {
15921631 t .Parallel ()
15931632 atxHandler := newV2TestHandler (t , golden )
15941633
0 commit comments