Skip to content

Comments

Some improvements for the state package testing#10316

Merged
prylabs-bulldozer[bot] merged 8 commits intoOffchainLabs:developfrom
leolara:testing/state_testing_coverage
Mar 15, 2022
Merged

Some improvements for the state package testing#10316
prylabs-bulldozer[bot] merged 8 commits intoOffchainLabs:developfrom
leolara:testing/state_testing_coverage

Conversation

@leolara
Copy link
Contributor

@leolara leolara commented Mar 7, 2022

What type of PR is this?

Refactor

What does this PR do? Why is it needed?

Avoids some code repetition in the state package testing

Which issues(s) does this PR fix?

Related #10047

Other notes for review

@leolara leolara requested review from a team, nisdas and rkapka as code owners March 7, 2022 16:19
@leolara leolara requested a review from jmozah March 7, 2022 16:19

type getStateWithLatestBlockHeader func(*ethpb.BeaconBlockHeader) (state.BeaconState, error)

func VerifyBeaconState_LatestBlockHeader(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a particular reason snake case is preferred over camel case? Local IDE (Goland) complained about this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am just copying what is the name of the original test: TestBeaconState_LatestBlockHeader

Copy link
Collaborator

Choose a reason for hiding this comment

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

Then I think camel case is preferred since this is no longer an executable test rather than a test only helper function

@leolara
Copy link
Contributor Author

leolara commented Mar 8, 2022

@terencechain please, check new commit

Copy link
Contributor

@rkapka rkapka left a comment

Choose a reason for hiding this comment

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

Please also add state-native/v2/references_test.go and state-native/v3/references_test.go

@leolara
Copy link
Contributor Author

leolara commented Mar 10, 2022

@rkapka done

rkapka
rkapka previously approved these changes Mar 10, 2022
@rkapka
Copy link
Contributor

rkapka commented Mar 10, 2022

Thanks! Let's wait for @terencechain's approval before merging

@rkapka
Copy link
Contributor

rkapka commented Mar 10, 2022

bazel run //:gazelle -- fix needed

rkapka
rkapka previously approved these changes Mar 10, 2022
@rkapka
Copy link
Contributor

rkapka commented Mar 10, 2022

Hey @leolara , I just checked daaa2f9 and I'm pretty sure what @terencechain meant was to change VerifyBeaconState_LatestBlockHeader to verifyBeaconStateLatestBlockHeader starting with a lowercase because it's a private helper function.

@rkapka rkapka dismissed their stale review March 10, 2022 21:55

Found a small issue

@leolara
Copy link
Contributor Author

leolara commented Mar 15, 2022

@rkapka VerifyBeaconState_LatestBlockHeader or VerifyBeaconStateLatestBlockHeader cannot be private, it is called by the tests of the different state versions.

For example:

https://github.com/leolara/prysm/blob/testing/state_testing_coverage/beacon-chain/state/v1/getters_block_test.go#L12

Please let me know if you want the underscore in the name of the public VerifyBeaconState_... methods or you prefer VerifyBeaconState...

@rkapka
Copy link
Contributor

rkapka commented Mar 15, 2022

Thanks for explaining. This looks good to me.

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.

3 participants