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

Fix createSlice for reference type #4

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sszgen/generator/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func (v *Value) createSlice(useNumVariable bool) string {
// []int uses the Extend functions in the fastssz package
return fmt.Sprintf("::.%s = ssz.Extend%s(::.%s, %s)", v.name, uintVToName(v.e), v.name, size)

case TypeContainer:
case TypeContainer, TypeReference:
Copy link

Choose a reason for hiding this comment

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

I'd add some tests to current test suite (it will be checked inside our project but anyway...)

Also seems we need to fix error messages for this case...

fastssz/encode.go

Lines 303 to 309 in 93b9cf0

num, ok := DivideInt(a, b)
if !ok {
return 0, fmt.Errorf("xx")
}
if num > max {
return 0, fmt.Errorf("yy")
}

Copy link
Author

Choose a reason for hiding this comment

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

What is the error message?

Copy link

Choose a reason for hiding this comment

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

Seems in case if user passes malformed input or adds more elements than limit allows it will get "xx" or "yy" as an error message.

It's not related to your patch directly, it's just interesting moment.

Copy link
Author

Choose a reason for hiding this comment

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

I see, let's do it later.
About tests, I tried to find a place in fastssz where to make them, but no luck. Let's push it as is and see what we'll need.

// []*(ref.)Struct{}
ptr := "*"
if v.e.noPtr {
Expand Down
Loading