From 8fdddabdd3d738bf71c371a3991961ac98f0b52a Mon Sep 17 00:00:00 2001 From: VoR0220 <rj@erisindustries.com> Date: Thu, 15 Sep 2016 16:00:14 -0500 Subject: [PATCH] gofmt'd and added status Signed-off-by: VoR0220 <rj@erisindustries.com> --- client/client.go | 13 ++++++++++++ client/core/transaction_factory_test.go | 2 +- client/core/transaction_factory_util.go | 2 +- client/mock/client_mock.go | 27 +++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/client/client.go b/client/client.go index d131f510..be06862e 100644 --- a/client/client.go +++ b/client/client.go @@ -23,6 +23,7 @@ import ( "github.com/eris-ltd/eris-db/account" tendermint_client "github.com/eris-ltd/eris-db/rpc/tendermint/client" + rpc_types "github.com/eris-ltd/eris-db/rpc/tendermint/core/types" "github.com/eris-ltd/eris-db/txs" ) @@ -30,6 +31,8 @@ type NodeClient interface { Broadcast(transaction txs.Tx) (*txs.Receipt, error) GetAccount(address []byte) (*account.Account, error) + + Status() (*rpc_types.ResultStatus, error) } // NOTE [ben] Compiler check to ensure ErisClient successfully implements @@ -80,3 +83,13 @@ func (erisClient *ErisNodeClient) GetAccount(address []byte) (*account.Account, return account.Copy(), nil } + +func (erisClient *ErisNodeClient) Status() (*rpc_types.ResultStatus, error) { + client := rpcclient.NewClientURI(erisClient.broadcastRPC) + res, err := tendermint_client.Status(client) + if err != nil { + err = fmt.Errorf("Error connecting to node (%s) to get status: %s", + erisClient.broadcastRPC, err.Error()) + return nil, err + } +} diff --git a/client/core/transaction_factory_test.go b/client/core/transaction_factory_test.go index aa492b98..f480fcaf 100644 --- a/client/core/transaction_factory_test.go +++ b/client/core/transaction_factory_test.go @@ -150,4 +150,4 @@ func testTransactionFactoryPermissions(t *testing.T, t.Fail() } // TODO: test content of Transaction -} \ No newline at end of file +} diff --git a/client/core/transaction_factory_util.go b/client/core/transaction_factory_util.go index b5ed8250..6178da75 100644 --- a/client/core/transaction_factory_util.go +++ b/client/core/transaction_factory_util.go @@ -170,4 +170,4 @@ func checkCommon(nodeClient client.NodeClient, keyClient keys.KeyClient, pubkey, } return -} \ No newline at end of file +} diff --git a/client/mock/client_mock.go b/client/mock/client_mock.go index 0fc7e576..0b71e303 100644 --- a/client/mock/client_mock.go +++ b/client/mock/client_mock.go @@ -18,6 +18,7 @@ package mock import ( "github.com/tendermint/go-crypto" + "github.com/tendermint/go-p2p" acc "github.com/eris-ltd/eris-db/account" . "github.com/eris-ltd/eris-db/client" @@ -68,3 +69,29 @@ func (mock *MockNodeClient) MockAddAccount(account *acc.Account) { addressString := string(account.Address[:]) mock.accounts[addressString] = account.Copy() } + +func (mock *MockNodeClient) Status() (*rpc_types.ResultStatus, error) { + // make zero account + var zero [32]byte + pub := crypto.PubKey(crypto.PubKeyEd25519(zero)) + + // create a status + nodeInfo := &p2p.NodeInfo{ + PubKey: pub, + Moniker: "Mock", + Network: "MockNet", + RemoteAddr: "127.0.0.1", + ListenAddr: "127.0.0.1", + Version: "0.12.0", + Other: []string{}, + } + + return &rpc_types.ResultStatus{ + NodeInfo: nodeInfo, + GenesisHash: nil, + PubKey: pub, + LatestBlockHash: nil, + LatestBlockHeight: 1, + LatestBlockTime: 1, + } +} -- GitLab