-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling of aliases to unsigned integer types other than uint64. (#…
…162)
- Loading branch information
Showing
6 changed files
with
163 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package testcases | ||
|
||
//go:generate go run ../main.go --path uint.go | ||
|
||
type Uint8 uint8 | ||
type Uint16 uint16 | ||
type Uint32 uint32 | ||
type Uint64 uint64 | ||
|
||
type Uints struct { | ||
Uint8 Uint8 | ||
Uint16 Uint16 | ||
Uint32 Uint32 | ||
Uint64 Uint64 | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package testcases | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestUint(t *testing.T) { | ||
s := Uints{ | ||
Uint8: Uint8(123), | ||
Uint16: Uint16(12345), | ||
Uint32: Uint32(1234567890), | ||
Uint64: Uint64(123456789000), | ||
} | ||
expectedHash := [32]byte{ | ||
0xea, 0xfc, 0xf7, 0xa2, 0x41, 0x8, 0x51, 0xa2, | ||
0xa0, 0xb0, 0x23, 0x68, 0xff, 0x4, 0x44, 0xbd, | ||
0x24, 0xc9, 0x9b, 0xff, 0xe7, 0x81, 0xca, 0x49, | ||
0xb6, 0xf7, 0xd4, 0x99, 0x28, 0xf3, 0xee, 0xeb, | ||
} | ||
|
||
bytes, err := s.MarshalSSZ() | ||
assert.NoError(t, err) | ||
|
||
var s2 Uints | ||
err = s2.UnmarshalSSZ(bytes) | ||
assert.NoError(t, err) | ||
|
||
assert.Equal(t, s, s2) | ||
|
||
h, err := s.HashTreeRoot() | ||
assert.NoError(t, err) | ||
|
||
assert.Equal(t, h, expectedHash) | ||
} |