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

Test: Types - ConsensusData #344

Merged
merged 11 commits into from
Jan 16, 2024
Merged

Test: Types - ConsensusData #344

merged 11 commits into from
Jan 16, 2024

Conversation

MatheusFranco99
Copy link
Contributor

@MatheusFranco99 MatheusFranco99 commented Jan 9, 2024

Implement tests for ConsensusData.

Tests:

  • Attestation consensus data encoding
  • Aggregation consensus data encoding
  • Proposer consensus data encoding
  • Blinded proposer consensus data encoding
  • Sync committee consensus data encoding
  • Sync committee contribution consensus data encoding

  • Invalid duty

  • Valid proposer consensus data with Capella block
  • Valid proposer consensus data with blinded Capella block
  • Proposer consensus data with no justification
  • Invalid proposer consensus data with for Capella block
  • Invalid proposer consensus data with for blinded Capella block

  • Valid attestation consensus data
  • Invalid attestation consensus data with pre-consensus justification
  • Invalid attestation consensus data with wrong data

  • Valid aggregation consensus data
  • Invalid aggregation consensus data with no pre-consensus justification
  • Invalid aggregation consensus data with wrong data

  • Valid sync committee consensus data
  • Invalid sync committee consensus data with pre-consensus justification
  • Invalid sync committee consensus data with wrong data

  • Valid sync committee contribution consensus data
  • Invalid sync committee contribution consensus data with no pre-consensus justification
  • Invalid sync committee contribution consensus data with wrong data

Note: some files were deleted because they had duplicated test specifications.

Copy link
Contributor

@GalRogozinski GalRogozinski left a comment

Choose a reason for hiding this comment

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

I think I review this after we conclude on value check

@MatheusFranco99 MatheusFranco99 mentioned this pull request Jan 15, 2024
1 task
Copy link
Contributor

@GalRogozinski GalRogozinski left a comment

Choose a reason for hiding this comment

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

LGTM just answer my questions and I'll approve

// CapellaBlindedBlockValidation tests a valid consensus data with capella blinded block
func CapellaBlindedBlockValidation() *SpecTest {
panic("implement")
func CapellaBlindedBlockValidation() *ConsensusDataTest {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we will


// ContributionsEncoding tests encoding and decoding contributions
func ContributionsEncoding() *SpecTest {
panic("implement")
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's already inside encoding.go (duplicate)

return &ConsensusDataTest{
Name: "invalid sync committee",
ConsensusData: cd,
ExpectedError: "could not unmarshal ssz: expected buffer of length 32 receiced 1",
Copy link
Contributor

Choose a reason for hiding this comment

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

there is a typo in the error.. it is from our code?

Copy link
Contributor Author

@MatheusFranco99 MatheusFranco99 Jan 16, 2024

Choose a reason for hiding this comment

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

Will check

return &ConsensusDataTest{
Name: "invalid sync committee contribution",
ConsensusData: *cd,
ExpectedError: "could not unmarshal ssz: four",
Copy link
Contributor

Choose a reason for hiding this comment

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

you know what "four" means here?
it comes from ssz lib

Copy link
Contributor

Choose a reason for hiding this comment

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

seems to be like an error code or something, that's pretty funny, from the fastssz lib:

		if offset > endOffset {
			return fmt.Errorf("four")
		}
		if endOffset > size {
			return fmt.Errorf("five")
		}


// ProposerJustifications tests a valid consensus data with proposer justifications
func ProposerJustifications() *SpecTest {
panic("implement")
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Duplicate (same as proposer_valid test)

// SyncCommitteeContributionNoJustifications tests an invalid consensus data with no sync committee contribution pre-consensus justifications
func SyncCommitteeContributionNoJustifications() *ConsensusDataTest {

// To-do: add error when pre-consensus justification check is added.
Copy link
Contributor

Choose a reason for hiding this comment

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

is this a test todo or we missing this check in general?

Copy link
Contributor

Choose a reason for hiding this comment

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

when we bring back pre-consensus justification it shouldn't be empty

Copy link
Contributor

@GalRogozinski GalRogozinski left a comment

Choose a reason for hiding this comment

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

@MatheusFranco99
I approve but still answer my questions please 🙏

@GalRogozinski GalRogozinski merged commit 0af3f69 into main Jan 16, 2024
2 checks passed
@GalRogozinski GalRogozinski deleted the consensus-data-test branch January 16, 2024 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants