From 57f5595eb515e5320ddb9f09271da22b370bf9e6 Mon Sep 17 00:00:00 2001 From: Terence Tsao Date: Sat, 12 May 2018 15:54:17 -0700 Subject: [PATCH] sharding/proposer: beginning addHeader test Former-commit-id: 02b04a635b1f54c6a6bf76bcfea779a83f0439e7 [formerly 0741baedf7ca864162bf61796242c78adba4cc60] Former-commit-id: 68fe8324ba9bd1f03355632262be1d1e47162505 --- sharding/proposer/proposer_test.go | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/sharding/proposer/proposer_test.go b/sharding/proposer/proposer_test.go index 169819ae4..60b286879 100644 --- a/sharding/proposer/proposer_test.go +++ b/sharding/proposer/proposer_test.go @@ -1 +1,41 @@ package proposer + +import ( + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/sharding/contracts" + "math/big" + "testing" +) + +var ( + key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + addr = crypto.PubkeyToAddress(key.PublicKey) + accountBalance = big.NewInt(1001000000000000000000) +) + +type mockClient struct { + smc *contracts.SMC + t *testing.T +} + +func (m *mockClient) SMCCaller() *contracts.SMCCaller { + return &m.smc.SMCCaller +} + +func (m *mockClient) SMCTransactor() *contracts.SMCTransactor { + return &m.smc.SMCTransactor +} + +func transactOpts() *bind.TransactOpts { + return bind.NewKeyedTransactor(key) +} + +func setup() (*backends.SimulatedBackend, *contracts.SMC) { + backend := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: accountBalance}}) + _, _, smc, _ := contracts.DeploySMC(transactOpts(), backend) + backend.Commit() + return backend, smc +} \ No newline at end of file