From 97f190c1dfe8d8355c392b6155bffed91fc9c8cc Mon Sep 17 00:00:00 2001 From: androlo <andreas@erisindustries.com> Date: Sat, 18 Jul 2015 22:00:30 +0200 Subject: [PATCH] Improved test-data --- erisdb/erisdbss/http.go | 2 +- erisdb/pipe/pipe.go | 2 +- erisdb/pipe/transactor.go | 2 +- test/mock/mock_web_api_test.go | 208 +++++---- test/mock/pipe.go | 82 ++-- test/testdata/testdata/testdata.go | 700 +++++++++++++++++++---------- test/web_api/web_api_test.go | 80 ++-- 7 files changed, 667 insertions(+), 409 deletions(-) diff --git a/erisdb/erisdbss/http.go b/erisdb/erisdbss/http.go index abd0d1f3..da3df60e 100644 --- a/erisdb/erisdbss/http.go +++ b/erisdb/erisdbss/http.go @@ -15,7 +15,7 @@ import ( const TendermintConfigDefault = `# This is a TOML config file. # For more information, see https://github.com/toml-lang/toml -moniker = "anothertester" +moniker = "__MONIKER__" seeds = "" fast_sync = false db_backend = "leveldb" diff --git a/erisdb/pipe/pipe.go b/erisdb/pipe/pipe.go index 50000cc6..59069488 100644 --- a/erisdb/pipe/pipe.go +++ b/erisdb/pipe/pipe.go @@ -120,4 +120,4 @@ func (this *PipeImpl) Net() Net { func (this *PipeImpl) Transactor() Transactor { return this.txs -} +} \ No newline at end of file diff --git a/erisdb/pipe/transactor.go b/erisdb/pipe/transactor.go index eee3d91b..1a1e2b50 100644 --- a/erisdb/pipe/transactor.go +++ b/erisdb/pipe/transactor.go @@ -143,7 +143,7 @@ func (this *transactor) Transact(privKey, address, data []byte, gasLimit, fee in fmt.Printf("NONCE: %d\n", sequence) txInput := &types.TxInput{ Address: pa.Address, - Amount: 1000, + Amount: 1, Sequence: sequence, PubKey: pa.PubKey, } diff --git a/test/mock/mock_web_api_test.go b/test/mock/mock_web_api_test.go index c0421b7d..eb8d55ae 100644 --- a/test/mock/mock_web_api_test.go +++ b/test/mock/mock_web_api_test.go @@ -3,7 +3,7 @@ package mock // Basic imports import ( "bytes" - "fmt" + "encoding/hex" // edb "github.com/eris-ltd/erisdb/erisdb" "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/suite" @@ -67,186 +67,206 @@ func (this *MockSuite) TearDownSuite() { <-sec } -// ********************************************* Consensus ********************************************* +// ********************************************* Accounts ********************************************* -func (this *MockSuite) Test_A0_ConsensusState() { - resp := this.get("/consensus") - ret := &ep.ConsensusState{} +func (this *MockSuite) TestGetAccounts() { + resp := this.get("/accounts") + ret := &ep.AccountList{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - ret.StartTime = "" - this.Equal(ret, this.testData.Output.ConsensusState) + this.Equal(ret, this.testData.GetAccounts.Output) } -func (this *MockSuite) Test_A1_Validators() { - resp := this.get("/consensus/validators") - ret := &ep.ValidatorList{} +func (this *MockSuite) TestGetAccount() { + addr := hex.EncodeToString(this.testData.GetAccount.Input.Address) + resp := this.get("/accounts/" + addr) + ret := &account.Account{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Validators) + this.Equal(ret, this.testData.GetAccount.Output) } -// ********************************************* Network ********************************************* +func (this *MockSuite) TestGetStorage() { + addr := hex.EncodeToString(this.testData.GetStorage.Input.Address) + resp := this.get("/accounts/" + addr + "/storage") + ret := &ep.Storage{} + errD := this.codec.Decode(ret, resp.Body) + this.NoError(errD) + this.Equal(ret, this.testData.GetStorage.Output) +} -func (this *MockSuite) Test_B0_NetworkInfo() { - resp := this.get("/network") - ret := &ep.NetworkInfo{} +func (this *MockSuite) TestGetStorageAt() { + addr := hex.EncodeToString(this.testData.GetStorageAt.Input.Address) + key := hex.EncodeToString(this.testData.GetStorageAt.Input.Key) + resp := this.get("/accounts/" + addr + "/storage/" + key) + ret := &ep.StorageItem{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.NetworkInfo) + this.Equal(ret, this.testData.GetStorageAt.Output) } -func (this *MockSuite) Test_B1_ClientVersion() { - resp := this.get("/network/client_version") - ret := &ep.ClientVersion{} +// ********************************************* Blockchain ********************************************* + +func (this *MockSuite) TestGetBlockchainInfo() { + resp := this.get("/blockchain") + ret := &ep.BlockchainInfo{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.ClientVersion) + this.Equal(ret, this.testData.GetBlockchainInfo.Output) } -func (this *MockSuite) Test_B2_Moniker() { - resp := this.get("/network/moniker") - ret := &ep.Moniker{} +func (this *MockSuite) TestGetChainId() { + resp := this.get("/blockchain/chain_id") + ret := &ep.ChainId{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Moniker) + this.Equal(ret, this.testData.GetChainId.Output) } -func (this *MockSuite) Test_B3_Listening() { - resp := this.get("/network/listening") - ret := &ep.Listening{} +func (this *MockSuite) TestGetGenesisHash() { + resp := this.get("/blockchain/genesis_hash") + ret := &ep.GenesisHash{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Listening) + this.Equal(ret, this.testData.GetGenesisHash.Output) } -func (this *MockSuite) Test_B4_Listeners() { - resp := this.get("/network/listeners") - ret := &ep.Listeners{} +func (this *MockSuite) TestLatestBlockHeight() { + resp := this.get("/blockchain/latest_block_height") + ret := &ep.LatestBlockHeight{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Listeners) + this.Equal(ret, this.testData.GetLatestBlockHeight.Output) } -func (this *MockSuite) Test_B5_Peers() { - resp := this.get("/network/peers") - ret := []*ep.Peer{} +func (this *MockSuite) TestBlocks() { + resp := this.get("/blockchain/blocks") + ret := &ep.Blocks{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Peers) + this.Equal(ret, this.testData.GetBlocks.Output) } -// ********************************************* Transactions ********************************************* +// ********************************************* Consensus ********************************************* -func (this *MockSuite) Test_C0_TxCreate() { - resp := this.postJson("/unsafe/txpool", this.testData.Input.TxCreate) - ret := &ep.Receipt{} +func (this *MockSuite) TestGetConsensusState() { + resp := this.get("/consensus") + ret := &ep.ConsensusState{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.TxCreateReceipt) + ret.StartTime = "" + this.Equal(ret, this.testData.GetConsensusState.Output) } -func (this *MockSuite) Test_C1_Tx() { - resp := this.postJson("/unsafe/txpool", this.testData.Input.Tx) - ret := &ep.Receipt{} +func (this *MockSuite) TestGetValidators() { + resp := this.get("/consensus/validators") + ret := &ep.ValidatorList{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.TxReceipt) + this.Equal(ret, this.testData.GetValidators.Output) } -func (this *MockSuite) Test_C2_UnconfirmedTxs() { - resp := this.get("/txpool") - ret := &ep.UnconfirmedTxs{} +// ********************************************* Network ********************************************* + +func (this *MockSuite) TestGetNetworkInfo() { + resp := this.get("/network") + ret := &ep.NetworkInfo{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.UnconfirmedTxs) + this.Equal(ret, this.testData.GetNetworkInfo.Output) } -func (this *MockSuite) Test_C3_CallCode() { - resp := this.postJson("/codecalls", this.testData.Input.CallCode) - ret := &ep.Call{} +func (this *MockSuite) TestGetClientVersion() { + resp := this.get("/network/client_version") + ret := &ep.ClientVersion{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.CallCode) + this.Equal(ret, this.testData.GetClientVersion.Output) } -// ********************************************* Accounts ********************************************* +func (this *MockSuite) TestGetMoniker() { + resp := this.get("/network/moniker") + ret := &ep.Moniker{} + errD := this.codec.Decode(ret, resp.Body) + this.NoError(errD) + this.Equal(ret, this.testData.GetMoniker.Output) +} -func (this *MockSuite) Test_D0_Accounts() { - resp := this.get("/accounts") - ret := &ep.AccountList{} +func (this *MockSuite) TestIsListening() { + resp := this.get("/network/listening") + ret := &ep.Listening{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Accounts) + this.Equal(ret, this.testData.IsListening.Output) } -func (this *MockSuite) Test_D1_Account() { - resp := this.get("/accounts/" + this.testData.Input.AccountAddress) - ret := &account.Account{} +func (this *MockSuite) TestGetListeners() { + resp := this.get("/network/listeners") + ret := &ep.Listeners{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Account) + this.Equal(ret, this.testData.GetListeners.Output) } -func (this *MockSuite) Test_D2_Storage() { - resp := this.get("/accounts/" + this.testData.Input.AccountAddress + "/storage") - ret := &ep.Storage{} +func (this *MockSuite) TestGetPeers() { + resp := this.get("/network/peers") + ret := []*ep.Peer{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Storage) + this.Equal(ret, this.testData.GetPeers.Output) } -func (this *MockSuite) Test_D3_StorageAt() { - addr := this.testData.Input.AccountAddress - key := this.testData.Input.StorageAddress - resp := this.get("/accounts/" + addr + "/storage/" + key) - ret := &ep.StorageItem{} +/* +func (this *MockSuite) TestGetPeer() { + addr := this.testData.GetPeer.Input.Address + resp := this.get("/network/peer/" + addr) + ret := []*ep.Peer{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.StorageAt) + this.Equal(ret, this.testData.GetPeers.Output) } +*/ -// ********************************************* Blockchain ********************************************* +// ********************************************* Transactions ********************************************* -func (this *MockSuite) Test_E0_BlockchainInfo() { - resp := this.get("/blockchain") - ret := &ep.BlockchainInfo{} +func (this *MockSuite) TestTransactCreate() { + resp := this.postJson("/unsafe/txpool", this.testData.TransactCreate.Input) + ret := &ep.Receipt{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.BlockchainInfo) + this.Equal(ret, this.testData.TransactCreate.Output) } -func (this *MockSuite) Test_E1_ChainId() { - resp := this.get("/blockchain/chain_id") - ret := &ep.ChainId{} +func (this *MockSuite) TestTransact() { + resp := this.postJson("/unsafe/txpool", this.testData.Transact.Input) + ret := &ep.Receipt{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.ChainId) + this.Equal(ret, this.testData.Transact.Output) } -func (this *MockSuite) Test_E2_GenesisHash() { - resp := this.get("/blockchain/genesis_hash") - ret := &ep.GenesisHash{} +func (this *MockSuite) TestGetUnconfirmedTxs() { + resp := this.get("/txpool") + ret := &ep.UnconfirmedTxs{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.GenesisHash) + this.Equal(ret, this.testData.GetUnconfirmedTxs.Output) } -func (this *MockSuite) Test_E3_LatestBlockHeight() { - resp := this.get("/blockchain/latest_block_height") - ret := &ep.LatestBlockHeight{} +func (this *MockSuite) TestCallCode() { + resp := this.postJson("/codecalls", this.testData.CallCode.Input) + ret := &ep.Call{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.LatestBlockHeight) + this.Equal(ret, this.testData.CallCode.Output) } -func (this *MockSuite) Test_E4_Blocks() { - br := this.testData.Input.BlockRange - resp := this.get(fmt.Sprintf("/blockchain/blocks?q=height:%d..%d", br.Min, br.Max)) - ret := &ep.Blocks{} +func (this *MockSuite) TestCall() { + resp := this.postJson("/calls", this.testData.Call.Input) + ret := &ep.Call{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Blocks) + this.Equal(ret, this.testData.CallCode.Output) } // ********************************************* Utilities ********************************************* diff --git a/test/mock/pipe.go b/test/mock/pipe.go index 166ed9ae..9ba2fd54 100644 --- a/test/mock/pipe.go +++ b/test/mock/pipe.go @@ -9,7 +9,7 @@ import ( // Base struct. type MockPipe struct { - testOutput *td.Output + testData *td.TestData accounts ep.Accounts blockchain ep.Blockchain consensus ep.Consensus @@ -20,15 +20,14 @@ type MockPipe struct { // Create a new mock tendermint pipe. func NewMockPipe(td *td.TestData) ep.Pipe { - testOutput := td.Output - accounts := &accounts{testOutput} - blockchain := &blockchain{testOutput} - consensus := &consensus{testOutput} - events := &events{testOutput} - net := &net{testOutput} - transactor := &transactor{testOutput} + accounts := &accounts{td} + blockchain := &blockchain{td} + consensus := &consensus{td} + events := &events{td} + net := &net{td} + transactor := &transactor{td} return &MockPipe{ - testOutput, + td, accounts, blockchain, consensus, @@ -71,82 +70,82 @@ func (this *MockPipe) Transactor() ep.Transactor { // Accounts type accounts struct { - testOutput *td.Output + testData *td.TestData } func (this *accounts) GenPrivAccount() (*account.PrivAccount, error) { - return this.testOutput.GenPrivAccount, nil + return this.testData.GenPrivAccount.Output, nil } func (this *accounts) GenPrivAccountFromKey(key []byte) (*account.PrivAccount, error) { - return this.testOutput.GenPrivAccount, nil + return this.testData.GenPrivAccount.Output, nil } func (this *accounts) Accounts([]*ep.FilterData) (*ep.AccountList, error) { - return this.testOutput.Accounts, nil + return this.testData.GetAccounts.Output, nil } func (this *accounts) Account(address []byte) (*account.Account, error) { - return this.testOutput.Account, nil + return this.testData.GetAccount.Output, nil } func (this *accounts) Storage(address []byte) (*ep.Storage, error) { - return this.testOutput.Storage, nil + return this.testData.GetStorage.Output, nil } func (this *accounts) StorageAt(address, key []byte) (*ep.StorageItem, error) { - return this.testOutput.StorageAt, nil + return this.testData.GetStorageAt.Output, nil } // Blockchain type blockchain struct { - testOutput *td.Output + testData *td.TestData } func (this *blockchain) Info() (*ep.BlockchainInfo, error) { - return this.testOutput.BlockchainInfo, nil + return this.testData.GetBlockchainInfo.Output, nil } func (this *blockchain) ChainId() (string, error) { - return this.testOutput.ChainId.ChainId, nil + return this.testData.GetChainId.Output.ChainId, nil } func (this *blockchain) GenesisHash() ([]byte, error) { - return this.testOutput.GenesisHash.Hash, nil + return this.testData.GetGenesisHash.Output.Hash, nil } func (this *blockchain) LatestBlockHeight() (int, error) { - return this.testOutput.LatestBlockHeight.Height, nil + return this.testData.GetLatestBlockHeight.Output.Height, nil } func (this *blockchain) LatestBlock() (*types.Block, error) { - return nil, nil + return this.testData.GetLatestBlock.Output, nil } func (this *blockchain) Blocks([]*ep.FilterData) (*ep.Blocks, error) { - return this.testOutput.Blocks, nil + return this.testData.GetBlocks.Output, nil } func (this *blockchain) Block(height int) (*types.Block, error) { - return this.testOutput.Block, nil + return this.testData.GetBlock.Output, nil } // Consensus type consensus struct { - testOutput *td.Output + testData *td.TestData } func (this *consensus) State() (*ep.ConsensusState, error) { - return this.testOutput.ConsensusState, nil + return this.testData.GetConsensusState.Output, nil } func (this *consensus) Validators() (*ep.ValidatorList, error) { - return this.testOutput.Validators, nil + return this.testData.GetValidators.Output, nil } // Events type events struct { - testOutput *td.Output + testData *td.TestData } func (this *events) Subscribe(subId, event string, callback func(interface{})) (bool, error) { @@ -159,48 +158,49 @@ func (this *events) Unsubscribe(subId string) (bool, error) { // Net type net struct { - testOutput *td.Output + testData *td.TestData } func (this *net) Info() (*ep.NetworkInfo, error) { - return this.testOutput.NetworkInfo, nil + return this.testData.GetNetworkInfo.Output, nil } func (this *net) ClientVersion() (string, error) { - return this.testOutput.ClientVersion.ClientVersion, nil + return this.testData.GetClientVersion.Output.ClientVersion, nil } func (this *net) Moniker() (string, error) { - return this.testOutput.Moniker.Moniker, nil + return this.testData.GetMoniker.Output.Moniker, nil } func (this *net) Listening() (bool, error) { - return this.testOutput.Listening.Listening, nil + return this.testData.IsListening.Output.Listening, nil } func (this *net) Listeners() ([]string, error) { - return this.testOutput.Listeners.Listeners, nil + return this.testData.GetListeners.Output.Listeners, nil } func (this *net) Peers() ([]*ep.Peer, error) { - return this.testOutput.Peers, nil + return this.testData.GetPeers.Output, nil } func (this *net) Peer(address string) (*ep.Peer, error) { + // return this.testData.GetPeer.Output, nil return nil, nil } // Txs type transactor struct { - testOutput *td.Output + testData *td.TestData } func (this *transactor) Call(address, data []byte) (*ep.Call, error) { - return nil, nil + return this.testData.Call.Output, nil } func (this *transactor) CallCode(code, data []byte) (*ep.Call, error) { - return this.testOutput.CallCode, nil + return this.testData.CallCode.Output, nil } func (this *transactor) BroadcastTx(tx types.Tx) (*ep.Receipt, error) { @@ -208,14 +208,14 @@ func (this *transactor) BroadcastTx(tx types.Tx) (*ep.Receipt, error) { } func (this *transactor) UnconfirmedTxs() (*ep.UnconfirmedTxs, error) { - return this.testOutput.UnconfirmedTxs, nil + return this.testData.GetUnconfirmedTxs.Output, nil } func (this *transactor) Transact(privKey, address, data []byte, gasLimit, fee int64) (*ep.Receipt, error) { if address == nil || len(address) == 0 { - return this.testOutput.TxCreateReceipt, nil + return this.testData.TransactCreate.Output, nil } - return this.testOutput.TxReceipt, nil + return this.testData.Transact.Output, nil } func (this *transactor) SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (types.Tx, error) { diff --git a/test/testdata/testdata/testdata.go b/test/testdata/testdata/testdata.go index b4819f5d..0f89665f 100644 --- a/test/testdata/testdata/testdata.go +++ b/test/testdata/testdata/testdata.go @@ -1,19 +1,25 @@ package testdata import ( - edb "github.com/eris-ltd/eris-db/erisdb" - ep "github.com/eris-ltd/eris-db/erisdb/pipe" "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state" "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + edb "github.com/eris-ltd/eris-db/erisdb" + ep "github.com/eris-ltd/eris-db/erisdb/pipe" ) var testDataJson = `{ "chain_data": { "priv_validator": { "address": "37236DF251AB70022B1DA351F08A20FB52443E37", - "pub_key": [1, "CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906"], - "priv_key": [1, "6B72D45EB65F619F11CE580C8CAED9E0BADC774E9C9C334687A65DCBAD2C4151CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906"], + "pub_key": [ + 1, + "CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906" + ], + "priv_key": [ + 1, + "6B72D45EB65F619F11CE580C8CAED9E0BADC774E9C9C334687A65DCBAD2C4151CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906" + ], "last_height": 0, "last_round": 0, "last_step": 0 @@ -41,11 +47,13 @@ var testDataJson = `{ "address": "37236DF251AB70022B1DA351F08A20FB52443E37", "amount": 110000000000 } - ], "validators": [ { - "pub_key": [1, "CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906"], + "pub_key": [ + 1, + "CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906" + ], "amount": 5000000000, "unbond_to": [ { @@ -57,151 +65,48 @@ var testDataJson = `{ ] } }, - "input" : { - "account_address": "9FC1ECFCAE2A554D4D1A000D0D80F748E66359E3", - "storage_address": "00", - "tx_create" : { - "address": "", - "priv_key": "6B72D45EB65F619F11CE580C8CAED9E0BADC774E9C9C334687A65DCBAD2C4151CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906", - "data": "5B33600060006101000A81548173FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF021916908302179055505B6102828061003B6000396000F3006000357C01000000000000000000000000000000000000000000000000000000009004806337F428411461004557806340C10F191461005A578063D0679D341461006E57005B610050600435610244565B8060005260206000F35B610068600435602435610082565B60006000F35B61007C600435602435610123565B60006000F35B600060009054906101000A900473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1673FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF163373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1614156100DD576100E2565B61011F565B80600160005060008473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020019081526020016000206000828282505401925050819055505B5050565B80600160005060003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF168152602001908152602001600020600050541061015E57610163565B610240565B80600160005060003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF16815260200190815260200160002060008282825054039250508190555080600160005060008473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020019081526020016000206000828282505401925050819055507F93EB3C629EB575EDAF0252E4F9FC0C5CCADA50496F8C1D32F0F93A65A8257EB560003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020018373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020018281526020016000A15B5050565B6000600160005060008373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF16815260200190815260200160002060005054905061027D565B91905056", - "fee" : 1000, - "gas_limit": 1000 + "GetAccount": { + "input": { + "address": "9FC1ECFCAE2A554D4D1A000D0D80F748E66359E3" }, - "tx": { + "output": { "address": "9FC1ECFCAE2A554D4D1A000D0D80F748E66359E3", - "priv_key": "6B72D45EB65F619F11CE580C8CAED9E0BADC774E9C9C334687A65DCBAD2C4151CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906", - "data": "", - "fee" : 1000, - "gas_limit": 1000 - }, - "call_code": { - "code": "5B33600060006101000A81548173FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF021916908302179055505B6102828061003B6000396000F3006000357C01000000000000000000000000000000000000000000000000000000009004806337F428411461004557806340C10F191461005A578063D0679D341461006E57005B610050600435610244565B8060005260206000F35B610068600435602435610082565B60006000F35B61007C600435602435610123565B60006000F35B600060009054906101000A900473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1673FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF163373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1614156100DD576100E2565B61011F565B80600160005060008473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020019081526020016000206000828282505401925050819055505B5050565B80600160005060003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF168152602001908152602001600020600050541061015E57610163565B610240565B80600160005060003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF16815260200190815260200160002060008282825054039250508190555080600160005060008473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020019081526020016000206000828282505401925050819055507F93EB3C629EB575EDAF0252E4F9FC0C5CCADA50496F8C1D32F0F93A65A8257EB560003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020018373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020018281526020016000A15B5050565B6000600160005060008373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF16815260200190815260200160002060005054905061027D565B91905056", - "data": "" - }, - "block_range": { - "min": 0, - "max": 0 - }, - "priv_account": { - "address": "B4F9DA82738D37A1D83AD2CDD0C0D3CBA76EA4E7", - "pub_key": [ 1, "9C74ECA0AF1DF930C69F5B9F72A1802C47D1A47E14D4572ADB24A63EA501D917" ], - "priv_key": [ 1, - "82197A833282E819D172A3CB19B4CA3FFCA2F2CBE042B01CCF66E5147AF3C3759C74ECA0AF1DF930C69F5B9F72A1802C47D1A47E14D4572ADB24A63EA501D917" ] + "pub_key": null, + "sequence": 0, + "balance": 0, + "code": "", + "storage_root": "", + "permissions": { + "base": { + "perms": 0, + "set": 0 + }, + "roles": [] + } } }, - "output": { - "consensus_state": { - "height": 1, - "round": 0, - "step": 1, - "start_time": "", - "commit_time": "0001-01-01 00:00:00 +0000 UTC", - "validators": [{ - "address": "37236DF251AB70022B1DA351F08A20FB52443E37", - "pub_key": [1, "CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906"], - "bond_height": 0, - "unbond_height": 0, - "last_commit_height": 0, - "voting_power": 5000000000, - "accum": 0 - }], - "proposal": null - }, - "validators": { - "block_height": 0, - "bonded_validators": [{ - "address": "37236DF251AB70022B1DA351F08A20FB52443E37", - "pub_key": [1, "CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906"], - "bond_height": 0, - "unbond_height": 0, - "last_commit_height": 0, - "voting_power": 5000000000, - "accum": 0 - }], - "unbonding_validators": [] - }, - "network_info": { - "client_version": "0.5.0", - "moniker": "anothertester", - "listening": false, - "listeners": [], - "peers": [] - }, - "client_version": { - "client_version": "0.5.0" - }, - "moniker": { - "moniker": "anothertester" - }, - "listening": { - "listening": false + "GetAccounts": { + "input": { + "filters": [] }, - "listeners": { - "listeners": [] - }, - "peers": [], - "peer": null, - "tx_create_receipt": { - "tx_hash": "C1C84BCD4CCA6D6132D1E702FA4A7618DBCDB52F", - "creates_contract": 1, - "contract_addr": "9FC1ECFCAE2A554D4D1A000D0D80F748E66359E3" - }, - "tx_receipt": { - "tx_hash": "A40873D4C7136F6D79476A035D4265781FC20A3B", - "creates_contract": 0, - "contract_addr": "" - }, - "unconfirmed_txs": { - "txs": [ - [ 2, { - "input": { - "address": "37236DF251AB70022B1DA351F08A20FB52443E37", - "amount": 1000, - "sequence": 1, - "signature": [ 1, "39E1D98C2F4F8FC5A98442C55DCC8FCBCE4ADB0F6BAD5C5258CEFE94EFB0315EA9616CC275F97E4D04C5A8FD08D73B84A28B7CFEAEE98F4A37E2F2BCA1830907" ], - "pub_key": [1, "CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906"] - }, - "address": "", - "gas_limit": 1000, - "fee": 1000, - "data": "5B33600060006101000A81548173FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF021916908302179055505B6102828061003B6000396000F3006000357C01000000000000000000000000000000000000000000000000000000009004806337F428411461004557806340C10F191461005A578063D0679D341461006E57005B610050600435610244565B8060005260206000F35B610068600435602435610082565B60006000F35B61007C600435602435610123565B60006000F35B600060009054906101000A900473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1673FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF163373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1614156100DD576100E2565B61011F565B80600160005060008473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020019081526020016000206000828282505401925050819055505B5050565B80600160005060003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF168152602001908152602001600020600050541061015E57610163565B610240565B80600160005060003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF16815260200190815260200160002060008282825054039250508190555080600160005060008473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020019081526020016000206000828282505401925050819055507F93EB3C629EB575EDAF0252E4F9FC0C5CCADA50496F8C1D32F0F93A65A8257EB560003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020018373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020018281526020016000A15B5050565B6000600160005060008373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF16815260200190815260200160002060005054905061027D565B91905056" - } ], - [ 2, { - "input": { - "address": "37236DF251AB70022B1DA351F08A20FB52443E37", - "amount": 1000, - "sequence": 3, - "signature": [1, "8D84089EC1140C5AF474DB7E764E937D9C6309BA0AD7BCC56108A2075504005AE2EE1AD71C3D414F9D793D2BFAD77C9572D9494736E6F3D1A62D17DF4A01090D" ], - "pub_key": null - }, - "address": "9FC1ECFCAE2A554D4D1A000D0D80F748E66359E3", - "gas_limit": 1000, - "fee": 1000, - "data": "" - } ] - ]}, - "call_code": { - "return": "6000357c01000000000000000000000000000000000000000000000000000000009004806337f428411461004557806340c10f191461005a578063d0679d341461006e57005b610050600435610244565b8060005260206000f35b610068600435602435610082565b60006000f35b61007c600435602435610123565b60006000f35b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156100dd576100e2565b61011f565b80600160005060008473ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828282505401925050819055505b5050565b80600160005060003373ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600050541061015e57610163565b610240565b80600160005060003373ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282825054039250508190555080600160005060008473ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828282505401925050819055507f93eb3c629eb575edaf0252e4f9fc0c5ccada50496f8c1d32f0f93a65a8257eb560003373ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020016000a15b5050565b6000600160005060008373ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060005054905061027d565b91905056", - "gas_used": 0 - }, - "accounts": { + "output": { "accounts": [ - { - "address": "0000000000000000000000000000000000000000", - "balance": 1337, - "code": "", - "permissions": { - "base": { - "perms": 126, - "set": 1095216660607 + { + "address": "0000000000000000000000000000000000000000", + "balance": 1337, + "code": "", + "permissions": { + "base": { + "perms": 126, + "set": 1095216660607 + }, + "roles": [] }, - "roles": [] + "pub_key": null, + "sequence": 0, + "storage_root": "" }, - "pub_key": null, - "sequence": 0, - "storage_root": "" - }, - { + { "address": "0000000000000000000000000000000000000002", "pub_key": null, "sequence": 0, @@ -215,7 +120,7 @@ var testDataJson = `{ }, "roles": [] } - }, + }, { "address": "0000000000000000000000000000000000000004", "pub_key": null, @@ -276,134 +181,465 @@ var testDataJson = `{ "roles": [] } } - ] + } + }, + "GetStorage": { + "input": { + "address": "9FC1ECFCAE2A554D4D1A000D0D80F748E66359E3" }, - "account": { - "address": "9FC1ECFCAE2A554D4D1A000D0D80F748E66359E3", - "pub_key": null, - "sequence": 0, - "balance": 0, - "code": "", - "storage_root": "", - "permissions": { - "base": { - "perms": 0, - "set": 0 - }, - "roles": [] - } - }, - "storage": { + "output": { "storage_root": "", "storage_items": [] + } + }, + "GetStorageAt": { + "input": { + "address": "9FC1ECFCAE2A554D4D1A000D0D80F748E66359E3", + "key": "00" }, - "storage_at": { + "output": { "key": "00", "value": "" - }, - "blockchain_info": { + } + }, + "GenPrivAccount": { + "output": { + "address": "", + "pub_key": [ + 1, + "" + ], + "priv_key": [ + 1, + "" + ] + } + }, + "GetBlockchainInfo": { + "output": { "chain_id": "my_tests", "genesis_hash": "59A43DA6B4C9685E2D8840158768746093A71925", "latest_block_height": 0, "latest_block": null - }, - "chain_id": { + } + }, + "GetChainId": { + "output": { "chain_id": "my_tests" - }, - "genesis_hash": { + } + }, + "GetGenesisHash": { + "output": { "hash": "59A43DA6B4C9685E2D8840158768746093A71925" - }, - "latest_block_height": { + } + }, + "GetLatestBlockHeight": { + "output": { "height": 0 + } + }, + "GetLatestBlock": { + "output": {} + }, + "GetBlock": { + "input": {"height": 0}, + "output": null + }, + "GetBlocks": { + "input": { + "filters": [] }, - "latest_block" : null, - "block": null, - "blocks": { + "output": { "min_height": 0, "max_height": 0, "block_metas": [] + } + }, + "GetConsensusState": { + "output": { + "height": 1, + "round": 0, + "step": 1, + "start_time": "", + "commit_time": "0001-01-01 00:00:00 +0000 UTC", + "validators": [ + { + "address": "37236DF251AB70022B1DA351F08A20FB52443E37", + "pub_key": [ + 1, + "CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906" + ], + "bond_height": 0, + "unbond_height": 0, + "last_commit_height": 0, + "voting_power": 5000000000, + "accum": 0 + } + ], + "proposal": null + } + }, + "GetValidators": { + "output": { + "block_height": 0, + "bonded_validators": [ + { + "address": "37236DF251AB70022B1DA351F08A20FB52443E37", + "pub_key": [ + 1, + "CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906" + ], + "bond_height": 0, + "unbond_height": 0, + "last_commit_height": 0, + "voting_power": 5000000000, + "accum": 0 + } + ], + "unbonding_validators": [] + } + }, + "GetNetworkInfo": { + "output": { + "client_version": "0.5.0", + "moniker": "__MONIKER__", + "listening": false, + "listeners": [], + "peers": [] + } + }, + "GetClientVersion": { + "output": { + "client_version": "0.5.0" + } + }, + "GetMoniker": { + "output": { + "moniker": "__MONIKER__" + } + }, + "IsListening": { + "output": { + "listening": false + } + }, + "GetListeners": { + "output": { + "listeners": [] + } + }, + "GetPeers": { + "output": [] + }, + "GetPeer": { + "input": {"address": "127.0.0.1:30000"}, + "output": { + "is_outbound": false, + "node_info": null + } + }, + "Transact": { + "input": { + "address": "9FC1ECFCAE2A554D4D1A000D0D80F748E66359E3", + "priv_key": "6B72D45EB65F619F11CE580C8CAED9E0BADC774E9C9C334687A65DCBAD2C4151CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906", + "data": "", + "fee": 0, + "gas_limit": 1000000 }, - "gen_priv_account": { + "output": { + "tx_hash": "240E5BDCC0E4F7C1F29A66CA20E3F7A0D6F7EF51", + "creates_contract": 0, + "contract_addr": "" + } + }, + "TransactCreate": { + "input": { "address": "", - "pub_key": [ 1, "" ], - "priv_key": [ 1, "" ] + "priv_key": "6B72D45EB65F619F11CE580C8CAED9E0BADC774E9C9C334687A65DCBAD2C4151CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906", + "data": "5B33600060006101000A81548173FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF021916908302179055505B6102828061003B6000396000F3006000357C01000000000000000000000000000000000000000000000000000000009004806337F428411461004557806340C10F191461005A578063D0679D341461006E57005B610050600435610244565B8060005260206000F35B610068600435602435610082565B60006000F35B61007C600435602435610123565B60006000F35B600060009054906101000A900473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1673FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF163373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1614156100DD576100E2565B61011F565B80600160005060008473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020019081526020016000206000828282505401925050819055505B5050565B80600160005060003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF168152602001908152602001600020600050541061015E57610163565B610240565B80600160005060003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF16815260200190815260200160002060008282825054039250508190555080600160005060008473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020019081526020016000206000828282505401925050819055507F93EB3C629EB575EDAF0252E4F9FC0C5CCADA50496F8C1D32F0F93A65A8257EB560003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020018373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020018281526020016000A15B5050565B6000600160005060008373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF16815260200190815260200160002060005054905061027D565B91905056", + "fee": 0, + "gas_limit": 1000000 + }, + "output": { + "tx_hash": "BD5D35871770DB04726843A4C07A26CDE69EB860", + "creates_contract": 1, + "contract_addr": "9FC1ECFCAE2A554D4D1A000D0D80F748E66359E3" + } + }, + "GetUnconfirmedTxs": { + "output": { + "txs": [ + [ + 2, + { + "input": { + "address": "37236DF251AB70022B1DA351F08A20FB52443E37", + "amount": 1, + "sequence": 1, + "signature": [ + 1, + "2FE1C5EA3B0A05560073D7BF145C0997803113D27618CBCD71985806255E6492C7DC574AF373D3807068164AF4FE51D8CDA7DCC995E088375B83AEA3F8F6F204" + ], + "pub_key": [ + 1, + "CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906" + ] + }, + "address": "", + "gas_limit": 1000000, + "fee": 0, + "data": "5B33600060006101000A81548173FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF021916908302179055505B6102828061003B6000396000F3006000357C01000000000000000000000000000000000000000000000000000000009004806337F428411461004557806340C10F191461005A578063D0679D341461006E57005B610050600435610244565B8060005260206000F35B610068600435602435610082565B60006000F35B61007C600435602435610123565B60006000F35B600060009054906101000A900473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1673FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF163373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1614156100DD576100E2565B61011F565B80600160005060008473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020019081526020016000206000828282505401925050819055505B5050565B80600160005060003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF168152602001908152602001600020600050541061015E57610163565B610240565B80600160005060003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF16815260200190815260200160002060008282825054039250508190555080600160005060008473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020019081526020016000206000828282505401925050819055507F93EB3C629EB575EDAF0252E4F9FC0C5CCADA50496F8C1D32F0F93A65A8257EB560003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020018373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020018281526020016000A15B5050565B6000600160005060008373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF16815260200190815260200160002060005054905061027D565B91905056" + } + ], + [ + 2, + { + "input": { + "address": "37236DF251AB70022B1DA351F08A20FB52443E37", + "amount": 1, + "sequence": 3, + "signature": [ + 1, + "425A4D50350EEB597C48F82924E83F24640F9ECB3886A2B85D0073911AE02FC06F3D0FD480D59140B1D2DA669A9BD0227B31026EF3E0AAD534DCF50784984B01" + ], + "pub_key": null + }, + "address": "9FC1ECFCAE2A554D4D1A000D0D80F748E66359E3", + "gas_limit": 1000000, + "fee": 0, + "data": "" + } + ] + ] + } + }, + "CallCode": { + "input": { + "code": "5B33600060006101000A81548173FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF021916908302179055505B6102828061003B6000396000F3006000357C01000000000000000000000000000000000000000000000000000000009004806337F428411461004557806340C10F191461005A578063D0679D341461006E57005B610050600435610244565B8060005260206000F35B610068600435602435610082565B60006000F35B61007C600435602435610123565B60006000F35B600060009054906101000A900473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1673FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF163373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1614156100DD576100E2565B61011F565B80600160005060008473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020019081526020016000206000828282505401925050819055505B5050565B80600160005060003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF168152602001908152602001600020600050541061015E57610163565B610240565B80600160005060003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF16815260200190815260200160002060008282825054039250508190555080600160005060008473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020019081526020016000206000828282505401925050819055507F93EB3C629EB575EDAF0252E4F9FC0C5CCADA50496F8C1D32F0F93A65A8257EB560003373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020018373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1681526020018281526020016000A15B5050565B6000600160005060008373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF16815260200190815260200160002060005054905061027D565B91905056", + "data": "" + }, + "output": { + "return": "6000357c01000000000000000000000000000000000000000000000000000000009004806337f428411461004557806340c10f191461005a578063d0679d341461006e57005b610050600435610244565b8060005260206000f35b610068600435602435610082565b60006000f35b61007c600435602435610123565b60006000f35b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156100dd576100e2565b61011f565b80600160005060008473ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828282505401925050819055505b5050565b80600160005060003373ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600050541061015e57610163565b610240565b80600160005060003373ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282825054039250508190555080600160005060008473ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828282505401925050819055507f93eb3c629eb575edaf0252e4f9fc0c5ccada50496f8c1d32f0f93a65a8257eb560003373ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020016000a15b5050565b6000600160005060008373ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060005054905061027d565b91905056", + "gas_used": 0 + } + }, + "Call": { + "input": {"address": "9FC1ECFCAE2A554D4D1A000D0D80F748E66359E3", "data": ""}, + "output": { + "return": "6000357c01000000000000000000000000000000000000000000000000000000009004806337f428411461004557806340c10f191461005a578063d0679d341461006e57005b610050600435610244565b8060005260206000f35b610068600435602435610082565b60006000f35b61007c600435602435610123565b60006000f35b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156100dd576100e2565b61011f565b80600160005060008473ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828282505401925050819055505b5050565b80600160005060003373ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600050541061015e57610163565b610240565b80600160005060003373ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282825054039250508190555080600160005060008473ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828282505401925050819055507f93eb3c629eb575edaf0252e4f9fc0c5ccada50496f8c1d32f0f93a65a8257eb560003373ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020016000a15b5050565b6000600160005060008373ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060005054905061027d565b91905056", + "gas_used": 0 + } + }, + "EventSubscribe": { + "input": { + "event_id": "testId" }, - "evt_sub": { + "output": { "sub_id": "1234123412341234123412341234123412341234123412341234123412341234" + } + }, + "EventUnsubscribe": { + "input": { + "event_sub": "1234123412341234123412341234123412341234123412341234123412341234" }, - "evt_poll": { - "events": [{ - "address": "0000000000000000000000009FC1ECFCAE2A554D4D1A000D0D80F748E66359E3", - "topics": [ - "0FC28FCE5E54AC6458756FC24DC51A931CA7AD21440CFCA44933AE774ED5F70C", - "0000000000000000000000000000000000000000000000000000000000000005", - "0000000000000000000000000000000000000000000000000000000000000019", - "000000000000000000000000000000000000000000000000000000000000001E" - ], - "data": "41646465642074776F206E756D62657273000000000000000000000000000000", - "height": 1 - }] + "output": { + "result": true + } + }, + "EventPoll": { + "input": { + "event_sub": "1234123412341234123412341234123412341234123412341234123412341234" }, - "evt_unsub": {"result": true} + "output": { + "events": [ + { + "address": "0000000000000000000000009FC1ECFCAE2A554D4D1A000D0D80F748E66359E3", + "topics": [ + "0FC28FCE5E54AC6458756FC24DC51A931CA7AD21440CFCA44933AE774ED5F70C", + "0000000000000000000000000000000000000000000000000000000000000005", + "0000000000000000000000000000000000000000000000000000000000000019", + "000000000000000000000000000000000000000000000000000000000000001E" + ], + "data": "41646465642074776F206E756D62657273000000000000000000000000000000", + "height": 1 + } + ] + } } }` var serverDuration uint = 100 -type ( - BlockRange struct { - Min int `json:"min"` - Max int `json:"max"` - } -) - type ( ChainData struct { PrivValidator *state.PrivValidator `json:"priv_validator"` Genesis *state.GenesisDoc `json:"genesis"` } - Input struct { - AccountAddress string `json:"account_address"` - StorageAddress string `json:"storage_address"` - TxCreate *edb.TransactParam `json:"tx_create"` - Tx *edb.TransactParam `json:"tx"` - CallCode *edb.CallCodeParam `json:"call_code"` - BlockRange *BlockRange `json:"block_range"` - PrivAccount *account.PrivAccount `json:"priv_account"` + GetAccountData struct { + Input *edb.AddressParam `json:"input"` + Output *account.Account `json:"output"` + } + + GetAccountsData struct { + Input *edb.AccountsParam `json:"input"` + Output *ep.AccountList `json:"output"` + } + + GetStorageData struct { + Input *edb.AddressParam `json:"input"` + Output *ep.Storage `json:"output"` + } + + GetStorageAtData struct { + Input *edb.StorageAtParam `json:"input"` + Output *ep.StorageItem `json:"output"` + } + + GenPrivAccountData struct { + Output *account.PrivAccount `json:"output"` + } + + GetBlockchainInfoData struct { + Output *ep.BlockchainInfo `json:"output"` + } + + GetChainIdData struct { + Output *ep.ChainId `json:"output"` + } + + GetGenesisHashData struct { + Output *ep.GenesisHash `json:"output"` + } + + GetLatestBlockHeightData struct { + Output *ep.LatestBlockHeight `json:"output"` + } + + GetLatestBlockData struct { + Output *types.Block `json:"output"` + } + + GetBlockData struct { + Input *edb.HeightParam `json:"input"` + Output *types.Block `json:"output"` + } + + GetBlocksData struct { + Input *edb.BlocksParam `json:"input"` + Output *ep.Blocks `json:"output"` + } + + GetConsensusStateData struct { + Output *ep.ConsensusState `json:"output"` + } + + GetValidatorsData struct { + Output *ep.ValidatorList `json:"output"` + } + + GetNetworkInfoData struct { + Output *ep.NetworkInfo `json:"output"` + } + + GetClientVersionData struct { + Output *ep.ClientVersion `json:"output"` + } + + GetMonikerData struct { + Output *ep.Moniker `json:"output"` + } + + IsListeningData struct { + Output *ep.Listening `json:"output"` + } + + GetListenersData struct { + Output *ep.Listeners `json:"output"` + } + + GetPeersData struct { + Output []*ep.Peer `json:"output"` + } + + GetPeerData struct { + Input *edb.PeerParam `json:"input"` + Output *ep.Peer `json:"output"` + } + + TransactData struct { + Input *edb.TransactParam `json:"input"` + Output *ep.Receipt `json:"output"` + } + + TransactCreateData struct { + Input *edb.TransactParam `json:"input"` + Output *ep.Receipt `json:"output"` + } + + GetUnconfirmedTxsData struct { + Output *ep.UnconfirmedTxs `json:"output"` + } + + CallCodeData struct { + Input *edb.CallCodeParam `json:"input"` + Output *ep.Call `json:"output"` + } + + CallData struct { + Input *edb.CallParam `json:"input"` + Output *ep.Call `json:"output"` + } + + EventSubscribeData struct { + Input *edb.EventIdParam `json:"input"` + Output *ep.EventSub `json:"output"` } - Output struct { - ConsensusState *ep.ConsensusState `json:"consensus_state"` - Validators *ep.ValidatorList `json:"validators"` - NetworkInfo *ep.NetworkInfo `json:"network_info"` - ClientVersion *ep.ClientVersion `json:"client_version"` - Moniker *ep.Moniker `json:"moniker"` - Listening *ep.Listening `json:"listening"` - Listeners *ep.Listeners `json:"listeners"` - Peers []*ep.Peer `json:"peers"` - TxCreateReceipt *ep.Receipt `json:"tx_create_receipt"` - TxReceipt *ep.Receipt `json:"tx_receipt"` - UnconfirmedTxs *ep.UnconfirmedTxs `json:"unconfirmed_txs"` - CallCode *ep.Call `json:"call_code"` - Accounts *ep.AccountList `json:"accounts"` - Account *account.Account `json:"account"` - Storage *ep.Storage `json:"storage"` - StorageAt *ep.StorageItem `json:"storage_at"` - BlockchainInfo *ep.BlockchainInfo `json:"blockchain_info"` - ChainId *ep.ChainId `json:"chain_id"` - GenesisHash *ep.GenesisHash `json:"genesis_hash"` - LatestBlockHeight *ep.LatestBlockHeight `json:"latest_block_height"` - Block *types.Block `json:"block"` - Blocks *ep.Blocks `json:"blocks"` - GenPrivAccount *account.PrivAccount `json:"gen_priv_account"` + EventUnsubscribeData struct { + Input *edb.SubIdParam `json:"input"` + Output *ep.EventUnsub `json:"output"` } + /* + EventPollData struct { + Input *edb.SubIdParam `json:"input"` + Output *ep.PollResponse `json:"output"` + } + */ + TestData struct { - ChainData *ChainData `json:"chain_data"` - Input *Input `json:"input"` - Output *Output `json:"output"` + ChainData *ChainData `json:"chain_data"` + GetAccount *GetAccountData + GetAccounts *GetAccountsData + GetStorage *GetStorageData + GetStorageAt *GetStorageAtData + GenPrivAccount *GenPrivAccountData + GetBlockchainInfo *GetBlockchainInfoData + GetChainId *GetChainIdData + GetGenesisHash *GetGenesisHashData + GetLatestBlockHeight *GetLatestBlockHeightData + GetLatestBlock *GetLatestBlockData + GetBlock *GetBlockData + GetBlocks *GetBlocksData + GetConsensusState *GetConsensusStateData + GetValidators *GetValidatorsData + GetNetworkInfo *GetNetworkInfoData + GetClientVersion *GetClientVersionData + GetMoniker *GetMonikerData + IsListening *IsListeningData + GetListeners *GetListenersData + GetPeers *GetPeersData + // GetPeer *GetPeerData + Transact *TransactData + TransactCreate *TransactCreateData + GetUnconfirmedTxs *GetUnconfirmedTxsData + CallCode *CallCodeData + Call *CallData + EventSubscribe *EventSubscribeData + EventUnsubscribe *EventUnsubscribeData + // EventPoll *EventPollData } ) diff --git a/test/web_api/web_api_test.go b/test/web_api/web_api_test.go index e44166e9..ede734ce 100644 --- a/test/web_api/web_api_test.go +++ b/test/web_api/web_api_test.go @@ -3,6 +3,7 @@ package web_api // Basic imports import ( "bytes" + "encoding/hex" "fmt" // edb "github.com/eris-ltd/erisdb/erisdb" "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" @@ -74,7 +75,7 @@ func (this *WebApiSuite) Test_A0_ConsensusState() { errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) ret.StartTime = "" - this.Equal(ret, this.testData.Output.ConsensusState) + this.Equal(ret, this.testData.GetConsensusState.Output) } func (this *WebApiSuite) Test_A1_Validators() { @@ -82,7 +83,7 @@ func (this *WebApiSuite) Test_A1_Validators() { ret := &ep.ValidatorList{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Validators) + this.Equal(ret, this.testData.GetValidators.Output) } // ********************************************* Network ********************************************* @@ -92,7 +93,7 @@ func (this *WebApiSuite) Test_B0_NetworkInfo() { ret := &ep.NetworkInfo{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.NetworkInfo) + this.Equal(ret, this.testData.GetNetworkInfo.Output) } func (this *WebApiSuite) Test_B1_ClientVersion() { @@ -100,7 +101,7 @@ func (this *WebApiSuite) Test_B1_ClientVersion() { ret := &ep.ClientVersion{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.ClientVersion) + this.Equal(ret, this.testData.GetClientVersion.Output) } func (this *WebApiSuite) Test_B2_Moniker() { @@ -108,7 +109,7 @@ func (this *WebApiSuite) Test_B2_Moniker() { ret := &ep.Moniker{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Moniker) + this.Equal(ret, this.testData.GetMoniker.Output) } func (this *WebApiSuite) Test_B3_Listening() { @@ -116,7 +117,7 @@ func (this *WebApiSuite) Test_B3_Listening() { ret := &ep.Listening{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Listening) + this.Equal(ret, this.testData.IsListening.Output) } func (this *WebApiSuite) Test_B4_Listeners() { @@ -124,7 +125,7 @@ func (this *WebApiSuite) Test_B4_Listeners() { ret := &ep.Listeners{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Listeners) + this.Equal(ret, this.testData.GetListeners.Output) } func (this *WebApiSuite) Test_B5_Peers() { @@ -132,25 +133,25 @@ func (this *WebApiSuite) Test_B5_Peers() { ret := []*ep.Peer{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Peers) + this.Equal(ret, this.testData.GetPeers.Output) } // ********************************************* Transactions ********************************************* func (this *WebApiSuite) Test_C0_TxCreate() { - resp := this.postJson("/unsafe/txpool", this.testData.Input.TxCreate) + resp := this.postJson("/unsafe/txpool", this.testData.TransactCreate.Input) ret := &ep.Receipt{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.TxCreateReceipt) + this.Equal(ret, this.testData.TransactCreate.Output) } func (this *WebApiSuite) Test_C1_Tx() { - resp := this.postJson("/unsafe/txpool", this.testData.Input.Tx) + resp := this.postJson("/unsafe/txpool", this.testData.Transact.Input) ret := &ep.Receipt{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.TxReceipt) + this.Equal(ret, this.testData.Transact.Output) } func (this *WebApiSuite) Test_C2_UnconfirmedTxs() { @@ -158,94 +159,95 @@ func (this *WebApiSuite) Test_C2_UnconfirmedTxs() { ret := &ep.UnconfirmedTxs{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.UnconfirmedTxs) + this.Equal(ret, this.testData.GetUnconfirmedTxs.Output) } func (this *WebApiSuite) Test_C3_CallCode() { - resp := this.postJson("/codecalls", this.testData.Input.CallCode) + resp := this.postJson("/codecalls", this.testData.CallCode.Input) ret := &ep.Call{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.CallCode) + this.Equal(ret, this.testData.CallCode.Output) } // ********************************************* Accounts ********************************************* -func (this *WebApiSuite) Test_D0_Accounts() { +func (this *WebApiSuite) Test_D0_GetAccounts() { resp := this.get("/accounts") ret := &ep.AccountList{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Accounts) + this.Equal(ret, this.testData.GetAccounts.Output) } -func (this *WebApiSuite) Test_D1_Account() { - resp := this.get("/accounts/" + this.testData.Input.AccountAddress) +func (this *WebApiSuite) Test_D1_GetAccount() { + addr := hex.EncodeToString(this.testData.GetAccount.Input.Address) + resp := this.get("/accounts/" + addr) ret := &account.Account{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Account) + this.Equal(ret, this.testData.GetAccount.Output) } -func (this *WebApiSuite) Test_D2_Storage() { - resp := this.get("/accounts/" + this.testData.Input.AccountAddress + "/storage") +func (this *WebApiSuite) Test_D2_GetStorage() { + addr := hex.EncodeToString(this.testData.GetStorage.Input.Address) + resp := this.get("/accounts/" + addr + "/storage") ret := &ep.Storage{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Storage) + this.Equal(ret, this.testData.GetStorage.Output) } -func (this *WebApiSuite) Test_D3_StorageAt() { - addr := this.testData.Input.AccountAddress - key := this.testData.Input.StorageAddress +func (this *WebApiSuite) Test_D3_GetStorageAt() { + addr := hex.EncodeToString(this.testData.GetStorageAt.Input.Address) + key := hex.EncodeToString(this.testData.GetStorageAt.Input.Key) resp := this.get("/accounts/" + addr + "/storage/" + key) ret := &ep.StorageItem{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.StorageAt) + this.Equal(ret, this.testData.GetStorageAt.Output) } // ********************************************* Blockchain ********************************************* -func (this *WebApiSuite) Test_E0_BlockchainInfo() { +func (this *WebApiSuite) Test_E0_GetBlockchainInfo() { resp := this.get("/blockchain") ret := &ep.BlockchainInfo{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.BlockchainInfo) + this.Equal(ret, this.testData.GetBlockchainInfo.Output) } -func (this *WebApiSuite) Test_E1_ChainId() { +func (this *WebApiSuite) Test_E1_GetChainId() { resp := this.get("/blockchain/chain_id") ret := &ep.ChainId{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.ChainId) + this.Equal(ret, this.testData.GetChainId.Output) } -func (this *WebApiSuite) Test_E2_GenesisHash() { +func (this *WebApiSuite) Test_E2_GetGenesisHash() { resp := this.get("/blockchain/genesis_hash") ret := &ep.GenesisHash{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.GenesisHash) + this.Equal(ret, this.testData.GetGenesisHash.Output) } -func (this *WebApiSuite) Test_E3_LatestBlockHeight() { +func (this *WebApiSuite) Test_E3_GetLatestBlockHeight() { resp := this.get("/blockchain/latest_block_height") ret := &ep.LatestBlockHeight{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.LatestBlockHeight) + this.Equal(ret, this.testData.GetLatestBlockHeight.Output) } -func (this *WebApiSuite) Test_E4_Blocks() { - br := this.testData.Input.BlockRange - resp := this.get(fmt.Sprintf("/blockchain/blocks?q=height:%d..%d", br.Min, br.Max)) +func (this *WebApiSuite) Test_E4_GetBlocks() { + resp := this.get("/blockchain/blocks") ret := &ep.Blocks{} errD := this.codec.Decode(ret, resp.Body) this.NoError(errD) - this.Equal(ret, this.testData.Output.Blocks) + this.Equal(ret, this.testData.GetBlocks.Output) } // ********************************************* Utilities ********************************************* -- GitLab