-
Notifications
You must be signed in to change notification settings - Fork 3
chore(core/types): add Test_Body_hasOptionalFields to enforce hasLaterOptionalField
is up to date
#113
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
Conversation
Any fields added in the future will have to be optional. The change-detector will pick up on these too. |
yes but it would not pick up if we forget to update the |
core/types/block.libevm.go
Outdated
@@ -146,6 +146,10 @@ func (b *Body) EncodeRLP(dst io.Writer) error { | |||
}) | |||
} | |||
|
|||
func (b *Body) hasOptionalFields() bool { |
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.
func (b *Body) hasOptionalFields() bool { | |
func (b *Body) hasOptionalFieldsSet() bool { |
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.
Renamed to hasAnyOptionalFieldSet
since it should be true if any (not all) optional field is set.
field := v.Field(i) | ||
before := field.Interface() | ||
switch field.Kind() { | ||
case reflect.Slice: |
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 needs support for reflect.Pointer
as the optional fields can be struct pointers.
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.
We can just add them later on a add-when-needed basis. If it's not defined in the switch, the test would fail
03e6373
to
a0cec28
Compare
…erOptionalField` is up to date
Co-authored-by: Arran Schlosberg <[email protected]> Signed-off-by: Quentin McGaw <[email protected]>
a0cec28
to
24b3aec
Compare
This will likely be made obsolete by #120 |
Unnecessary following merge of #120 |
Why this should be merged
To enforce updating the
hasLaterOptionalField
field if more optional fields are added toBody
How this works
Use some reflect magic in a unit test
How this was tested