accounts/abi/bind: remove test case UseLibrary

This commit is contained in:
Daniel Liu 2024-12-13 17:07:00 +08:00
parent 993bc6963e
commit d6957d9283

View file

@ -1033,74 +1033,6 @@ var bindTests = []struct {
nil,
nil,
},
{
`UseLibrary`,
`
library Math {
function add(uint a, uint b) public view returns(uint) {
return a + b;
}
}
contract UseLibrary {
function add (uint c, uint d) public view returns(uint) {
return Math.add(c,d);
}
}
`,
[]string{
// Bytecode for the UseLibrary contract
`608060405234801561001057600080fd5b5061011d806100206000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063771602f714602d575b600080fd5b604d60048036036040811015604157600080fd5b5080359060200135605f565b60408051918252519081900360200190f35b600073__$b98c933f0a6ececcd167bd4f9d3299b1a0$__63771602f784846040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b15801560b757600080fd5b505af415801560ca573d6000803e3d6000fd5b505050506040513d602081101560df57600080fd5b5051939250505056fea265627a7a72305820eb5c38f42445604cfa43d85e3aa5ecc48b0a646456c902dd48420ae7241d06f664736f6c63430005090032`,
// Bytecode for the Math contract
`60a3610024600b82828239805160001a607314601757fe5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361060335760003560e01c8063771602f7146038575b600080fd5b605860048036036040811015604c57600080fd5b5080359060200135606a565b60408051918252519081900360200190f35b019056fea265627a7a723058206fc6c05f3078327f9c763edffdb5ab5f8bd212e293a1306c7d0ad05af3ad35f464736f6c63430005090032`,
},
[]string{
`[{"constant":true,"inputs":[{"name":"c","type":"uint256"},{"name":"d","type":"uint256"}],"name":"add","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]`,
`[{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"add","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]`,
},
`
"math/big"
"github.com/XinFinOrg/XDPoSChain/accounts/abi/bind"
"github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends"
"github.com/XinFinOrg/XDPoSChain/core"
"github.com/XinFinOrg/XDPoSChain/crypto"
"github.com/XinFinOrg/XDPoSChain/params"
`,
`
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
sim := backends.NewXDCSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000, params.TestXDPoSMockChainConfig)
// Deploy the test contract
_, _, testContract, err := DeployUseLibrary(auth, sim)
if err != nil {
t.Fatalf("Failed to deploy test contract: %v", err)
}
// Finish deploy.
sim.Commit()
// Check that the library contract has been deployed
// by calling the contract's add function.
res, err := testContract.Add(&bind.CallOpts{
From: auth.From,
Pending: false,
}, big.NewInt(1), big.NewInt(2))
if err != nil {
t.Fatalf("Failed to call linked contract: %v", err)
}
if res.Cmp(big.NewInt(3)) != 0 {
t.Fatalf("Add did not return the correct result: %d != %d", res, 3)
}
`,
nil,
map[string]string{
"b98c933f0a6ececcd167bd4f9d3299b1a0": "Math",
},
[]string{"UseLibrary", "Math"},
},
}
// Tests that packages generated by the binder can be successfully compiled and