Skip to content

Commit dbe1082

Browse files
committed
Add ConstructorWithStructParam test
1 parent 7c60b7e commit dbe1082

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

accounts/abi/bind/bind_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,6 +1854,47 @@ var bindTests = []struct {
18541854
nil,
18551855
nil,
18561856
},
1857+
{
1858+
name: `ConstructorWithStructParam`,
1859+
contract: `
1860+
pragma solidity >=0.8.0 <0.9.0;
1861+
1862+
contract ConstructorWithStructParam {
1863+
struct StructType {
1864+
uint256 field;
1865+
}
1866+
1867+
constructor(StructType memory st) {}
1868+
}
1869+
`,
1870+
bytecode: []string{`0x608060405234801561001057600080fd5b506040516101c43803806101c48339818101604052810190610032919061014a565b50610177565b6000604051905090565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6100958261004c565b810181811067ffffffffffffffff821117156100b4576100b361005d565b5b80604052505050565b60006100c7610038565b90506100d3828261008c565b919050565b6000819050919050565b6100eb816100d8565b81146100f657600080fd5b50565b600081519050610108816100e2565b92915050565b60006020828403121561012457610123610047565b5b61012e60206100bd565b9050600061013e848285016100f9565b60008301525092915050565b6000602082840312156101605761015f610042565b5b600061016e8482850161010e565b91505092915050565b603f806101856000396000f3fe6080604052600080fdfea2646970667358221220cdffa667affecefac5561f65f4a4ba914204a8d4eb859d8cd426fb306e5c12a364736f6c634300080a0033`},
1871+
abi: []string{`[{"inputs":[{"components":[{"internalType":"uint256","name":"field","type":"uint256"}],"internalType":"struct ConstructorWithStructParam.StructType","name":"st","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"}]`},
1872+
imports: `
1873+
"math/big"
1874+
"github.com/kaiachain/kaia/accounts/abi/bind"
1875+
"github.com/kaiachain/kaia/accounts/abi/bind/backends"
1876+
"github.com/kaiachain/kaia/blockchain"
1877+
"github.com/kaiachain/kaia/crypto"
1878+
`,
1879+
tester: `
1880+
var (
1881+
key, _ = crypto.GenerateKey()
1882+
auth = bind.NewKeyedTransactor(key)
1883+
sim = backends.NewSimulatedBackend(blockchain.GenesisAlloc{auth.From: {Balance: big.NewInt(1000000000000000000)}})
1884+
)
1885+
defer sim.Close()
1886+
_, tx, _, err := DeployConstructorWithStructParam(auth, sim, ConstructorWithStructParamStructType{Field: big.NewInt(42)})
1887+
if err != nil {
1888+
t.Fatalf("DeployConstructorWithStructParam() got err %v; want nil err", err)
1889+
}
1890+
sim.Commit()
1891+
1892+
if _, err = bind.WaitDeployed(nil, sim, tx); err != nil {
1893+
t.Logf("Deployment tx: %+v", tx)
1894+
t.Errorf("bind.WaitDeployed(nil, %T, <deployment tx>) got err %v; want nil err", sim, err)
1895+
}
1896+
`,
1897+
},
18571898
{
18581899
name: "RangeKeyword",
18591900
contract: `

0 commit comments

Comments
 (0)