-
Notifications
You must be signed in to change notification settings - Fork 24
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
Type test: share #337
Type test: share #337
Conversation
func NoQuorum() *ShareTest { | ||
ks := testingutils.Testing4SharesSet() | ||
share := testingutils.TestingShare(ks) | ||
|
||
msg := testingutils.TestingCommitMultiSignerMessage([]*bls.SecretKey{ks.Shares[1], ks.Shares[2]}, []types.OperatorID{1, 2}) | ||
|
||
return &ShareTest{ | ||
Name: "no quorum", | ||
Share: *share, | ||
Message: *msg, | ||
ExpectedHasPartialQuorum: true, | ||
ExpectedHasQuorum: false, | ||
ExpectedFullCommittee: false, | ||
} |
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 logic is pretty much the same as has_partial_quroum
?
If so maybe we might as well delete this test and change the name of has_partial_quorum
to account for 2 scenarios?
Having the same test for 2 different scenarios might also be an ok approach, but I think we have enough clutter in our tests anyhow
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.
Agree
func (test *ShareTest) GetUniqueMessageSignersCount() int { | ||
uniqueSigners := make(map[uint64]bool) | ||
|
||
for _, element := range test.Message.Signers { | ||
uniqueSigners[element] = true | ||
} | ||
|
||
return len(uniqueSigners) | ||
} |
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.
func (test *ShareTest) GetUniqueMessageSignersCount() int { | |
uniqueSigners := make(map[uint64]bool) | |
for _, element := range test.Message.Signers { | |
uniqueSigners[element] = true | |
} | |
return len(uniqueSigners) | |
} | |
func (test *ShareTest) GetUniqueMessageSignersCount() int { | |
uniqueSigners := make(map[uint64]struct{}) | |
for _, signer := range test.Message.Signers { | |
uniqueSigners[signer] = struct{}{} | |
} | |
return len(uniqueSigners) | |
} |
not anything crucial, but this is more memory-efficient since it doesn't actually store any data
@@ -96,6 +96,12 @@ func TestJson(t *testing.T) { | |||
typedTest := &beacon.DepositDataSpecTest{} | |||
require.NoError(t, json.Unmarshal(byts, &typedTest)) | |||
typedTest.Run(t) | |||
case reflect.TypeOf(&share.ShareTest{}).String(): | |||
byts, err := json.Marshal(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.
typo?
Spec Test
New test type to verify share's functionality of checking quorums.
Tests:
Solving one element of issue 25.