@@ -66,71 +66,3 @@ func TestEncodeSelector(t *testing.T) {
6666 }
6767 }
6868}
69-
70- func TestEncodeArgs (t * testing.T ) {
71- cases := []struct {
72- Args []string
73- ExpectedFn func () []byte
74- }{
75- {
76- Args : []string {"1" , "2" , "3" },
77- ExpectedFn : func () []byte {
78- data := byteutil .Padding32Bytes ([]byte ("1" ))
79- data = append (data , byteutil .Padding32Bytes ([]byte ("2" ))... )
80- data = append (data , byteutil .Padding32Bytes ([]byte ("3" ))... )
81- return data
82- },
83- },
84- }
85- for _ , c := range cases {
86- got := EncodeArgs (c .Args )
87- if expected := c .ExpectedFn (); ! bytes .Equal (got , expected ) {
88- t .Errorf ("Unexpected args: got %v (%d), expected: %v (%d)" , byteutil .ToHexBloom (got ), len (got ), byteutil .ToHexBloom (expected ), len (expected ))
89- }
90- }
91- }
92-
93- func TestParseArgs (t * testing.T ) {
94- cases := []struct {
95- Args []string
96- ExpectedFn func () []byte
97- }{
98- {
99- Args : []string {"true" , "false" },
100- ExpectedFn : func () []byte {
101- // bool: 1 and 0 right-padded to 32 bytes
102- tr := byteutil .Padding32Bytes ([]byte {1 })
103- fa := byteutil .Padding32Bytes ([]byte {0 })
104- return append (tr , fa ... )
105- },
106- },
107- {
108- Args : []string {"42" , "0x2a" },
109- ExpectedFn : func () []byte {
110- // number 42 as uint256 big-endian (decimal and hex)
111- word := make ([]byte , 32 )
112- word [31 ] = 42
113- return append (word , word ... )
114- },
115- },
116- {
117- Args : []string {`""` },
118- ExpectedFn : func () []byte {
119- return byteutil .Padding32Bytes ([]byte {}) // empty string
120- },
121- },
122- {
123- Args : []string {`"hello"` },
124- ExpectedFn : func () []byte {
125- return byteutil .Padding32Bytes ([]byte ("hello" ))
126- },
127- },
128- }
129- for _ , c := range cases {
130- got := ParseArgs (c .Args )
131- expected := c .ExpectedFn ()
132- if ! bytes .Equal (got , expected ) {
133- t .Errorf ("ParseArgs(%q): got %v (%d), expected: %v (%d)" , c .Args , byteutil .ToHexBloom (got ), len (got ), byteutil .ToHexBloom (expected ), len (expected ))
134- }
135- }
136- }
0 commit comments