-
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
Test: Types - ConsensusData #344
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a79cdb1
ConsensusData test
MatheusFranco99 6305829
validator registration and voluntary exit tests
MatheusFranco99 8052423
attestation tests
MatheusFranco99 3e0c5ad
aggregator tests
MatheusFranco99 863940a
proposer tests
MatheusFranco99 2c88929
sync committee tests
MatheusFranco99 4bf81f9
sync committee contribution tests
MatheusFranco99 45d5b54
invalid duty test
MatheusFranco99 10d5fb0
encoding tests
MatheusFranco99 deaa13e
generate tests
MatheusFranco99 f71ca69
Merge branch 'main' into consensus-data-test
GalRogozinski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
types/spectest/tests/consensusdata/aggregator_justifications.go
This file was deleted.
Oops, something went wrong.
12 changes: 10 additions & 2 deletions
12
types/spectest/tests/consensusdata/aggregator_no_justifications.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
package consensusdata | ||
|
||
import "github.com/bloxapp/ssv-spec/types/testingutils" | ||
|
||
// AggregatorNoJustifications tests an invalid consensus data with no aggregator pre-consensus justifications | ||
func AggregatorNoJustifications() *SpecTest { | ||
panic("implement") | ||
func AggregatorNoJustifications() *ConsensusDataTest { | ||
|
||
// To-do: add error when pre-consensus justification check is added. | ||
|
||
return &ConsensusDataTest{ | ||
Name: "aggregator without justification", | ||
ConsensusData: *testingutils.TestAggregatorConsensusData, | ||
} | ||
} |
11 changes: 9 additions & 2 deletions
11
types/spectest/tests/consensusdata/aggregator_validation.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
package consensusdata | ||
|
||
import "github.com/bloxapp/ssv-spec/types/testingutils" | ||
|
||
// AggregatorValidation tests a valid consensus data with AggregateAndProof | ||
func AggregatorValidation() *SpecTest { | ||
panic("implement") | ||
func AggregatorValidation() *ConsensusDataTest { | ||
ks := testingutils.Testing4SharesSet() | ||
|
||
return &ConsensusDataTest{ | ||
Name: "aggregator valid", | ||
ConsensusData: *testingutils.TestAggregatorWithJustificationsConsensusData(ks), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
package consensusdata | ||
|
||
import "github.com/bloxapp/ssv-spec/types/testingutils" | ||
|
||
// AttestationValidation tests a valid consensus data with AttestationData | ||
func AttestationValidation() *SpecTest { | ||
panic("implement") | ||
func AttestationValidation() *ConsensusDataTest { | ||
return &ConsensusDataTest{ | ||
Name: "attestation validation", | ||
ConsensusData: *testingutils.TestAttesterConsensusData, | ||
} | ||
} |
25 changes: 23 additions & 2 deletions
25
types/spectest/tests/consensusdata/attester_justifications.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,27 @@ | ||
package consensusdata | ||
|
||
import ( | ||
"github.com/bloxapp/ssv-spec/types" | ||
"github.com/bloxapp/ssv-spec/types/testingutils" | ||
) | ||
|
||
// AttesterJustifications tests an invalid consensus data with attester pre-consensus justifications | ||
func AttesterJustifications() *SpecTest { | ||
panic("implement") | ||
func AttesterJustifications() *ConsensusDataTest { | ||
|
||
ks := testingutils.Testing4SharesSet() | ||
|
||
justif := make([]*types.SignedPartialSignatureMessage, 0) | ||
for i := uint64(0); i <= ks.Threshold; i++ { | ||
justif = append(justif, testingutils.PreConsensusRandaoMsg(ks.Shares[i+1], i+1)) | ||
} | ||
|
||
cd := testingutils.TestAttesterConsensusData | ||
|
||
cd.PreConsensusJustifications = justif | ||
|
||
return &ConsensusDataTest{ | ||
Name: "invalid attestation with justification", | ||
ConsensusData: *cd, | ||
ExpectedError: "attester invalid justifications", | ||
} | ||
} |
6 changes: 0 additions & 6 deletions
6
types/spectest/tests/consensusdata/attester_no_justifications.go
This file was deleted.
Oops, something went wrong.
14 changes: 12 additions & 2 deletions
14
types/spectest/tests/consensusdata/capella_blinded_block_validation.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
package consensusdata | ||
|
||
import ( | ||
"github.com/attestantio/go-eth2-client/spec" | ||
"github.com/bloxapp/ssv-spec/types/testingutils" | ||
) | ||
|
||
// CapellaBlindedBlockValidation tests a valid consensus data with capella blinded block | ||
func CapellaBlindedBlockValidation() *SpecTest { | ||
panic("implement") | ||
func CapellaBlindedBlockValidation() *ConsensusDataTest { | ||
ks := testingutils.Testing4SharesSet() | ||
|
||
return &ConsensusDataTest{ | ||
Name: "valid capella blinded block", | ||
ConsensusData: *testingutils.TestProposerBlindedWithJustificationsConsensusDataV(ks, spec.DataVersionCapella), | ||
} | ||
} |
14 changes: 12 additions & 2 deletions
14
types/spectest/tests/consensusdata/capella_block_validation.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
package consensusdata | ||
|
||
import ( | ||
"github.com/attestantio/go-eth2-client/spec" | ||
"github.com/bloxapp/ssv-spec/types/testingutils" | ||
) | ||
|
||
// CapellaBlockValidation tests a valid consensus data with capella block | ||
func CapellaBlockValidation() *SpecTest { | ||
panic("implement") | ||
func CapellaBlockValidation() *ConsensusDataTest { | ||
ks := testingutils.Testing4SharesSet() | ||
|
||
return &ConsensusDataTest{ | ||
Name: "valid capella block", | ||
ConsensusData: *testingutils.TestProposerWithJustificationsConsensusDataV(ks, spec.DataVersionCapella), | ||
} | ||
} |
43 changes: 41 additions & 2 deletions
43
types/spectest/tests/consensusdata/consensus_data_encoding.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,45 @@ | ||
package consensusdata | ||
|
||
import ( | ||
"github.com/attestantio/go-eth2-client/spec" | ||
"github.com/bloxapp/ssv-spec/types" | ||
"github.com/bloxapp/ssv-spec/types/testingutils" | ||
) | ||
|
||
// ConsensusDataEncoding tests encoding and decoding ConsensusData for all duties | ||
func ConsensusDataEncoding() *SpecTest { | ||
panic("implement") | ||
func ConsensusDataEncoding(name string, cd *types.ConsensusData) *EncodingTest { | ||
|
||
byts, err := cd.Encode() | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
root, err := cd.HashTreeRoot() | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
|
||
return &EncodingTest{ | ||
Name: name, | ||
Data: byts, | ||
ExpectedRoot: root, | ||
} | ||
} | ||
|
||
func ProposerConsensusDataEncoding() *EncodingTest { | ||
return ConsensusDataEncoding("proposer encoding", testingutils.TestProposerBlindedBlockConsensusDataV(spec.DataVersionCapella)) | ||
} | ||
func BlindedProposerConsensusDataEncoding() *EncodingTest { | ||
return ConsensusDataEncoding("blinded proposer encoding", testingutils.TestProposerBlindedBlockConsensusDataV(spec.DataVersionCapella)) | ||
} | ||
func AttestationConsensusDataEncoding() *EncodingTest { | ||
return ConsensusDataEncoding("attestation encoding", testingutils.TestAttesterConsensusData) | ||
} | ||
func AggregatorConsensusDataEncoding() *EncodingTest { | ||
return ConsensusDataEncoding("aggregation encoding", testingutils.TestAggregatorConsensusData) | ||
} | ||
func SyncCommitteeConsensusDataEncoding() *EncodingTest { | ||
return ConsensusDataEncoding("sync committee encoding", testingutils.TestSyncCommitteeConsensusData) | ||
} | ||
func SyncCommitteeContributionConsensusDataEncoding() *EncodingTest { | ||
return ConsensusDataEncoding("sync committee contribution encoding", testingutils.TestSyncCommitteeContributionConsensusData) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
17 changes: 15 additions & 2 deletions
17
types/spectest/tests/consensusdata/invalid_aggregator_validation.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
package consensusdata | ||
|
||
import "github.com/bloxapp/ssv-spec/types/testingutils" | ||
|
||
// InvalidAggregatorValidation tests an invalid consensus data with AggregateAndProof | ||
func InvalidAggregatorValidation() *SpecTest { | ||
panic("implement") | ||
func InvalidAggregatorValidation() *ConsensusDataTest { | ||
|
||
ks := testingutils.Testing4SharesSet() | ||
|
||
cd := testingutils.TestAggregatorWithJustificationsConsensusData(ks) | ||
|
||
cd.DataSSZ = testingutils.TestingSyncCommitteeBlockRoot[:] | ||
|
||
return &ConsensusDataTest{ | ||
Name: "invalid aggregator data", | ||
ConsensusData: *cd, | ||
ExpectedError: "could not unmarshal ssz: incorrect size", | ||
} | ||
} |
14 changes: 12 additions & 2 deletions
14
types/spectest/tests/consensusdata/invalid_attestation_validation.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
package consensusdata | ||
|
||
import "github.com/bloxapp/ssv-spec/types/testingutils" | ||
|
||
// InvalidAttestationValidation tests an invalid consensus data with AttestationData | ||
func InvalidAttestationValidation() *SpecTest { | ||
panic("implement") | ||
func InvalidAttestationValidation() *ConsensusDataTest { | ||
|
||
cd := testingutils.TestAttesterConsensusData | ||
cd.DataSSZ = testingutils.TestAggregatorConsensusDataByts | ||
|
||
return &ConsensusDataTest{ | ||
Name: "invalid attestation", | ||
ConsensusData: *cd, | ||
ExpectedError: "could not unmarshal ssz: incorrect size", | ||
} | ||
} |
22 changes: 20 additions & 2 deletions
22
types/spectest/tests/consensusdata/invalid_capella_blinded_block_validation.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,24 @@ | ||
package consensusdata | ||
|
||
import ( | ||
"github.com/attestantio/go-eth2-client/spec" | ||
"github.com/bloxapp/ssv-spec/types" | ||
"github.com/bloxapp/ssv-spec/types/testingutils" | ||
) | ||
|
||
// InvalidCapellaBlindedBlockValidation tests an invalid consensus data with capella blinded block | ||
func InvalidCapellaBlindedBlockValidation() *SpecTest { | ||
panic("implement") | ||
func InvalidCapellaBlindedBlockValidation() *ConsensusDataTest { | ||
|
||
version := spec.DataVersionCapella | ||
|
||
cd := &types.ConsensusData{ | ||
Duty: *testingutils.TestingProposerDutyV(version), | ||
Version: version, | ||
DataSSZ: []byte{}, | ||
} | ||
return &ConsensusDataTest{ | ||
Name: "invalid capella blinded block", | ||
ConsensusData: *cd, | ||
ExpectedError: "could not unmarshal ssz: incorrect size", | ||
} | ||
} |
22 changes: 20 additions & 2 deletions
22
types/spectest/tests/consensusdata/invalid_capella_block_validation.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,24 @@ | ||
package consensusdata | ||
|
||
import ( | ||
"github.com/attestantio/go-eth2-client/spec" | ||
"github.com/bloxapp/ssv-spec/types" | ||
"github.com/bloxapp/ssv-spec/types/testingutils" | ||
) | ||
|
||
// InvalidCapellaBlockValidation tests an invalid consensus data with capella block | ||
func InvalidCapellaBlockValidation() *SpecTest { | ||
panic("implement") | ||
func InvalidCapellaBlockValidation() *ConsensusDataTest { | ||
|
||
version := spec.DataVersionCapella | ||
|
||
cd := &types.ConsensusData{ | ||
Duty: *testingutils.TestingProposerDutyV(version), | ||
Version: version, | ||
DataSSZ: []byte{}, | ||
} | ||
return &ConsensusDataTest{ | ||
Name: "invalid capella block", | ||
ConsensusData: *cd, | ||
ExpectedError: "could not unmarshal ssz: incorrect size", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package consensusdata | ||
|
||
import ( | ||
"github.com/attestantio/go-eth2-client/spec" | ||
"github.com/bloxapp/ssv-spec/types" | ||
"github.com/bloxapp/ssv-spec/types/testingutils" | ||
) | ||
|
||
// InvalidDuty tests an invalid consensus data with invalid duty | ||
func InvalidDuty() *ConsensusDataTest { | ||
|
||
cd := &types.ConsensusData{ | ||
Duty: types.Duty{ | ||
Type: types.BeaconRole(100), | ||
PubKey: testingutils.TestingValidatorPubKey, | ||
}, | ||
Version: spec.DataVersionCapella, | ||
DataSSZ: testingutils.TestingAttestationDataBytes, | ||
} | ||
|
||
return &ConsensusDataTest{ | ||
Name: "invalid duty", | ||
ConsensusData: *cd, | ||
ExpectedError: "unknown duty role", | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
In Deneb PR we should maybe add tests if they are not there?
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.
Yes, we will