Skip to content

Commit

Permalink
Apply suggestions from PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
durkmurder committed Dec 16, 2024
1 parent 2b7f80f commit 83adfc0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions state/protocol/inmem/dkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
// TestDKGv0 tests that the [inmem.DKG] is backward compatible with the v0 DKG protocol model.
// We test this by creating a [inmem.DKG] instance from a v0 [flow.EpochSetup] and [flow.EpochCommit]
// and verifying that the DKG methods return the expected values.
// TODO(EFM, #6794): Remove this once we complete the network upgrade
func TestDKGv0(t *testing.T) {
// TODO(EFM, #6794): Update this test to use the new DKG model.
func TestDKG(t *testing.T) {
consensusParticipants := unittest.IdentityListFixture(5, unittest.WithRole(flow.RoleConsensus)).Sort(flow.Canonical[flow.Identity])
otherParticipants := unittest.IdentityListFixture(10, unittest.WithAllRolesExcept(flow.RoleConsensus))
setup := unittest.EpochSetupFixture(unittest.WithParticipants(append(consensusParticipants, otherParticipants...).ToSkeleton()))
Expand Down
9 changes: 3 additions & 6 deletions state/protocol/validity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,11 @@ func TestIsValidEpochCommitBackwardCompatible(t *testing.T) {
requiredThreshold := protocol.RandomBeaconSafetyThreshold(uint(len(commit.DKGIndexMap)))
require.Less(t, int(requiredThreshold), len(commit.DKGParticipantKeys),
"threshold has to be at lower than the number of keys, otherwise the test is invalid")
// sample the required threshold, since it's lower than the number of keys it will be valid for the
// new version of the [flow.EpochCommit] but not for the v0 version since it doesn't have the [flow.DKGIndexMap] field.
sampled, err := setup.Participants.Filter(filter.IsConsensusCommitteeMember).Sample(requiredThreshold)
require.NoError(t, err)

// preserve the DKGIndexMap since we will be removing it later
dkgIndexMap := commit.DKGIndexMap

// since we are passing the new version validation result should be successful
err = protocol.IsValidEpochCommit(commit, setup)
err := protocol.IsValidEpochCommit(commit, setup)
require.NoError(t, err)

commit.DKGIndexMap = nil
Expand All @@ -235,6 +230,8 @@ func TestIsValidEpochCommitBackwardCompatible(t *testing.T) {
// now we are going to sample participants so the number of keys is not equal to the number of consensus participants
// but the threshold for random beacon participants is still met. This is valid for the new version of the [flow.EpochCommit]
// since it requires the [flow.DKGIndexMap] to be present, but it's invalid for the v0 version.
sampled, err := setup.Participants.Filter(filter.IsConsensusCommitteeMember).Sample(requiredThreshold)
require.NoError(t, err)
setup.Participants = sampled
commit.DKGIndexMap = dkgIndexMap
err = protocol.IsValidEpochCommit(commit, setup)
Expand Down

0 comments on commit 83adfc0

Please sign in to comment.