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

QBFT Tests - Instance & Message #328

Merged
merged 16 commits into from
Feb 12, 2024
Merged

Conversation

MatheusFranco99
Copy link
Contributor

@MatheusFranco99 MatheusFranco99 commented Dec 29, 2023

Tests

Messages

  • Invalid hash data root - message.Validate() doesn't test root field. Should this test be dropped?
  • Invalid prepare justification
  • Invalid round change justifications unmarshalling
  • Marshal justifications
  • Prepare justifications unmarshalling
  • Round change justifications unmarshalling
  • Round change prepared
  • SSZ Marshalling
  • Valid Hash data root - message.Validate() doesn't test root field. Should this test be dropped?

Start Instance

  • Equal height no running instance

@MatheusFranco99 MatheusFranco99 marked this pull request as ready for review December 29, 2023 19:12
@MatheusFranco99 MatheusFranco99 self-assigned this Dec 29, 2023
"github.com/bloxapp/ssv-spec/qbft/spectest/tests"
"github.com/bloxapp/ssv-spec/types"
"github.com/bloxapp/ssv-spec/types/testingutils"
)

// InvalidPrepareJustificationsUnmarshalling tests unmarshalling invalid prepare justifications (during message.validate())
func InvalidPrepareJustificationsUnmarshalling() tests.SpecTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

@alonmuroch
It seems this is mainly testing ssz logic that is the repsonsibility of a 3rd party lib.

We can have this basic test but just wondering what is your view of testing such parts of the code?

Copy link
Contributor

Choose a reason for hiding this comment

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

Answering myself since Alon won't answer:

  1. for valid messages we need to make sure the encoding is consistent if the ssz lib changes
  2. invalid encodings in my eyes are optional to test. Since even if malformed object is created later validations should help here

qbft/spectest/tests/messages/round_change_prepared.go Outdated Show resolved Hide resolved
qbft/spectest/tests/messages/ssz_marshaling.go Outdated Show resolved Hide resolved
@GalRogozinski GalRogozinski self-requested a review January 3, 2024 16:24
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.

We need to discuss whether the MsgSpecTest needs to be changed to have better validity checks.

Also we need to understand why we need CreateMsgTest and MsgSpecTest

"github.com/bloxapp/ssv-spec/qbft/spectest/tests"
"github.com/bloxapp/ssv-spec/types"
"github.com/bloxapp/ssv-spec/types/testingutils"
)

// InvalidPrepareJustificationsUnmarshalling tests unmarshalling invalid prepare justifications (during message.validate())
func InvalidPrepareJustificationsUnmarshalling() tests.SpecTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

Answering myself since Alon won't answer:

  1. for valid messages we need to make sure the encoding is consistent if the ssz lib changes
  2. invalid encodings in my eyes are optional to test. Since even if malformed object is created later validations should help here

Comment on lines +23 to +24

return &tests.MsgSpecTest{
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the issue here is that the test code is wrong... we should be doing BaseMsgValidation() and not msg.Validate() that is partial

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean the instance BaseMsgValidation or the controller one?
In the test structure we don't have any of these objects btw. Should I add it?
My only concern is that the other tests will probably need to change.
Another way would be to move this single test to ssv. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we open an issue and just remember to fix this when we do spec rethink

qbft/spectest/tests/messages/round_change_prepared.go Outdated Show resolved Hide resolved
qbft/spectest/tests/messages/ssz_marshaling.go Outdated Show resolved Hide resolved
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.

So we just need @alonmuroch to explain us the test and we're done

qbft/spectest/tests/controller_spectest.go Show resolved Hide resolved
@GalRogozinski GalRogozinski merged commit 83e0897 into main Feb 12, 2024
2 checks passed
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