From 0ac606408877f4a56a8c9f9d6341f6cc67e28cc9 Mon Sep 17 00:00:00 2001 From: Alan Chen Date: Thu, 7 Sep 2017 11:30:30 +0800 Subject: [PATCH] client, container, tests/*: integrate ethclient with Istanbul client --- {istclient => client}/client.go | 11 +- {istclient => client}/client_test.go | 2 +- client/ethclient.go | 200 ++++++++++++++++++ container/blockchain.go | 4 +- container/container.go | 2 +- container/ethereum.go | 81 +++---- tests/functional/block_sync_test.go | 2 +- tests/functional/dynamic_test.go | 18 +- tests/functional/general_consensus_test.go | 4 +- tests/functional/gossip_network_test.go | 2 +- tests/quorum/functional/block_sync_test.go | 2 +- tests/quorum/functional/dynamic_test.go | 18 +- .../functional/general_consensus_test.go | 4 +- .../quorum/functional/gossip_network_test.go | 2 +- 14 files changed, 268 insertions(+), 84 deletions(-) rename {istclient => client}/client.go (95%) rename {istclient => client}/client_test.go (99%) create mode 100644 client/ethclient.go diff --git a/istclient/client.go b/client/client.go similarity index 95% rename from istclient/client.go rename to client/client.go index a3f5512e..51776b32 100644 --- a/istclient/client.go +++ b/client/client.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see . -package istclient +package client import ( "context" @@ -27,10 +27,12 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/rpc" + "github.com/getamis/go-ethereum/ethclient" ) type Client struct { - c *rpc.Client + c *rpc.Client + ethClient *ethclient.Client } func Dial(rawurl string) (*Client, error) { @@ -38,7 +40,10 @@ func Dial(rawurl string) (*Client, error) { if err != nil { return nil, err } - return &Client{c}, nil + return &Client{ + c: c, + ethClient: ethclient.NewClient(c), + }, nil } func (c *Client) Close() { diff --git a/istclient/client_test.go b/client/client_test.go similarity index 99% rename from istclient/client_test.go rename to client/client_test.go index 952232bb..84529817 100644 --- a/istclient/client_test.go +++ b/client/client_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see . -package istclient +package client import ( "context" diff --git a/client/ethclient.go b/client/ethclient.go new file mode 100644 index 00000000..4ce01839 --- /dev/null +++ b/client/ethclient.go @@ -0,0 +1,200 @@ +// Copyright 2017 AMIS Technologies +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package client + +import ( + "context" + "math/big" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" +) + +// Blockchain Access + +// BlockByHash returns the given full block. +// +// Note that loading full blocks requires two requests. Use HeaderByHash +// if you don't need all transactions or uncle headers. +func (c *Client) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) { + return c.ethClient.BlockByHash(ctx, hash) +} + +// BlockByNumber returns a block from the current canonical chain. If number is nil, the +// latest known block is returned. +// +// Note that loading full blocks requires two requests. Use HeaderByNumber +// if you don't need all transactions or uncle headers. +func (c *Client) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error) { + return c.ethClient.BlockByNumber(ctx, number) +} + +// HeaderByHash returns the block header with the given hash. +func (c *Client) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) { + return c.ethClient.HeaderByHash(ctx, hash) +} + +// HeaderByNumber returns a block header from the current canonical chain. If number is +// nil, the latest known header is returned. +func (c *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) { + return c.ethClient.HeaderByNumber(ctx, number) +} + +// TransactionByHash returns the transaction with the given hash. +func (c *Client) TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error) { + return c.ethClient.TransactionByHash(ctx, hash) +} + +// TransactionCount returns the total number of transactions in the given block. +func (c *Client) TransactionCount(ctx context.Context, blockHash common.Hash) (uint, error) { + return c.ethClient.TransactionCount(ctx, blockHash) +} + +// TransactionInBlock returns a single transaction at index in the given block. +func (c *Client) TransactionInBlock(ctx context.Context, blockHash common.Hash, index uint) (*types.Transaction, error) { + return c.ethClient.TransactionInBlock(ctx, blockHash, index) +} + +// TransactionReceipt returns the receipt of a transaction by transaction hash. +// Note that the receipt is not available for pending transactions. +func (c *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) { + return c.ethClient.TransactionReceipt(ctx, txHash) +} + +// SyncProgress retrieves the current progress of the sync algorithm. If there's +// no sync currently running, it returns nil. +func (c *Client) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error) { + return c.ethClient.SyncProgress(ctx) +} + +// SubscribeNewHead subscribes to notifications about the current blockchain head +// on the given channel. +func (c *Client) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error) { + return c.ethClient.SubscribeNewHead(ctx, ch) +} + +// State Access + +// NetworkID returns the network ID (also known as the chain ID) for this chain. +func (c *Client) NetworkID(ctx context.Context) (*big.Int, error) { + return c.ethClient.NetworkID(ctx) +} + +// BalanceAt returns the wei balance of the given account. +// The block number can be nil, in which case the balance is taken from the latest known block. +func (c *Client) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error) { + return c.ethClient.BalanceAt(ctx, account, blockNumber) +} + +// StorageAt returns the value of key in the contract storage of the given account. +// The block number can be nil, in which case the value is taken from the latest known block. +func (c *Client) StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error) { + return c.ethClient.StorageAt(ctx, account, key, blockNumber) +} + +// CodeAt returns the contract code of the given account. +// The block number can be nil, in which case the code is taken from the latest known block. +func (c *Client) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error) { + return c.ethClient.CodeAt(ctx, account, blockNumber) +} + +// NonceAt returns the account nonce of the given account. +// The block number can be nil, in which case the nonce is taken from the latest known block. +func (c *Client) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error) { + return c.ethClient.NonceAt(ctx, account, blockNumber) +} + +// Filters + +// FilterLogs executes a filter query. +func (c *Client) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error) { + return c.ethClient.FilterLogs(ctx, q) +} + +// SubscribeFilterLogs subscribes to the results of a streaming filter query. +func (c *Client) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) { + return c.ethClient.SubscribeFilterLogs(ctx, q, ch) +} + +// Pending State + +// PendingBalanceAt returns the wei balance of the given account in the pending state. +func (c *Client) PendingBalanceAt(ctx context.Context, account common.Address) (*big.Int, error) { + return c.ethClient.PendingBalanceAt(ctx, account) +} + +// PendingStorageAt returns the value of key in the contract storage of the given account in the pending state. +func (c *Client) PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error) { + return c.ethClient.PendingStorageAt(ctx, account, key) +} + +// PendingCodeAt returns the contract code of the given account in the pending state. +func (c *Client) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error) { + return c.ethClient.PendingCodeAt(ctx, account) +} + +// PendingNonceAt returns the account nonce of the given account in the pending state. +// This is the nonce that should be used for the next transaction. +func (c *Client) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) { + return c.ethClient.PendingNonceAt(ctx, account) +} + +// PendingTransactionCount returns the total number of transactions in the pending state. +func (c *Client) PendingTransactionCount(ctx context.Context) (uint, error) { + return c.ethClient.PendingTransactionCount(ctx) +} + +// Contract Calling + +// CallContract executes a message call transaction, which is directly executed in the VM +// of the node, but never mined into the blockchain. +// +// blockNumber selects the block height at which the call runs. It can be nil, in which +// case the code is taken from the latest known block. Note that state from very old +// blocks might not be available. +func (c *Client) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) { + return c.ethClient.CallContract(ctx, msg, blockNumber) +} + +// PendingCallContract executes a message call transaction using the EVM. +// The state seen by the contract call is the pending state. +func (c *Client) PendingCallContract(ctx context.Context, msg ethereum.CallMsg) ([]byte, error) { + return c.ethClient.PendingCallContract(ctx, msg) +} + +// SuggestGasPrice retrieves the currently suggested gas price to allow a timely +// execution of a transaction. +func (c *Client) SuggestGasPrice(ctx context.Context) (*big.Int, error) { + return c.ethClient.SuggestGasPrice(ctx) +} + +// EstimateGas tries to estimate the gas needed to execute a specific transaction based on +// the current pending state of the backend blockchain. There is no guarantee that this is +// the true gas limit requirement as other transactions may be added or removed by miners, +// but it should provide a basis for setting a reasonable default. +func (c *Client) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (*big.Int, error) { + return c.ethClient.EstimateGas(ctx, msg) +} + +// SendTransaction injects a signed transaction into the pending pool for execution. +// +// If the transaction was a contract creation use the TransactionReceipt method to get the +// contract address after the transaction has been mined. +func (c *Client) SendTransaction(ctx context.Context, tx *types.Transaction) error { + return c.ethClient.SendTransaction(ctx, tx) +} diff --git a/container/blockchain.go b/container/blockchain.go index 4e99e2c7..80653e9d 100644 --- a/container/blockchain.go +++ b/container/blockchain.go @@ -220,7 +220,7 @@ func (bc *blockchain) AddValidators(numOfValidators int) ([]Ethereum, error) { // propose new validators as validator in consensus for _, v := range bc.validators[:lastLen] { - istClient := v.NewIstanbulClient() + istClient := v.NewClient() for _, newV := range newValidators { if err := istClient.ProposeValidator(context.Background(), newV.Address(), true); err != nil { return nil, err @@ -259,7 +259,7 @@ func (bc *blockchain) RemoveValidators(candidates []Ethereum, processingTime tim var newValidators []Ethereum for _, v := range bc.validators { - istClient := v.NewIstanbulClient() + istClient := v.NewClient() isFound := false for _, c := range candidates { if err := istClient.ProposeValidator(context.Background(), c.Address(), false); err != nil { diff --git a/container/container.go b/container/container.go index dba3ebdc..e53b9c17 100644 --- a/container/container.go +++ b/container/container.go @@ -35,7 +35,7 @@ func (eth *ethereum) ContainerID() string { func (eth *ethereum) Host() string { var host string - daemonHost := eth.client.DaemonHost() + daemonHost := eth.dockerClient.DaemonHost() url, err := url.Parse(daemonHost) if err != nil { log.Printf("Failed to parse daemon host, err: %v", err) diff --git a/container/ethereum.go b/container/ethereum.go index fdc7fab5..ccf0d68c 100644 --- a/container/ethereum.go +++ b/container/ethereum.go @@ -34,18 +34,17 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/network" - "github.com/docker/docker/client" + docker "github.com/docker/docker/client" "github.com/docker/go-connections/nat" "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/p2p/discover" + "github.com/getamis/istanbul-tools/client" istcommon "github.com/getamis/istanbul-tools/common" "github.com/getamis/istanbul-tools/genesis" - "github.com/getamis/istanbul-tools/istclient" ) const ( @@ -68,8 +67,7 @@ type Ethereum interface { ContainerID() string Host() string - NewClient() *ethclient.Client - NewIstanbulClient() *istclient.Client + NewClient() *client.Client ConsensusMonitor(err chan<- error, quit chan struct{}) WaitForProposed(expectedAddress common.Address, t time.Duration) error @@ -88,9 +86,9 @@ type Ethereum interface { DockerBinds() []string } -func NewEthereum(c *client.Client, options ...Option) *ethereum { +func NewEthereum(c *docker.Client, options ...Option) *ethereum { eth := ðereum{ - client: c, + dockerClient: c, } for _, opt := range options { @@ -105,7 +103,7 @@ func NewEthereum(c *client.Client, options ...Option) *ethereum { }) if len(images) == 0 || err != nil { - out, err := eth.client.ImagePull(context.Background(), eth.Image(), types.ImagePullOptions{}) + out, err := eth.dockerClient.ImagePull(context.Background(), eth.Image(), types.ImagePullOptions{}) if err != nil { log.Printf("Cannot pull %s, err: %v", eth.Image(), err) return nil @@ -141,9 +139,9 @@ type ethereum struct { imageTag string dockerNetworkName string - key *ecdsa.PrivateKey - logging bool - client *client.Client + key *ecdsa.PrivateKey + logging bool + dockerClient *docker.Client } func (eth *ethereum) Init(genesisFile string) error { @@ -159,7 +157,7 @@ func (eth *ethereum) Init(genesisFile string) error { binds = append(binds, eth.dataDir+":"+utils.DataDirFlag.Value.Value) } - resp, err := eth.client.ContainerCreate(context.Background(), + resp, err := eth.dockerClient.ContainerCreate(context.Background(), &container.Config{ Image: eth.Image(), Cmd: []string{ @@ -179,12 +177,12 @@ func (eth *ethereum) Init(genesisFile string) error { id := resp.ID - if err := eth.client.ContainerStart(context.Background(), id, types.ContainerStartOptions{}); err != nil { + if err := eth.dockerClient.ContainerStart(context.Background(), id, types.ContainerStartOptions{}); err != nil { log.Printf("Failed to start container, err: %v", err) return err } - resC, errC := eth.client.ContainerWait(context.Background(), id, container.WaitConditionNotRunning) + resC, errC := eth.dockerClient.ContainerWait(context.Background(), id, container.WaitConditionNotRunning) select { case <-resC: case <-errC: @@ -196,7 +194,7 @@ func (eth *ethereum) Init(genesisFile string) error { eth.showLog(context.Background()) } - return eth.client.ContainerRemove(context.Background(), id, types.ContainerRemoveOptions{Force: true}) + return eth.dockerClient.ContainerRemove(context.Background(), id, types.ContainerRemoveOptions{Force: true}) } func (eth *ethereum) Start() error { @@ -250,7 +248,7 @@ func (eth *ethereum) Start() error { } } - resp, err := eth.client.ContainerCreate(context.Background(), + resp, err := eth.dockerClient.ContainerCreate(context.Background(), &container.Config{ Hostname: "geth-" + eth.hostName, Image: eth.Image(), @@ -269,7 +267,7 @@ func (eth *ethereum) Start() error { eth.containerID = resp.ID - err = eth.client.ContainerStart(context.Background(), eth.containerID, types.ContainerStartOptions{}) + err = eth.dockerClient.ContainerStart(context.Background(), eth.containerID, types.ContainerStartOptions{}) if err != nil { log.Printf("Failed to start container, err: %v, ip:%v", err, eth.ip) return err @@ -297,7 +295,7 @@ func (eth *ethereum) Start() error { containerIP := eth.ip if containerIP == "" { - containerJSON, err := eth.client.ContainerInspect(context.Background(), eth.containerID) + containerJSON, err := eth.dockerClient.ContainerInspect(context.Background(), eth.containerID) if err != nil { log.Print("Failed to inspect container,", err) return err @@ -317,7 +315,7 @@ func (eth *ethereum) Start() error { } func (eth *ethereum) Stop() error { - err := eth.client.ContainerStop(context.Background(), eth.containerID, nil) + err := eth.dockerClient.ContainerStop(context.Background(), eth.containerID, nil) if err != nil { fmt.Printf("error on stop container:%v", err) return err @@ -325,7 +323,7 @@ func (eth *ethereum) Stop() error { defer os.RemoveAll(eth.dataDir) - return eth.client.ContainerRemove(context.Background(), eth.containerID, + return eth.dockerClient.ContainerRemove(context.Background(), eth.containerID, types.ContainerRemoveOptions{ Force: true, }) @@ -334,12 +332,12 @@ func (eth *ethereum) Stop() error { func (eth *ethereum) Wait(t time.Duration) error { ctx, cancel := context.WithTimeout(context.Background(), t) defer cancel() - _, errCh := eth.client.ContainerWait(ctx, eth.containerID, "") + _, errCh := eth.dockerClient.ContainerWait(ctx, eth.containerID, "") return <-errCh } func (eth *ethereum) Running() bool { - containers, err := eth.client.ContainerList(context.Background(), types.ContainerListOptions{}) + containers, err := eth.dockerClient.ContainerList(context.Background(), types.ContainerListOptions{}) if err != nil { log.Printf("Failed to list containers, err: %v", err) return false @@ -354,7 +352,7 @@ func (eth *ethereum) Running() bool { return false } -func (eth *ethereum) NewClient() *ethclient.Client { +func (eth *ethereum) NewClient() *client.Client { var scheme, port string if eth.rpcPort != "" { @@ -365,26 +363,7 @@ func (eth *ethereum) NewClient() *ethclient.Client { scheme = "ws://" port = eth.wsPort } - client, err := ethclient.Dial(scheme + eth.Host() + ":" + port) - if err != nil { - log.Printf("Failed to dial eth client, err: %v\n", err) - return nil - } - return client -} - -func (eth *ethereum) NewIstanbulClient() *istclient.Client { - var scheme, port string - - if eth.rpcPort != "" { - scheme = "http://" - port = eth.rpcPort - } - if eth.wsPort != "" { - scheme = "ws://" - port = eth.wsPort - } - client, err := istclient.Dial(scheme + eth.Host() + ":" + port) + client, err := client.Dial(scheme + eth.Host() + ":" + port) if err != nil { return nil } @@ -477,7 +456,7 @@ func (eth *ethereum) WaitForProposed(expectedAddress common.Address, timeout tim } func (eth *ethereum) WaitForPeersConnected(expectedPeercount int) error { - client := eth.NewIstanbulClient() + client := eth.NewClient() if client == nil { return errors.New("failed to retrieve client") } @@ -503,7 +482,7 @@ func (eth *ethereum) WaitForPeersConnected(expectedPeercount int) error { func (eth *ethereum) WaitForBlocks(num int, waitingTime ...time.Duration) error { var first *big.Int - client := eth.NewIstanbulClient() + client := eth.NewClient() if client == nil { return errors.New("failed to retrieve client") } @@ -542,7 +521,7 @@ func (eth *ethereum) WaitForBlocks(num int, waitingTime ...time.Duration) error } func (eth *ethereum) WaitForBlockHeight(num int) error { - client := eth.NewIstanbulClient() + client := eth.NewClient() if client == nil { return errors.New("failed to retrieve client") } @@ -566,7 +545,7 @@ func (eth *ethereum) WaitForBlockHeight(num int) error { func (eth *ethereum) WaitForNoBlocks(num int, duration time.Duration) error { var first *big.Int - client := eth.NewIstanbulClient() + client := eth.NewClient() if client == nil { return errors.New("failed to retrieve client") } @@ -595,7 +574,7 @@ func (eth *ethereum) WaitForNoBlocks(num int, duration time.Duration) error { } func (eth *ethereum) AddPeer(address string) error { - client := eth.NewIstanbulClient() + client := eth.NewClient() if client == nil { return errors.New("failed to retrieve client") } @@ -605,7 +584,7 @@ func (eth *ethereum) AddPeer(address string) error { } func (eth *ethereum) StartMining() error { - client := eth.NewIstanbulClient() + client := eth.NewClient() if client == nil { return errors.New("failed to retrieve client") } @@ -615,7 +594,7 @@ func (eth *ethereum) StartMining() error { } func (eth *ethereum) StopMining() error { - client := eth.NewIstanbulClient() + client := eth.NewClient() if client == nil { return errors.New("failed to retrieve client") } @@ -635,7 +614,7 @@ func (eth *ethereum) DockerBinds() []string { // ---------------------------------------------------------------------------- func (eth *ethereum) showLog(context context.Context) { - if readCloser, err := eth.client.ContainerLogs(context, eth.containerID, + if readCloser, err := eth.dockerClient.ContainerLogs(context, eth.containerID, types.ContainerLogsOptions{ShowStderr: true, Follow: true}); err == nil { defer readCloser.Close() _, err = io.Copy(os.Stdout, readCloser) diff --git a/tests/functional/block_sync_test.go b/tests/functional/block_sync_test.go index c642ef9e..17065ea9 100644 --- a/tests/functional/block_sync_test.go +++ b/tests/functional/block_sync_test.go @@ -108,7 +108,7 @@ var _ = Describe("Block synchronization testing", func() { By("Stop consensus", func() { for _, v := range blockchain.Validators() { - client := v.NewIstanbulClient() + client := v.NewClient() Expect(client).NotTo(BeNil()) err := client.StopMining(context.Background()) Expect(err).To(BeNil()) diff --git a/tests/functional/dynamic_test.go b/tests/functional/dynamic_test.go index bb15d9ae..1dfa8139 100644 --- a/tests/functional/dynamic_test.go +++ b/tests/functional/dynamic_test.go @@ -52,7 +52,7 @@ var _ = Describe("TFS-02: Dynamic validators addition/removal testing", func() { By("Ensure the number of validators is correct", func() { for _, v := range blockchain.Validators() { - client := v.NewIstanbulClient() + client := v.NewClient() validators, err := client.GetValidators(context.Background(), nil) Expect(err).Should(BeNil()) Expect(len(validators)).Should(BeNumerically("==", numberOfValidators)) @@ -73,7 +73,7 @@ var _ = Describe("TFS-02: Dynamic validators addition/removal testing", func() { By("Ensure the number of validators is correct", func() { for _, v := range blockchain.Validators() { - client := v.NewIstanbulClient() + client := v.NewClient() validators, err := client.GetValidators(context.Background(), nil) Expect(err).Should(BeNil()) Expect(len(validators)).Should(BeNumerically("==", numberOfValidators+testValidators)) @@ -98,7 +98,7 @@ var _ = Describe("TFS-02: Dynamic validators addition/removal testing", func() { By("Ensure that numbers of validator is equal to $numberOfValidators", func() { for _, v := range blockchain.Validators() { - client := v.NewIstanbulClient() + client := v.NewClient() validators, err := client.GetValidators(context.Background(), nil) Expect(err).Should(BeNil()) Expect(len(validators)).Should(BeNumerically("==", numberOfValidators)) @@ -116,7 +116,7 @@ var _ = Describe("TFS-02: Dynamic validators addition/removal testing", func() { By("Check if the number of validators is correct", func() { for _, v := range blockchain.Validators() { - client := v.NewIstanbulClient() + client := v.NewClient() validators, err := client.GetValidators(context.Background(), nil) Expect(err).Should(BeNil()) Expect(len(validators)).Should(BeNumerically("==", numberOfValidators+numOfCandidates)) @@ -136,7 +136,7 @@ var _ = Describe("TFS-02: Dynamic validators addition/removal testing", func() { By("Check if the number of validators is correct", func() { for _, v := range blockchain.Validators() { - client := v.NewIstanbulClient() + client := v.NewClient() validators, err := client.GetValidators(context.Background(), nil) Expect(err).Should(BeNil()) Expect(len(validators)).Should(BeNumerically("==", numberOfValidators)) @@ -160,14 +160,14 @@ var _ = Describe("TFS-02: Dynamic validators addition/removal testing", func() { // stop validators [3] stopCandidates := blockchain.Validators()[numberOfValidators-1:] for _, candidates := range stopCandidates { - c := candidates.NewIstanbulClient() + c := candidates.NewClient() Expect(c.StopMining(context.Background())).Should(BeNil()) } }) By("Verify number of validators", func() { for _, v := range blockchain.Validators() { - client := v.NewIstanbulClient() + client := v.NewClient() validators, err := client.GetValidators(context.Background(), nil) Expect(err).Should(BeNil()) Expect(len(validators)).Should(BeNumerically("==", numberOfValidators)) @@ -194,14 +194,14 @@ var _ = Describe("TFS-02: Dynamic validators addition/removal testing", func() { stopCandidates := blockchain.Validators()[numberOfValidators-2:] // stop validators [3,4] for _, candidates := range stopCandidates { - c := candidates.NewIstanbulClient() + c := candidates.NewClient() Expect(c.StopMining(context.Background())).Should(BeNil()) } }) By("Verify number of validators", func() { for _, v := range blockchain.Validators() { - client := v.NewIstanbulClient() + client := v.NewClient() validators, err := client.GetValidators(context.Background(), nil) Expect(err).Should(BeNil()) Expect(len(validators)).Should(BeNumerically("==", numberOfValidators)) diff --git a/tests/functional/general_consensus_test.go b/tests/functional/general_consensus_test.go index f349e58a..b97a549e 100644 --- a/tests/functional/general_consensus_test.go +++ b/tests/functional/general_consensus_test.go @@ -87,7 +87,7 @@ var _ = Describe("TFS-01: General consensus", func() { } // 2. Check validator set - istClient := geth.NewIstanbulClient() + istClient := geth.NewClient() vals, err := istClient.GetValidators(context.Background(), big.NewInt(0)) if err != nil { errc <- err @@ -191,7 +191,7 @@ var _ = Describe("TFS-01: General consensus", func() { for _, geth := range blockchain.Validators() { go func(geth container.Ethereum) { c := geth.NewClient() - istClient := geth.NewIstanbulClient() + istClient := geth.NewClient() // get initial validator set vals, err := istClient.GetValidators(context.Background(), big.NewInt(0)) diff --git a/tests/functional/gossip_network_test.go b/tests/functional/gossip_network_test.go index a0e41d85..588ede7c 100644 --- a/tests/functional/gossip_network_test.go +++ b/tests/functional/gossip_network_test.go @@ -48,7 +48,7 @@ var _ = Describe("TFS-07: Gossip Network", func() { It("TFS-07-01: Gossip Network", func(done Done) { By("Check peer count", func() { for _, geth := range blockchain.Validators() { - c := geth.NewIstanbulClient() + c := geth.NewClient() peers, e := c.AdminPeers(context.Background()) Expect(e).To(BeNil()) Ω(len(peers)).Should(BeNumerically("<=", 2)) diff --git a/tests/quorum/functional/block_sync_test.go b/tests/quorum/functional/block_sync_test.go index 6cae463a..bf714e19 100644 --- a/tests/quorum/functional/block_sync_test.go +++ b/tests/quorum/functional/block_sync_test.go @@ -113,7 +113,7 @@ var _ = Describe("Block synchronization testing", func() { By("Stop consensus", func() { for _, v := range blockchain.Validators() { - client := v.NewIstanbulClient() + client := v.NewClient() Expect(client).NotTo(BeNil()) err := client.StopMining(context.Background()) Expect(err).To(BeNil()) diff --git a/tests/quorum/functional/dynamic_test.go b/tests/quorum/functional/dynamic_test.go index 68fb726f..58056073 100644 --- a/tests/quorum/functional/dynamic_test.go +++ b/tests/quorum/functional/dynamic_test.go @@ -57,7 +57,7 @@ var _ = Describe("QFS-02: Dynamic validators addition/removal testing", func() { By("Ensure the number of validators is correct", func() { for _, v := range blockchain.Validators() { - client := v.NewIstanbulClient() + client := v.NewClient() validators, err := client.GetValidators(context.Background(), nil) Expect(err).Should(BeNil()) Expect(len(validators)).Should(BeNumerically("==", numberOfValidators)) @@ -78,7 +78,7 @@ var _ = Describe("QFS-02: Dynamic validators addition/removal testing", func() { By("Ensure the number of validators is correct", func() { for _, v := range blockchain.Validators() { - client := v.NewIstanbulClient() + client := v.NewClient() validators, err := client.GetValidators(context.Background(), nil) Expect(err).Should(BeNil()) Expect(len(validators)).Should(BeNumerically("==", numberOfValidators+testValidators)) @@ -103,7 +103,7 @@ var _ = Describe("QFS-02: Dynamic validators addition/removal testing", func() { By("Ensure that numbers of validator is equal to $numberOfValidators", func() { for _, v := range blockchain.Validators() { - client := v.NewIstanbulClient() + client := v.NewClient() validators, err := client.GetValidators(context.Background(), nil) Expect(err).Should(BeNil()) Expect(len(validators)).Should(BeNumerically("==", numberOfValidators)) @@ -121,7 +121,7 @@ var _ = Describe("QFS-02: Dynamic validators addition/removal testing", func() { By("Check if the number of validators is correct", func() { for _, v := range blockchain.Validators() { - client := v.NewIstanbulClient() + client := v.NewClient() validators, err := client.GetValidators(context.Background(), nil) Expect(err).Should(BeNil()) Expect(len(validators)).Should(BeNumerically("==", numberOfValidators+numOfCandidates)) @@ -141,7 +141,7 @@ var _ = Describe("QFS-02: Dynamic validators addition/removal testing", func() { By("Check if the number of validators is correct", func() { for _, v := range blockchain.Validators() { - client := v.NewIstanbulClient() + client := v.NewClient() validators, err := client.GetValidators(context.Background(), nil) Expect(err).Should(BeNil()) Expect(len(validators)).Should(BeNumerically("==", numberOfValidators)) @@ -165,14 +165,14 @@ var _ = Describe("QFS-02: Dynamic validators addition/removal testing", func() { // stop validators [3] stopCandidates := blockchain.Validators()[numberOfValidators-1:] for _, candidates := range stopCandidates { - c := candidates.NewIstanbulClient() + c := candidates.NewClient() Expect(c.StopMining(context.Background())).Should(BeNil()) } }) By("Verify number of validators", func() { for _, v := range blockchain.Validators() { - client := v.NewIstanbulClient() + client := v.NewClient() validators, err := client.GetValidators(context.Background(), nil) Expect(err).Should(BeNil()) Expect(len(validators)).Should(BeNumerically("==", numberOfValidators)) @@ -199,14 +199,14 @@ var _ = Describe("QFS-02: Dynamic validators addition/removal testing", func() { stopCandidates := blockchain.Validators()[numberOfValidators-2:] // stop validators [3,4] for _, candidates := range stopCandidates { - c := candidates.NewIstanbulClient() + c := candidates.NewClient() Expect(c.StopMining(context.Background())).Should(BeNil()) } }) By("Verify number of validators", func() { for _, v := range blockchain.Validators() { - client := v.NewIstanbulClient() + client := v.NewClient() validators, err := client.GetValidators(context.Background(), nil) Expect(err).Should(BeNil()) Expect(len(validators)).Should(BeNumerically("==", numberOfValidators)) diff --git a/tests/quorum/functional/general_consensus_test.go b/tests/quorum/functional/general_consensus_test.go index 43b6dc27..d0beb7bf 100644 --- a/tests/quorum/functional/general_consensus_test.go +++ b/tests/quorum/functional/general_consensus_test.go @@ -92,7 +92,7 @@ var _ = Describe("QFS-01: General consensus", func() { } // 2. Check validator set - istClient := geth.NewIstanbulClient() + istClient := geth.NewClient() vals, err := istClient.GetValidators(context.Background(), big.NewInt(0)) if err != nil { errc <- err @@ -195,7 +195,7 @@ var _ = Describe("QFS-01: General consensus", func() { for _, geth := range blockchain.Validators() { go func(geth container.Ethereum) { c := geth.NewClient() - istClient := geth.NewIstanbulClient() + istClient := geth.NewClient() // get initial validator set vals, err := istClient.GetValidators(context.Background(), big.NewInt(0)) diff --git a/tests/quorum/functional/gossip_network_test.go b/tests/quorum/functional/gossip_network_test.go index 5d3396a7..783847d6 100644 --- a/tests/quorum/functional/gossip_network_test.go +++ b/tests/quorum/functional/gossip_network_test.go @@ -53,7 +53,7 @@ var _ = Describe("QFS-07: Gossip Network", func() { It("QFS-07-01: Gossip Network", func(done Done) { By("Check peer count", func() { for _, geth := range blockchain.Validators() { - c := geth.NewIstanbulClient() + c := geth.NewClient() peers, e := c.AdminPeers(context.Background()) Expect(e).To(BeNil()) Ω(len(peers)).Should(BeNumerically("<=", 2))