laconicd-deprecated/x/evm/keeper/querier_test.go
thomasmodeneis 5417b4bb54
migrate build to Travis #258 (#259)
* add travis file
* update lint so it reports properly
* disable circleci
* separate test structure into Verify deps & Lint, Unit Tests, Race Tests, Integration Tests
* fix path issue now evident on ci build err
* fixed golangci version to latest stable
* Upgrade ci lint to go script and avoid cache issues #268
* fix lint issues #268
* bump go version for travis build to match go.mod version recently updated with Cosmos SDK upgrade
* add panic for err edge cases on os.Stat
* increase timeout to 10m since its failing on jenkins
* bump GOLANGCI_VERSION to 1.23.8 in order to try avoiding some weird errors on CI
2020-04-29 22:38:57 +02:00

58 lines
1.7 KiB
Go

package keeper_test
import (
"math/big"
"github.com/cosmos/ethermint/x/evm/types"
abci "github.com/tendermint/tendermint/abci/types"
)
func (suite *KeeperTestSuite) TestQuerier() {
testCases := []struct {
msg string
path []string
malleate func()
expPass bool
}{
{"protocol version", []string{types.QueryProtocolVersion}, func() {}, true},
{"balance", []string{types.QueryBalance, addrHex}, func() {
suite.app.EvmKeeper.SetBalance(suite.ctx, address, big.NewInt(5))
}, true},
// {"balance", []string{types.QueryBalance, "0x01232"}, func() {}, false},
{"block number", []string{types.QueryBlockNumber, "0x0"}, func() {}, true},
{"storage", []string{types.QueryStorage, "0x0", "0x0"}, func() {}, true},
{"code", []string{types.QueryCode, "0x0"}, func() {}, true},
{"nonce", []string{types.QueryNonce, "0x0"}, func() {}, true},
// {"hash to height", []string{types.QueryHashToHeight, "0x0"}, func() {}, true},
{"tx logs", []string{types.QueryTxLogs, "0x0"}, func() {}, true},
// {"logs bloom", []string{types.QueryLogsBloom, "0x0"}, func() {}, true},
{"logs", []string{types.QueryLogs, "0x0"}, func() {}, true},
{"account", []string{types.QueryAccount, "0x0"}, func() {}, true},
{"unknown request", []string{"other"}, func() {}, false},
}
for i, tc := range testCases {
suite.Run("", func() {
//nolint
tc := tc
suite.SetupTest() // reset
//nolint
tc.malleate()
bz, err := suite.querier(suite.ctx, tc.path, abci.RequestQuery{})
//nolint
if tc.expPass {
//nolint
suite.Require().NoError(err, "valid test %d failed: %s", i, tc.msg)
suite.Require().NotZero(len(bz))
} else {
//nolint
suite.Require().Error(err, "invalid test %d passed: %s", i, tc.msg)
}
})
}
}