From b878edc388788542b55398c1923b742e63c4ecc2 Mon Sep 17 00:00:00 2001 From: HaoyangLiu Date: Thu, 30 Aug 2018 15:52:17 +0800 Subject: [PATCH] IRISHUB-238: fix failures in test_lint and test_cover --- client/context/client_manager_test.go | 2 +- client/context/context.go | 2 +- client/context/query.go | 20 ++++++++++---------- client/lcd/test_helpers.go | 2 ++ store/multistoreproof.go | 2 +- store/multistoreproof_test.go | 2 +- store/rootmultistore.go | 3 +-- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/client/context/client_manager_test.go b/client/context/client_manager_test.go index c060e11cea..1960f74ced 100644 --- a/client/context/client_manager_test.go +++ b/client/context/client_manager_test.go @@ -13,4 +13,4 @@ func TestClientManager(t *testing.T) { assert.NotEqual(t, endpoint, clientMgr.getClient()) clientMgr.getClient() assert.Equal(t, endpoint, clientMgr.getClient()) -} \ No newline at end of file +} diff --git a/client/context/context.go b/client/context/context.go index b57e336657..28506756cf 100644 --- a/client/context/context.go +++ b/client/context/context.go @@ -9,8 +9,8 @@ import ( "github.com/spf13/viper" - rpcclient "github.com/tendermint/tendermint/rpc/client" tendermintLite "github.com/tendermint/tendermint/lite" + rpcclient "github.com/tendermint/tendermint/rpc/client" ) const ctxAccStoreName = "acc" diff --git a/client/context/query.go b/client/context/query.go index 72defb0d4a..aac0c90306 100644 --- a/client/context/query.go +++ b/client/context/query.go @@ -10,14 +10,14 @@ import ( "github.com/pkg/errors" - cmn "github.com/tendermint/tendermint/libs/common" - rpcclient "github.com/tendermint/tendermint/rpc/client" - ctypes "github.com/tendermint/tendermint/rpc/core/types" "github.com/cosmos/cosmos-sdk/store" "github.com/cosmos/cosmos-sdk/wire" - "strings" - tendermintLiteProxy "github.com/tendermint/tendermint/lite/proxy" abci "github.com/tendermint/tendermint/abci/types" + cmn "github.com/tendermint/tendermint/libs/common" + tendermintLiteProxy "github.com/tendermint/tendermint/lite/proxy" + rpcclient "github.com/tendermint/tendermint/rpc/client" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + "strings" ) // GetNode returns an RPC client. If the context's client is not defined, an @@ -351,18 +351,18 @@ func (ctx CLIContext) verifyProof(path string, resp abci.ResponseQuery) error { cdc := wire.NewCodec() err = cdc.UnmarshalBinary(resp.Proof, &multiStoreProof) if err != nil { - return errors.Wrap(err, "failed to unmarshalBinary rangeProof") + return errors.Wrap(err, "failed to unmarshalBinary rangeProof") } // Validate the substore commit hash against trusted appHash - substoreCommitHash, err := store.VerifyMultiStoreCommitInfo(multiStoreProof.StoreName, + substoreCommitHash, err := store.VerifyMultiStoreCommitInfo(multiStoreProof.StoreName, multiStoreProof.CommitIDList, commit.Header.AppHash) if err != nil { - return errors.Wrap(err, "failed in verifying the proof against appHash") + return errors.Wrap(err, "failed in verifying the proof against appHash") } err = store.VerifyRangeProof(resp.Key, resp.Value, substoreCommitHash, &multiStoreProof.RangeProof) if err != nil { - return errors.Wrap(err, "failed in the range proof verification") + return errors.Wrap(err, "failed in the range proof verification") } return nil } @@ -377,7 +377,7 @@ func (ctx CLIContext) queryStore(key cmn.HexBytes, storeName, endPath string) ([ // isQueryStoreWithProof expects a format like /// // queryType can be app or store // if subpath equals to "/store" or "/key", then return true -func isQueryStoreWithProof(path string) (bool) { +func isQueryStoreWithProof(path string) bool { if !strings.HasPrefix(path, "/") { return false } diff --git a/client/lcd/test_helpers.go b/client/lcd/test_helpers.go index 818eae1e86..8a344976a1 100644 --- a/client/lcd/test_helpers.go +++ b/client/lcd/test_helpers.go @@ -37,6 +37,7 @@ import ( "github.com/tendermint/tendermint/proxy" tmrpc "github.com/tendermint/tendermint/rpc/lib/server" tmtypes "github.com/tendermint/tendermint/types" + "time" ) // makePathname creates a unique pathname for each test. It will panic if it @@ -190,6 +191,7 @@ func InitializeTestLCD(t *testing.T, nValidators int, initAddrs []sdk.AccAddress node, err := startTM(config, logger, genDoc, privVal, app) require.NoError(t, err) + time.Sleep(3 * time.Second) lcd, err := startLCD(logger, listenAddr, cdc) require.NoError(t, err) diff --git a/store/multistoreproof.go b/store/multistoreproof.go index e98a198e93..5ca214bc7d 100644 --- a/store/multistoreproof.go +++ b/store/multistoreproof.go @@ -113,4 +113,4 @@ func VerifyRangeProof(key, value []byte, substoreCommitHash []byte, rangeProof * } return nil -} \ No newline at end of file +} diff --git a/store/multistoreproof_test.go b/store/multistoreproof_test.go index b1667c7265..1538915677 100644 --- a/store/multistoreproof_test.go +++ b/store/multistoreproof_test.go @@ -93,4 +93,4 @@ func TestVerifyRangeProof(t *testing.T) { assert.NotEmpty(t, proof) err = VerifyRangeProof(key, val, root, proof) assert.Nil(t, err) -} \ No newline at end of file +} diff --git a/store/rootmultistore.go b/store/rootmultistore.go index 2a9a9373a4..c5ce52b0ba 100644 --- a/store/rootmultistore.go +++ b/store/rootmultistore.go @@ -292,7 +292,6 @@ func (rs *rootMultiStore) Query(req abci.RequestQuery) abci.ResponseQuery { req.Path = subpath res := queryable.Query(req) - // Currently, only when query subpath is "/store" or "/key", will proof be included in response. // If there are some changes about proof building in iavlstore.go, we must change code here to keep consistency with iavlstore.go if !req.Prove || subpath != "/store" && subpath != "/key" { @@ -300,7 +299,7 @@ func (rs *rootMultiStore) Query(req abci.RequestQuery) abci.ResponseQuery { } //Load commit info from db - commitInfo, errMsg := getCommitInfo(rs.db,res.Height) + commitInfo, errMsg := getCommitInfo(rs.db, res.Height) if errMsg != nil { return sdk.ErrInternal(errMsg.Error()).QueryResult() }