aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/abi/bind/bind_test.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2019-07-31 17:07:03 +0800
committerGitHub <noreply@github.com>2019-07-31 17:07:03 +0800
commit7f3362595a3bdf1c27b17f16b7d90d89882312ab (patch)
tree7497a593073b3ff03212945efe731c103e75e9ca /accounts/abi/bind/bind_test.go
parent96ab8e1575bb5e3a12a70dc6f349f4baa32f710a (diff)
parent140a7e91778447e058c1811103037437b2091c6e (diff)
downloadgo-tangerine-7f3362595a3bdf1c27b17f16b7d90d89882312ab.tar
go-tangerine-7f3362595a3bdf1c27b17f16b7d90d89882312ab.tar.gz
go-tangerine-7f3362595a3bdf1c27b17f16b7d90d89882312ab.tar.bz2
go-tangerine-7f3362595a3bdf1c27b17f16b7d90d89882312ab.tar.lz
go-tangerine-7f3362595a3bdf1c27b17f16b7d90d89882312ab.tar.xz
go-tangerine-7f3362595a3bdf1c27b17f16b7d90d89882312ab.tar.zst
go-tangerine-7f3362595a3bdf1c27b17f16b7d90d89882312ab.zip
Merge pull request #19902 from karalabe/simulated-close
accounts/abi/bind: support closing a simulated backend
Diffstat (limited to 'accounts/abi/bind/bind_test.go')
-rw-r--r--accounts/abi/bind/bind_test.go40
1 files changed, 33 insertions, 7 deletions
diff --git a/accounts/abi/bind/bind_test.go b/accounts/abi/bind/bind_test.go
index f11966c81..5588b2431 100644
--- a/accounts/abi/bind/bind_test.go
+++ b/accounts/abi/bind/bind_test.go
@@ -282,7 +282,9 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
+
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
+ defer sim.Close()
// Deploy an interaction tester contract and call a transaction on it
_, _, interactor, err := DeployInteractor(auth, sim, "Deploy string")
@@ -334,7 +336,9 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
+
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
+ defer sim.Close()
// Deploy a tuple tester contract and execute a structured call on it
_, _, getter, err := DeployGetter(auth, sim)
@@ -377,7 +381,9 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
+
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
+ defer sim.Close()
// Deploy a tuple tester contract and execute a structured call on it
_, _, tupler, err := DeployTupler(auth, sim)
@@ -432,7 +438,9 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
+
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
+ defer sim.Close()
// Deploy a slice tester contract and execute a n array call on it
_, _, slicer, err := DeploySlicer(auth, sim)
@@ -477,7 +485,9 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
+
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
+ defer sim.Close()
// Deploy a default method invoker contract and execute its default method
_, _, defaulter, err := DeployDefaulter(auth, sim)
@@ -519,7 +529,9 @@ var bindTests = []struct {
`,
`
// Create a simulator and wrap a non-deployed contract
+
sim := backends.NewSimulatedBackend(core.GenesisAlloc{}, uint64(10000000000))
+ defer sim.Close()
nonexistent, err := NewNonExistent(common.Address{}, sim)
if err != nil {
@@ -566,7 +578,9 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
+
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
+ defer sim.Close()
// Deploy a funky gas pattern contract
_, _, limiter, err := DeployFunkyGasPattern(auth, sim)
@@ -613,7 +627,9 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
+
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
+ defer sim.Close()
// Deploy a sender tester contract and execute a structured call on it
_, _, callfrom, err := DeployCallFrom(auth, sim)
@@ -685,7 +701,9 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
+
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
+ defer sim.Close()
// Deploy a underscorer tester contract and execute a structured call on it
_, _, underscorer, err := DeployUnderscorer(auth, sim)
@@ -776,7 +794,9 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
+
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
+ defer sim.Close()
// Deploy an eventer contract
_, _, eventer, err := DeployEventer(auth, sim)
@@ -963,7 +983,9 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
+
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
+ defer sim.Close()
//deploy the test contract
_, _, testContract, err := DeployDeeplyNestedArray(auth, sim)
@@ -1059,12 +1081,12 @@ var bindTests = []struct {
`
pragma solidity >=0.4.19 <0.6.0;
pragma experimental ABIEncoderV2;
-
+
contract Tuple {
struct S { uint a; uint[] b; T[] c; }
struct T { uint x; uint y; }
event TupleEvent(S a, T[2][] b, T[][2] c, S[] d, uint[] e);
-
+
function func1(S memory a, T[2][] memory b, T[][2] memory c, S[] memory d, uint[] memory e) public pure returns (S memory, T[2][] memory, T[][2] memory, S[] memory, uint[] memory) {
return (a, b, c, d, e);
}
@@ -1081,7 +1103,7 @@ var bindTests = []struct {
`
"math/big"
"reflect"
-
+
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/core"
@@ -1091,13 +1113,15 @@ var bindTests = []struct {
`
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
- backend := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
- _, _, contract, err := DeployTuple(auth, backend)
+ sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
+ defer sim.Close()
+
+ _, _, contract, err := DeployTuple(auth, sim)
if err != nil {
t.Fatalf("deploy contract failed %v", err)
}
- backend.Commit()
+ sim.Commit()
check := func(a, b interface{}, errMsg string) {
if !reflect.DeepEqual(a, b) {
@@ -1169,7 +1193,7 @@ var bindTests = []struct {
if err != nil {
t.Fatalf("invoke contract failed, err %v", err)
}
- backend.Commit()
+ sim.Commit()
iter, err := contract.FilterTupleEvent(nil)
if err != nil {
@@ -1225,7 +1249,9 @@ var bindTests = []struct {
// Generate a new random account and a funded simulator
key, _ := crypto.GenerateKey()
auth := bind.NewKeyedTransactor(key)
+
sim := backends.NewSimulatedBackend(core.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000)}}, 10000000)
+ defer sim.Close()
//deploy the test contract
_, _, testContract, err := DeployUseLibrary(auth, sim)