Skip to content
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

Aggregator Consensus data with no justifications #332

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions types/spectest/all_tests.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package spectest

import (
"testing"

"github.com/bloxapp/ssv-spec/types/spectest/tests"
"github.com/bloxapp/ssv-spec/types/spectest/tests/beacon"
"github.com/bloxapp/ssv-spec/types/spectest/tests/consensusdata"
consensusdataproposer "github.com/bloxapp/ssv-spec/types/spectest/tests/consensusdata/proposer"
Expand All @@ -14,12 +13,7 @@ import (
"github.com/bloxapp/ssv-spec/types/spectest/tests/ssvmsg"
)

type SpecTest interface {
TestName() string
Run(t *testing.T)
}

var AllTests = []SpecTest{
var AllTests = []tests.SpecTest{
ssvmsg.Encoding(),

partialsigmessage.Encoding(),
Expand Down Expand Up @@ -52,6 +46,7 @@ var AllTests = []SpecTest{
//consensusdata.BlockAndBlindedBlock(),
//consensusdata.ValidSyncCommitteeAggregator(),
//consensusdata.EmptySyncCommitteeAggregator(),
consensusdata.AggregatorNoJustifications(),
// TODO: add new consensusdata tests

consensusdataproposer.VersionedBlockValidation(),
Expand Down
3 changes: 2 additions & 1 deletion types/spectest/generate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"github.com/bloxapp/ssv-spec/types/spectest"
"github.com/bloxapp/ssv-spec/types/spectest/tests"
"os"
"path/filepath"
"reflect"
Expand All @@ -14,7 +15,7 @@ import (
//go:generate go run main.go

func main() {
all := map[string]spectest.SpecTest{}
all := map[string]tests.SpecTest{}
for _, t := range spectest.AllTests {
n := reflect.TypeOf(t).String() + "_" + t.TestName()
if all[n] != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// AggregatorJustifications tests a valid consensus data with aggregator pre-consensus justifications
func AggregatorJustifications() *SpecTest {
func AggregatorJustifications() tests.SpecTest {
panic("implement")
}
26 changes: 23 additions & 3 deletions types/spectest/tests/consensusdata/aggregator_no_justifications.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
package consensusdata

// AggregatorNoJustifications tests an invalid consensus data with no aggregator pre-consensus justifications
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that it is no issue to have an empty pre-con justification field here

func AggregatorNoJustifications() *SpecTest {
panic("implement")
import (
"github.com/bloxapp/ssv-spec/types/spectest/tests"
"github.com/bloxapp/ssv-spec/types/testingutils"
)

// AggregatorNoJustifications tests consensus data with no aggregator pre-consensus justifications
func AggregatorNoJustifications() tests.SpecTest {
cd := testingutils.TestAggregatorConsensusData

byts, err := cd.Encode()
if err != nil {
panic(err.Error())
}
root, err := cd.HashTreeRoot()
if err != nil {
panic(err.Error())
}

return &EncodingTest{
Name: "consensusdata aggregator no justifications encoding",
Data: byts,
ExpectedRoot: root,
}
}
4 changes: 3 additions & 1 deletion types/spectest/tests/consensusdata/aggregator_validation.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// AggregatorValidation tests a valid consensus data with AggregateAndProof
func AggregatorValidation() *SpecTest {
func AggregatorValidation() tests.SpecTest {
panic("implement")
}
4 changes: 3 additions & 1 deletion types/spectest/tests/consensusdata/attestation_validation.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// AttestationValidation tests a valid consensus data with AttestationData
func AttestationValidation() *SpecTest {
func AttestationValidation() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// AttesterJustifications tests an invalid consensus data with attester pre-consensus justifications
func AttesterJustifications() *SpecTest {
func AttesterJustifications() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// AttesterNoValidation tests a valid attester consensus data with no pre-consensus justifications
func AttesterNoValidation() *SpecTest {
func AttesterNoValidation() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// CapellaBlindedBlockValidation tests a valid consensus data with capella blinded block
func CapellaBlindedBlockValidation() *SpecTest {
func CapellaBlindedBlockValidation() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// CapellaBlockValidation tests a valid consensus data with capella block
func CapellaBlockValidation() *SpecTest {
func CapellaBlockValidation() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// ConsensusDataEncoding tests encoding and decoding ConsensusData for all duties
func ConsensusDataEncoding() *SpecTest {
func ConsensusDataEncoding() tests.SpecTest {
panic("implement")
}
4 changes: 3 additions & 1 deletion types/spectest/tests/consensusdata/contributions_encoding.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// ContributionsEncoding tests encoding and decoding contributions
func ContributionsEncoding() *SpecTest {
func ContributionsEncoding() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// InvalidAggregatorValidation tests an invalid consensus data with AggregateAndProof
func InvalidAggregatorValidation() *SpecTest {
func InvalidAggregatorValidation() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// InvalidAttestationValidation tests an invalid consensus data with AttestationData
func InvalidAttestationValidation() *SpecTest {
func InvalidAttestationValidation() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// InvalidCapellaBlindedBlockValidation tests an invalid consensus data with capella blinded block
func InvalidCapellaBlindedBlockValidation() *SpecTest {
func InvalidCapellaBlindedBlockValidation() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// InvalidCapellaBlockValidation tests an invalid consensus data with capella block
func InvalidCapellaBlockValidation() *SpecTest {
func InvalidCapellaBlockValidation() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// InvalidSyncCommitteeBlockValidation tests an invalid consensus data with sync committee block data.
func InvalidSyncCommitteeBlockValidation() *SpecTest {
func InvalidSyncCommitteeBlockValidation() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// InvalidSyncCommitteeContributionValidation tests an invalid consensus data with sync committee contrib.
func InvalidSyncCommitteeContributionValidation() *SpecTest {
func InvalidSyncCommitteeContributionValidation() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// ProposerJustifications tests a valid consensus data with proposer justifications
func ProposerJustifications() *SpecTest {
func ProposerJustifications() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// ProposerNoJustifications tests an invalid consensus data with no proposer justifications
func ProposerNoJustifications() *SpecTest {
func ProposerNoJustifications() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// SyncCommitteeContributionValidation tests a valid consensus data with sync committee contrib.
func SyncCommitteeContributionValidation() *SpecTest {
func SyncCommitteeContributionValidation() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// SyncCommitteeContributionJustifications tests a valid consensus data with sync committee contribution pre-consensus justifications
func SyncCommitteeContributionJustifications() *SpecTest {
func SyncCommitteeContributionJustifications() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// SyncCommitteeJustifications tests an invalid consensus data with sync committee pre-consensus justifications
func SyncCommitteeJustifications() *SpecTest {
func SyncCommitteeJustifications() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// SyncCommitteeNoContributionJustifications tests an invalid consensus data with no sync committee contribution pre-consensus justifications
func SyncCommitteeNoContributionJustifications() *SpecTest {
func SyncCommitteeNoContributionJustifications() tests.SpecTest {
panic("implement")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// SyncCommitteeNoJustifications tests a valid consensus data with no sync committee pre-consensus justifications
func SyncCommitteeNoJustifications() *SpecTest {
func SyncCommitteeNoJustifications() tests.SpecTest {
panic("implement")
}
18 changes: 0 additions & 18 deletions types/spectest/tests/consensusdata/test.go

This file was deleted.

4 changes: 3 additions & 1 deletion types/spectest/tests/consensusdata/validator_registration.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consensusdata

import "github.com/bloxapp/ssv-spec/types/spectest/tests"

// ValidatorRegistration tests an invalid consensus data for validator registration (has no consensus data)
func ValidatorRegistration() *SpecTest {
func ValidatorRegistration() tests.SpecTest {
panic("implement")
}
8 changes: 8 additions & 0 deletions types/spectest/tests/test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package tests

import "testing"

type SpecTest interface {
TestName() string
Run(t *testing.T)
}
13 changes: 7 additions & 6 deletions types/testingutils/ssv_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ var TestAttesterNextEpochConsensusData = &types.ConsensusData{

var TestingAttesterNextEpochConsensusDataByts, _ = TestAttesterNextEpochConsensusData.Encode()

var TestAggregatorConsensusData = &types.ConsensusData{
Duty: TestingAggregatorDuty,
DataSSZ: TestingAggregateAndProofBytes,
}
var TestAggregatorConsensusDataByts, _ = TestAggregatorConsensusData.Encode()

var TestAttesterWithJustificationsConsensusData = func(ks *TestKeySet) *types.ConsensusData {
justif := make([]*types.SignedPartialSignatureMessage, 0)
for i := uint64(1); i <= ks.Threshold; i++ {
Expand All @@ -77,6 +71,13 @@ var TestAttesterWithJustificationsConsensusData = func(ks *TestKeySet) *types.Co
}
}

var TestAggregatorConsensusData = &types.ConsensusData{
Duty: TestingAggregatorDuty,
DataSSZ: TestingAggregateAndProofBytes,
}

var TestAggregatorConsensusDataByts, _ = TestAggregatorConsensusData.Encode()

// TestSyncCommitteeWithJustificationsConsensusData is an invalid sync committee msg (doesn't have pre-consensus)
var TestSyncCommitteeWithJustificationsConsensusData = func(ks *TestKeySet) *types.ConsensusData {
justif := make([]*types.SignedPartialSignatureMessage, 0)
Expand Down