-
Notifications
You must be signed in to change notification settings - Fork 24
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 - Validator #340
base: main
Are you sure you want to change the base?
Test - Validator #340
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm...
I see Alon did add this as an issue but on another instance he told me that we don't need this in spec... I also didn't plan doing such tests for the spec rethink... putting this on hold for now
"github.com/bloxapp/ssv-spec/types/testingutils" | ||
) | ||
|
||
func ValidConsensus() tests.SpecTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add comment
ssv/spectest/tests/validator/test.go
Outdated
} | ||
|
||
func (test *ValidatorTest) GetPostState() (interface{}, error) { | ||
return nil, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as part of the post-mortem about the deneb bug, we concluded that we should generate jsons for all tests..
so might as well implement this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding. Thanks!
ssv/spectest/tests/validator/test.go
Outdated
for _, msg := range test.OutputMessages { | ||
found := false | ||
for index2, msg2 := range broadcastedMsgs { | ||
if usedIndexes[index2] { | ||
continue | ||
} | ||
if bytes.Equal(msg.GetData(), msg2.GetData()) { | ||
if msg.GetType() == msg2.GetType() && msg.GetID() == msg2.GetID() { | ||
found = true | ||
usedIndexes[index2] = true | ||
break | ||
} | ||
} | ||
} | ||
if !found { | ||
panic(fmt.Sprintf("Broadcasted message not found in output messages: %v", msg)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This checks that OutputMessages
are a subset of broadcastedMsgs
but not the other way around?
meaning that could be a BroadcastedMsg that is missing in OutputMessage?
I think maybe more tests are like this? I just never really inspected the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before it I do:
require.Len(t, broadcastedMsgs, len(test.OutputMessages))
So I think they are tested to be equal. What do you think?
ssv/spectest/tests/validator/test.go
Outdated
require.Len(t, broadcastedRoots, len(test.BeaconBroadcastedRoots)) | ||
for _, r1 := range test.BeaconBroadcastedRoots { | ||
found := false | ||
for _, r2 := range broadcastedRoots { | ||
if r1 == hex.EncodeToString(r2[:]) { | ||
found = true | ||
break | ||
} | ||
} | ||
require.Truef(t, found, "broadcasted beacon root not found") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same issue as below I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before it I also check the length. But indeed I should add an "already used" map as in the other check. Adding it.
Duties []*types.Duty | ||
Messages []*types.SSVMessage | ||
OutputMessages []*types.SSVMessage | ||
BeaconBroadcastedRoots []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed you don't really use this field for the tests...
Not much harm that it is here I suppose
your choice whether to remove it or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BeaconBroadcastedRoots
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use it in compareBroadcastedBeaconMsgs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is just that in the tests themselves I noticed it was always empty
but arguably that's also a check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. Will take a look. Thx!
@GalRogozinski |
SSV Tests
Added tests for the
Validator
structure.Tests:
Solving one element of issue 25.