@@ -120,6 +120,7 @@ var methods = map[string]Method{
120
120
}
121
121
122
122
func TestReader (t * testing.T ) {
123
+ t .Parallel ()
123
124
abi := ABI {
124
125
Methods : methods ,
125
126
}
@@ -151,6 +152,7 @@ func TestReader(t *testing.T) {
151
152
}
152
153
153
154
func TestInvalidABI (t * testing.T ) {
155
+ t .Parallel ()
154
156
json := `[{ "type" : "function", "name" : "", "constant" : fals }]`
155
157
_ , err := JSON (strings .NewReader (json ))
156
158
if err == nil {
@@ -170,6 +172,7 @@ func TestInvalidABI(t *testing.T) {
170
172
// constructor(uint256 a, uint256 b) public{}
171
173
// }
172
174
func TestConstructor (t * testing.T ) {
175
+ t .Parallel ()
173
176
json := `[{ "inputs": [{"internalType": "uint256","name": "a","type": "uint256" },{ "internalType": "uint256","name": "b","type": "uint256"}],"stateMutability": "nonpayable","type": "constructor"}]`
174
177
method := NewMethod ("" , "" , Constructor , "nonpayable" , false , false , []Argument {{"a" , Uint256 , false }, {"b" , Uint256 , false }}, nil )
175
178
// Test from JSON
@@ -199,6 +202,7 @@ func TestConstructor(t *testing.T) {
199
202
}
200
203
201
204
func TestTestNumbers (t * testing.T ) {
205
+ t .Parallel ()
202
206
abi , err := JSON (strings .NewReader (jsondata ))
203
207
if err != nil {
204
208
t .Fatal (err )
@@ -236,6 +240,7 @@ func TestTestNumbers(t *testing.T) {
236
240
}
237
241
238
242
func TestMethodSignature (t * testing.T ) {
243
+ t .Parallel ()
239
244
m := NewMethod ("foo" , "foo" , Function , "" , false , false , []Argument {{"bar" , String , false }, {"baz" , String , false }}, nil )
240
245
exp := "foo(string,string)"
241
246
if m .Sig != exp {
@@ -274,6 +279,7 @@ func TestMethodSignature(t *testing.T) {
274
279
}
275
280
276
281
func TestOverloadedMethodSignature (t * testing.T ) {
282
+ t .Parallel ()
277
283
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"}]`
278
284
abi , err := JSON (strings .NewReader (json ))
279
285
if err != nil {
@@ -297,6 +303,7 @@ func TestOverloadedMethodSignature(t *testing.T) {
297
303
}
298
304
299
305
func TestCustomErrors (t * testing.T ) {
306
+ t .Parallel ()
300
307
json := `[{ "inputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ],"name": "MyError", "type": "error"} ]`
301
308
abi , err := JSON (strings .NewReader (json ))
302
309
if err != nil {
@@ -311,6 +318,7 @@ func TestCustomErrors(t *testing.T) {
311
318
}
312
319
313
320
func TestMultiPack (t * testing.T ) {
321
+ t .Parallel ()
314
322
abi , err := JSON (strings .NewReader (jsondata ))
315
323
if err != nil {
316
324
t .Fatal (err )
@@ -349,6 +357,7 @@ func ExampleJSON() {
349
357
}
350
358
351
359
func TestInputVariableInputLength (t * testing.T ) {
360
+ t .Parallel ()
352
361
const definition = `[
353
362
{ "type" : "function", "name" : "strOne", "constant" : true, "inputs" : [ { "name" : "str", "type" : "string" } ] },
354
363
{ "type" : "function", "name" : "bytesOne", "constant" : true, "inputs" : [ { "name" : "str", "type" : "bytes" } ] },
@@ -477,6 +486,7 @@ func TestInputVariableInputLength(t *testing.T) {
477
486
}
478
487
479
488
func TestInputFixedArrayAndVariableInputLength (t * testing.T ) {
489
+ t .Parallel ()
480
490
abi , err := JSON (strings .NewReader (jsondata ))
481
491
if err != nil {
482
492
t .Error (err )
@@ -651,6 +661,7 @@ func TestInputFixedArrayAndVariableInputLength(t *testing.T) {
651
661
}
652
662
653
663
func TestDefaultFunctionParsing (t * testing.T ) {
664
+ t .Parallel ()
654
665
const definition = `[{ "name" : "balance", "type" : "function" }]`
655
666
656
667
abi , err := JSON (strings .NewReader (definition ))
@@ -664,6 +675,7 @@ func TestDefaultFunctionParsing(t *testing.T) {
664
675
}
665
676
666
677
func TestBareEvents (t * testing.T ) {
678
+ t .Parallel ()
667
679
const definition = `[
668
680
{ "type" : "event", "name" : "balance" },
669
681
{ "type" : "event", "name" : "anon", "anonymous" : true},
@@ -740,6 +752,7 @@ func TestBareEvents(t *testing.T) {
740
752
//
741
753
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
742
754
func TestUnpackEvent (t * testing.T ) {
755
+ t .Parallel ()
743
756
const abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"receive","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"}],"name":"receivedAddr","type":"event"}]`
744
757
abi , err := JSON (strings .NewReader (abiJSON ))
745
758
if err != nil {
@@ -778,6 +791,7 @@ func TestUnpackEvent(t *testing.T) {
778
791
}
779
792
780
793
func TestUnpackEventIntoMap (t * testing.T ) {
794
+ t .Parallel ()
781
795
const abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"receive","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"}],"name":"receivedAddr","type":"event"}]`
782
796
abi , err := JSON (strings .NewReader (abiJSON ))
783
797
if err != nil {
@@ -828,6 +842,7 @@ func TestUnpackEventIntoMap(t *testing.T) {
828
842
}
829
843
830
844
func TestUnpackMethodIntoMap (t * testing.T ) {
845
+ t .Parallel ()
831
846
const abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"receive","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"send","outputs":[{"name":"amount","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address"}],"name":"get","outputs":[{"name":"hash","type":"bytes"}],"payable":true,"stateMutability":"payable","type":"function"}]`
832
847
abi , err := JSON (strings .NewReader (abiJSON ))
833
848
if err != nil {
@@ -878,6 +893,7 @@ func TestUnpackMethodIntoMap(t *testing.T) {
878
893
}
879
894
880
895
func TestUnpackIntoMapNamingConflict (t * testing.T ) {
896
+ t .Parallel ()
881
897
// Two methods have the same name
882
898
var abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"get","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"send","outputs":[{"name":"amount","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address"}],"name":"get","outputs":[{"name":"hash","type":"bytes"}],"payable":true,"stateMutability":"payable","type":"function"}]`
883
899
abi , err := JSON (strings .NewReader (abiJSON ))
@@ -961,6 +977,7 @@ func TestUnpackIntoMapNamingConflict(t *testing.T) {
961
977
}
962
978
963
979
func TestABI_MethodById (t * testing.T ) {
980
+ t .Parallel ()
964
981
abi , err := JSON (strings .NewReader (jsondata ))
965
982
if err != nil {
966
983
t .Fatal (err )
@@ -993,6 +1010,7 @@ func TestABI_MethodById(t *testing.T) {
993
1010
}
994
1011
995
1012
func TestABI_EventById (t * testing.T ) {
1013
+ t .Parallel ()
996
1014
tests := []struct {
997
1015
name string
998
1016
json string
@@ -1059,6 +1077,7 @@ func TestABI_EventById(t *testing.T) {
1059
1077
}
1060
1078
1061
1079
func TestABI_ErrorByID (t * testing.T ) {
1080
+ t .Parallel ()
1062
1081
abi , err := JSON (strings .NewReader (`[
1063
1082
{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"MyError1","type":"error"},
1064
1083
{"inputs":[{"components":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"string","name":"b","type":"string"},{"internalType":"address","name":"c","type":"address"}],"internalType":"struct MyError.MyStruct","name":"x","type":"tuple"},{"internalType":"address","name":"y","type":"address"},{"components":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"string","name":"b","type":"string"},{"internalType":"address","name":"c","type":"address"}],"internalType":"struct MyError.MyStruct","name":"z","type":"tuple"}],"name":"MyError2","type":"error"},
@@ -1089,6 +1108,7 @@ func TestABI_ErrorByID(t *testing.T) {
1089
1108
// TestDoubleDuplicateMethodNames checks that if transfer0 already exists, there won't be a name
1090
1109
// conflict and that the second transfer method will be renamed transfer1.
1091
1110
func TestDoubleDuplicateMethodNames (t * testing.T ) {
1111
+ t .Parallel ()
1092
1112
abiJSON := `[{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"value","type":"uint256"}],"name":"transfer","outputs":[{"name":"ok","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"value","type":"uint256"},{"name":"data","type":"bytes"}],"name":"transfer0","outputs":[{"name":"ok","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"value","type":"uint256"},{"name":"data","type":"bytes"},{"name":"customFallback","type":"string"}],"name":"transfer","outputs":[{"name":"ok","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]`
1093
1113
contractAbi , err := JSON (strings .NewReader (abiJSON ))
1094
1114
if err != nil {
@@ -1118,6 +1138,7 @@ func TestDoubleDuplicateMethodNames(t *testing.T) {
1118
1138
// event send();
1119
1139
// }
1120
1140
func TestDoubleDuplicateEventNames (t * testing.T ) {
1141
+ t .Parallel ()
1121
1142
abiJSON := `[{"anonymous": false,"inputs": [{"indexed": false,"internalType": "uint256","name": "a","type": "uint256"}],"name": "send","type": "event"},{"anonymous": false,"inputs": [],"name": "send0","type": "event"},{ "anonymous": false, "inputs": [],"name": "send","type": "event"}]`
1122
1143
contractAbi , err := JSON (strings .NewReader (abiJSON ))
1123
1144
if err != nil {
@@ -1145,6 +1166,7 @@ func TestDoubleDuplicateEventNames(t *testing.T) {
1145
1166
// event send(uint256, uint256);
1146
1167
// }
1147
1168
func TestUnnamedEventParam (t * testing.T ) {
1169
+ t .Parallel ()
1148
1170
abiJSON := `[{ "anonymous": false, "inputs": [{ "indexed": false,"internalType": "uint256", "name": "","type": "uint256"},{"indexed": false,"internalType": "uint256","name": "","type": "uint256"}],"name": "send","type": "event"}]`
1149
1171
contractAbi , err := JSON (strings .NewReader (abiJSON ))
1150
1172
if err != nil {
@@ -1178,7 +1200,9 @@ func TestUnpackRevert(t *testing.T) {
1178
1200
{"4e487b7100000000000000000000000000000000000000000000000000000000000000ff" , "unknown panic code: 0xff" , nil },
1179
1201
}
1180
1202
for index , c := range cases {
1203
+ index , c := index , c
1181
1204
t .Run (fmt .Sprintf ("case %d" , index ), func (t * testing.T ) {
1205
+ t .Parallel ()
1182
1206
got , err := UnpackRevert (common .Hex2Bytes (c .input ))
1183
1207
if c .expectErr != nil {
1184
1208
if err == nil {
0 commit comments