Skip to content

Commit 91ceedb

Browse files
Tests - Re-add missing tests and fix error code handling (#586)
* reapply test and fix error code handling * generate files
1 parent f9cfb94 commit 91ceedb

8 files changed

+210
-12
lines changed

ssv/partial_sig_container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (ps *PartialSigContainer) ReconstructSignature(root [32]byte, validatorPubK
106106
validatorPubKeyCopy := make([]byte, len(validatorPubKey))
107107
copy(validatorPubKeyCopy, validatorPubKey)
108108

109-
if err := types.VerifyReconstructedSignature(signature, validatorPubKeyCopy, root); err != nil {
109+
if err = types.VerifyReconstructedSignature(signature, validatorPubKeyCopy, root); err != nil {
110110
return nil, errors.Wrap(err, "failed to verify reconstruct signature")
111111
}
112112
return signature.Serialize(), nil

ssv/spectest/all_tests.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ var AllTests = []tests.TestF{
183183

184184
dutyexe.WrongDutyRole,
185185
dutyexe.WrongDutyPubKey,
186-
// partialsigcontainer.OneSignature,
186+
partialsigcontainer.OneSignature,
187187
partialsigcontainer.Quorum,
188-
// partialsigcontainer.Duplicate,
188+
partialsigcontainer.Duplicate,
189189
partialsigcontainer.DuplicateQuorum,
190-
// partialsigcontainer.Invalid,
190+
partialsigcontainer.Invalid,
191191

192192
runnerconstruction.OneShare,
193193
runnerconstruction.NoShares,

ssv/spectest/generate/tests/partialsigcontainer.PartialSigContainerTest_PartialSigContainer_duplicate.json

Lines changed: 71 additions & 0 deletions
Large diffs are not rendered by default.

ssv/spectest/generate/tests/partialsigcontainer.PartialSigContainerTest_PartialSigContainer_invalid.json

Lines changed: 71 additions & 0 deletions
Large diffs are not rendered by default.

ssv/spectest/generate/tests/partialsigcontainer.PartialSigContainerTest_PartialSigContainer_one_signature.json

Lines changed: 59 additions & 0 deletions
Large diffs are not rendered by default.

ssv/spectest/tests/partialsigcontainer/invalid.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ func Invalid() tests.SpecTest {
2020
msgs := []*types.PartialSignatureMessage{msg1.Messages[0], msg2.Messages[0], msg3.Messages[0]}
2121

2222
// Verify the reconstructed signature
23-
expectedSig, err := types.ReconstructSignatures(map[types.OperatorID][]byte{1: msgs[0].PartialSignature, 2: msgs[1].PartialSignature, 3: msgs[2].PartialSignature})
23+
_, err := types.ReconstructSignatures(map[types.OperatorID][]byte{1: msgs[0].PartialSignature,
24+
2: msgs[1].PartialSignature, 3: msgs[2].PartialSignature})
2425
if err != nil {
2526
panic(err.Error())
2627
}
@@ -32,7 +33,7 @@ func Invalid() tests.SpecTest {
3233
ks.ValidatorPK.Serialize(),
3334
msgs,
3435
types.ReconstructSignatureErrorCode,
35-
expectedSig.Serialize(),
36+
nil,
3637
true,
3738
ks,
3839
)

ssv/spectest/tests/partialsigcontainer/one_signature.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func OneSignature() tests.SpecTest {
1818
msgs := []*types.PartialSignatureMessage{msg.Messages[0]}
1919

2020
// Verify the reconstructed signature
21-
expectedSig, err := types.ReconstructSignatures(map[types.OperatorID][]byte{1: msgs[0].PartialSignature})
21+
_, err := types.ReconstructSignatures(map[types.OperatorID][]byte{1: msgs[0].PartialSignature})
2222
if err != nil {
2323
panic(err.Error())
2424
}
@@ -30,7 +30,7 @@ func OneSignature() tests.SpecTest {
3030
ks.ValidatorPK.Serialize(),
3131
msgs,
3232
types.ReconstructSignatureErrorCode,
33-
expectedSig.Serialize(),
33+
nil,
3434
false,
3535
ks,
3636
)

ssv/spectest/tests/partialsigcontainer/test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ func (test *PartialSigContainerTest) Run(t *testing.T) {
4848
result, err := ps.ReconstructSignature(root, test.ValidatorPubKey, validatorIndex)
4949
// Check the result and error
5050
tests.AssertErrorCode(t, test.ExpectedErrorCode, err)
51-
if err != nil {
52-
require.Contains(t, err.Error(), test.ExpectedErrorCode)
53-
return
54-
}
5551
require.EqualValues(t, test.ExpectedResult, result)
5652
}
5753
}

0 commit comments

Comments
 (0)