-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests - Partial signatures container #338
Conversation
expectedSig, err := types.ReconstructSignatures(map[types.OperatorID][]byte{1: msgs[0].PartialSignature, 3: msgs[2].PartialSignature}) | ||
if err != nil { | ||
panic(err.Error()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am actually surprised that this doesn't err...
you think we need this? anyhow if there is an expectedError
then expectedResult
isn't checked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed isn't checked and we don't need. It's only confusing so I'll drop.
func DuplicateQuorum() tests.SpecTest { | ||
|
||
// Create a test key set | ||
ks := testingutils.Testing4SharesSet() | ||
|
||
// Create PartialSignatureMessage for testing | ||
msg1 := testingutils.PostConsensusAttestationMsg(ks.Shares[1], 1, qbft.FirstHeight) | ||
msg12 := testingutils.PostConsensusAttestationMsg(ks.Shares[1], 1, qbft.FirstHeight) | ||
msg2 := testingutils.PostConsensusAttestationMsg(ks.Shares[2], 2, qbft.FirstHeight) | ||
msg3 := testingutils.PostConsensusAttestationMsg(ks.Shares[3], 3, qbft.FirstHeight) | ||
msgs := []*types.PartialSignatureMessage{msg1.Message.Messages[0], msg12.Message.Messages[0], msg2.Message.Messages[0], msg3.Message.Messages[0]} | ||
|
||
// Verify the reconstructed signature | ||
expectedSig, err := types.ReconstructSignatures(map[types.OperatorID][]byte{1: msgs[0].PartialSignature, 2: msgs[2].PartialSignature, 3: msgs[3].PartialSignature}) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
|
||
return &PartialSigContainerTest{ | ||
Name: "duplicate quorum", | ||
Quorum: ks.Threshold, | ||
ValidatorPubKey: ks.ValidatorPK.Serialize(), | ||
SignatureMsgs: msgs, | ||
ExpectedResult: expectedSig.Serialize(), | ||
ExpectedQuorum: true, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we test a scenario where we have a duplicate msg but one is signed correctly and the other not? what are we expecting in that case? I guess to take the valid.
it that the Invalid
test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PartialSigContainer internal functionality is to only add a partial signature for a (signer, signing root) once. It uses a map for that. If we try to add another partial sig for the same author (even if the first one is invalid and the second one is valid), it won't do anything because the map already has this entry. I.e. it doesn't do any validation before adding.
For the duplicate and quorum test (this one), as a black box, we expect the partial sig container to produce the correct signature even if we call AddSignature twice for the same message/signature.
The two test cases you said are not tested. It will raise an error when reconstructing the signature if we add the invalid one first.
The invalid test, actually, tests a quorum with wrong signatures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two test cases you said are not tested. It will raise an error when reconstructing the signature if we add the invalid one first.
@MatheusFranco99 should we add an issue for those two tests, or they exist in other PRs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GalRogozinski
Actually, I should have said the "single test case" he mentioned.
Receiving a first valid and then a second invalid message from the same author is not tested here but I don't see this as an issue. I think that the current PartialSigContainer
module isn't supposed to do validation. On the other hand, the Runner
is supposed to do it and we have the tests for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please answer my question but approving in case no change is needed.
Spec Test
New test type to verify partial signature container functionality.
Tests:
Solving one element of issue 25.