@@ -38,6 +38,7 @@ var bindTests = []struct {
3838 tester string
3939 fsigs []map [string ]string
4040 libs map [string ]string
41+ aliases map [string ]string
4142 types []string
4243}{
4344 // Test that the binding is available in combined and separate forms too
@@ -61,6 +62,7 @@ var bindTests = []struct {
6162 nil ,
6263 nil ,
6364 nil ,
65+ nil ,
6466 },
6567 // Test that all the official sample contracts bind correctly
6668 {
@@ -77,6 +79,7 @@ var bindTests = []struct {
7779 nil ,
7880 nil ,
7981 nil ,
82+ nil ,
8083 },
8184 {
8285 `Crowdsale` ,
@@ -92,6 +95,7 @@ var bindTests = []struct {
9295 nil ,
9396 nil ,
9497 nil ,
98+ nil ,
9599 },
96100 {
97101 `DAO` ,
@@ -107,6 +111,7 @@ var bindTests = []struct {
107111 nil ,
108112 nil ,
109113 nil ,
114+ nil ,
110115 },
111116 // Test that named and anonymous inputs are handled correctly
112117 {
@@ -143,6 +148,7 @@ var bindTests = []struct {
143148 nil ,
144149 nil ,
145150 nil ,
151+ nil ,
146152 },
147153 // Test that named and anonymous outputs are handled correctly
148154 {
@@ -182,6 +188,7 @@ var bindTests = []struct {
182188 nil ,
183189 nil ,
184190 nil ,
191+ nil ,
185192 },
186193 // Tests that named, anonymous and indexed events are handled correctly
187194 {
@@ -250,6 +257,7 @@ var bindTests = []struct {
250257 nil ,
251258 nil ,
252259 nil ,
260+ nil ,
253261 },
254262 // Test that contract interactions (deploy, transact and call) generate working code
255263 {
@@ -311,6 +319,7 @@ var bindTests = []struct {
311319 nil ,
312320 nil ,
313321 nil ,
322+ nil ,
314323 },
315324 // Tests that plain values can be properly returned and deserialized
316325 {
@@ -356,6 +365,7 @@ var bindTests = []struct {
356365 nil ,
357366 nil ,
358367 nil ,
368+ nil ,
359369 },
360370 // Tests that tuples can be properly returned and deserialized
361371 {
@@ -401,6 +411,7 @@ var bindTests = []struct {
401411 nil ,
402412 nil ,
403413 nil ,
414+ nil ,
404415 },
405416 // Tests that arrays/slices can be properly returned and deserialized.
406417 // Only addresses are tested, remainder just compiled to keep the test small.
@@ -458,6 +469,7 @@ var bindTests = []struct {
458469 nil ,
459470 nil ,
460471 nil ,
472+ nil ,
461473 },
462474 // Tests that anonymous default methods can be correctly invoked
463475 {
@@ -508,6 +520,7 @@ var bindTests = []struct {
508520 nil ,
509521 nil ,
510522 nil ,
523+ nil ,
511524 },
512525 // Tests that non-existent contracts are reported as such (though only simulator test)
513526 {
@@ -547,6 +560,7 @@ var bindTests = []struct {
547560 nil ,
548561 nil ,
549562 nil ,
563+ nil ,
550564 },
551565 // Tests that gas estimation works for contracts with weird gas mechanics too.
552566 {
@@ -602,6 +616,7 @@ var bindTests = []struct {
602616 nil ,
603617 nil ,
604618 nil ,
619+ nil ,
605620 },
606621 // Test that constant functions can be called from an (optional) specified address
607622 {
@@ -655,6 +670,7 @@ var bindTests = []struct {
655670 nil ,
656671 nil ,
657672 nil ,
673+ nil ,
658674 },
659675 // Tests that methods and returns with underscores inside work correctly.
660676 {
@@ -734,6 +750,7 @@ var bindTests = []struct {
734750 nil ,
735751 nil ,
736752 nil ,
753+ nil ,
737754 },
738755 // Tests that logs can be successfully filtered and decoded.
739756 {
@@ -955,6 +972,7 @@ var bindTests = []struct {
955972 nil ,
956973 nil ,
957974 nil ,
975+ nil ,
958976 },
959977 {
960978 `DeeplyNestedArray` ,
@@ -1035,6 +1053,7 @@ var bindTests = []struct {
10351053 nil ,
10361054 nil ,
10371055 nil ,
1056+ nil ,
10381057 },
10391058 {
10401059 `CallbackParam` ,
@@ -1076,6 +1095,7 @@ var bindTests = []struct {
10761095 },
10771096 nil ,
10781097 nil ,
1098+ nil ,
10791099 }, {
10801100 `Tuple` ,
10811101 `
@@ -1219,6 +1239,7 @@ var bindTests = []struct {
12191239 nil ,
12201240 nil ,
12211241 nil ,
1242+ nil ,
12221243 },
12231244 {
12241245 `UseLibrary` ,
@@ -1287,6 +1308,7 @@ var bindTests = []struct {
12871308 map [string ]string {
12881309 "b98c933f0a6ececcd167bd4f9d3299b1a0" : "Math" ,
12891310 },
1311+ nil ,
12901312 []string {"UseLibrary" , "Math" },
12911313 }, {
12921314 "Overload" ,
@@ -1381,6 +1403,50 @@ var bindTests = []struct {
13811403 nil ,
13821404 nil ,
13831405 nil ,
1406+ nil ,
1407+ },
1408+ {
1409+ "IdentifierCollision" ,
1410+ `
1411+ pragma solidity >=0.4.19 <0.6.0;
1412+
1413+ contract IdentifierCollision {
1414+ uint public _myVar;
1415+
1416+ function MyVar() public view returns (uint) {
1417+ return _myVar;
1418+ }
1419+ }
1420+ ` ,
1421+ []string {"60806040523480156100115760006000fd5b50610017565b60c3806100256000396000f3fe608060405234801560105760006000fd5b506004361060365760003560e01c806301ad4d8714603c5780634ef1f0ad146058576036565b60006000fd5b60426074565b6040518082815260200191505060405180910390f35b605e607d565b6040518082815260200191505060405180910390f35b60006000505481565b60006000600050549050608b565b9056fea265627a7a7231582067c8d84688b01c4754ba40a2a871cede94ea1f28b5981593ab2a45b46ac43af664736f6c634300050c0032" },
1422+ []string {`[{"constant":true,"inputs":[],"name":"MyVar","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"_myVar","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]` },
1423+ `
1424+ "math/big"
1425+
1426+ "github.com/ethereum/go-ethereum/accounts/abi/bind"
1427+ "github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
1428+ "github.com/ethereum/go-ethereum/crypto"
1429+ "github.com/ethereum/go-ethereum/core"
1430+ ` ,
1431+ `
1432+ // Initialize test accounts
1433+ key, _ := crypto.GenerateKey()
1434+ addr := crypto.PubkeyToAddress(key.PublicKey)
1435+
1436+ // Deploy registrar contract
1437+ sim := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}}, 10000000)
1438+ defer sim.Close()
1439+
1440+ transactOpts := bind.NewKeyedTransactor(key)
1441+ _, _, _, err := DeployIdentifierCollision(transactOpts, sim)
1442+ if err != nil {
1443+ t.Fatalf("failed to deploy contract: %v", err)
1444+ }
1445+ ` ,
1446+ nil ,
1447+ nil ,
1448+ map [string ]string {"_myVar" : "pubVar" }, // alias MyVar to PubVar
1449+ nil ,
13841450 },
13851451}
13861452
@@ -1412,7 +1478,7 @@ func TestGolangBindings(t *testing.T) {
14121478 types = []string {tt .name }
14131479 }
14141480 // Generate the binding and create a Go source file in the workspace
1415- bind , err := Bind (types , tt .abi , tt .bytecode , tt .fsigs , "bindtest" , LangGo , tt .libs )
1481+ bind , err := Bind (types , tt .abi , tt .bytecode , tt .fsigs , "bindtest" , LangGo , tt .libs , tt . aliases )
14161482 if err != nil {
14171483 t .Fatalf ("test %d: failed to generate binding: %v" , i , err )
14181484 }
@@ -1835,7 +1901,7 @@ public class Test {
18351901 },
18361902 }
18371903 for i , c := range cases {
1838- binding , err := Bind ([]string {c .name }, []string {c .abi }, []string {c .bytecode }, nil , "bindtest" , LangJava , nil )
1904+ binding , err := Bind ([]string {c .name }, []string {c .abi }, []string {c .bytecode }, nil , "bindtest" , LangJava , nil , nil )
18391905 if err != nil {
18401906 t .Fatalf ("test %d: failed to generate binding: %v" , i , err )
18411907 }
0 commit comments