@@ -61,10 +61,10 @@ func TestReader(t *testing.T) {
6161 exp := ABI {
6262 Methods : map [string ]Method {
6363 "balance" : {
64- "balance" , true , nil , nil ,
64+ "balance" , "balance" , true , nil , nil ,
6565 },
6666 "send" : {
67- "send" , false , []Argument {
67+ "send" , "send" , false , []Argument {
6868 {"amount" , Uint256 , false },
6969 }, nil ,
7070 },
@@ -162,32 +162,30 @@ func TestTestSlice(t *testing.T) {
162162 if err != nil {
163163 t .Fatal (err )
164164 }
165-
166165 slice := make ([]uint64 , 2 )
167166 if _ , err := abi .Pack ("uint64[2]" , slice ); err != nil {
168167 t .Error (err )
169168 }
170-
171169 if _ , err := abi .Pack ("uint64[]" , slice ); err != nil {
172170 t .Error (err )
173171 }
174172}
175173
176174func TestMethodSignature (t * testing.T ) {
177175 String , _ := NewType ("string" , nil )
178- m := Method {"foo" , false , []Argument {{"bar" , String , false }, {"baz" , String , false }}, nil }
176+ m := Method {"foo" , "foo" , false , []Argument {{"bar" , String , false }, {"baz" , String , false }}, nil }
179177 exp := "foo(string,string)"
180178 if m .Sig () != exp {
181179 t .Error ("signature mismatch" , exp , "!=" , m .Sig ())
182180 }
183181
184182 idexp := crypto .Keccak256 ([]byte (exp ))[:4 ]
185- if ! bytes .Equal (m .Id (), idexp ) {
186- t .Errorf ("expected ids to match %x != %x" , m .Id (), idexp )
183+ if ! bytes .Equal (m .ID (), idexp ) {
184+ t .Errorf ("expected ids to match %x != %x" , m .ID (), idexp )
187185 }
188186
189187 uintt , _ := NewType ("uint256" , nil )
190- m = Method {"foo" , false , []Argument {{"bar" , uintt , false }}, nil }
188+ m = Method {"foo" , "foo" , false , []Argument {{"bar" , uintt , false }}, nil }
191189 exp = "foo(uint256)"
192190 if m .Sig () != exp {
193191 t .Error ("signature mismatch" , exp , "!=" , m .Sig ())
@@ -206,13 +204,36 @@ func TestMethodSignature(t *testing.T) {
206204 {Name : "y" , Type : "int256" },
207205 }},
208206 })
209- m = Method {"foo" , false , []Argument {{"s" , s , false }, {"bar" , String , false }}, nil }
207+ m = Method {"foo" , "foo" , false , []Argument {{"s" , s , false }, {"bar" , String , false }}, nil }
210208 exp = "foo((int256,int256[],(int256,int256)[],(int256,int256)[2]),string)"
211209 if m .Sig () != exp {
212210 t .Error ("signature mismatch" , exp , "!=" , m .Sig ())
213211 }
214212}
215213
214+ func TestOverloadedMethodSignature (t * testing.T ) {
215+ json := `[{"constant":true,"inputs":[{"name":"i","type":"uint256"},{"name":"j","type":"uint256"}],"name":"foo","outputs":[],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"i","type":"uint256"}],"name":"foo","outputs":[],"payable":false,"stateMutability":"pure","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"i","type":"uint256"}],"name":"bar","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"i","type":"uint256"},{"indexed":false,"name":"j","type":"uint256"}],"name":"bar","type":"event"}]`
216+ abi , err := JSON (strings .NewReader (json ))
217+ if err != nil {
218+ t .Fatal (err )
219+ }
220+ check := func (name string , expect string , method bool ) {
221+ if method {
222+ if abi .Methods [name ].Sig () != expect {
223+ t .Fatalf ("The signature of overloaded method mismatch, want %s, have %s" , expect , abi .Methods [name ].Sig ())
224+ }
225+ } else {
226+ if abi .Events [name ].Sig () != expect {
227+ t .Fatalf ("The signature of overloaded event mismatch, want %s, have %s" , expect , abi .Events [name ].Sig ())
228+ }
229+ }
230+ }
231+ check ("foo" , "foo(uint256,uint256)" , true )
232+ check ("foo0" , "foo(uint256)" , true )
233+ check ("bar" , "bar(uint256)" , false )
234+ check ("bar0" , "bar(uint256,uint256)" , false )
235+ }
236+
216237func TestMultiPack (t * testing.T ) {
217238 abi , err := JSON (strings .NewReader (jsondata2 ))
218239 if err != nil {
@@ -900,13 +921,13 @@ func TestABI_MethodById(t *testing.T) {
900921 }
901922 for name , m := range abi .Methods {
902923 a := fmt .Sprintf ("%v" , m )
903- m2 , err := abi .MethodById (m .Id ())
924+ m2 , err := abi .MethodById (m .ID ())
904925 if err != nil {
905926 t .Fatalf ("Failed to look up ABI method: %v" , err )
906927 }
907928 b := fmt .Sprintf ("%v" , m2 )
908929 if a != b {
909- t .Errorf ("Method %v (id %v) not 'findable' by id in ABI" , name , common .ToHex (m .Id ()))
930+ t .Errorf ("Method %v (id %v) not 'findable' by id in ABI" , name , common .ToHex (m .ID ()))
910931 }
911932 }
912933 // Also test empty
@@ -974,8 +995,8 @@ func TestABI_EventById(t *testing.T) {
974995 t .Errorf ("We should find a event for topic %s, test #%d" , topicID .Hex (), testnum )
975996 }
976997
977- if event .Id () != topicID {
978- t .Errorf ("Event id %s does not match topic %s, test #%d" , event .Id ().Hex (), topicID .Hex (), testnum )
998+ if event .ID () != topicID {
999+ t .Errorf ("Event id %s does not match topic %s, test #%d" , event .ID ().Hex (), topicID .Hex (), testnum )
9791000 }
9801001
9811002 unknowntopicID := crypto .Keccak256Hash ([]byte ("unknownEvent" ))
0 commit comments