-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ConsensusData test * validator registration and voluntary exit tests * attestation tests * aggregator tests * proposer tests * sync committee tests * sync committee contribution tests * invalid duty test * encoding tests * generate tests --------- Co-authored-by: Gal Rogozinski <galrogogit@gmail.com>
- Loading branch information
1 parent
90cfb70
commit 0af3f69
Showing
33 changed files
with
456 additions
and
119 deletions.
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.