mirror of https://github.com/certusone/wasmd.git
Fix tests
This commit is contained in:
parent
9d2cbc9c66
commit
33c4e92bdf
|
@ -104,7 +104,7 @@ func queryContractState(ctx sdk.Context, bech, queryMethod string, req abci.Requ
|
|||
default:
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, queryMethod)
|
||||
}
|
||||
bz, err := json.MarshalIndent(resultData, "", " ")
|
||||
bz, err := json.Marshal(resultData)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
|
||||
}
|
||||
|
|
|
@ -45,8 +45,8 @@ func TestQueryContractState(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
contractModel := []types.Model{
|
||||
{Key: []byte("foo"), Value: []byte("\"bar\"")},
|
||||
{Key: []byte{0x0, 0x1}, Value: []byte("{}")},
|
||||
{Key: []byte("foo"), Value: []byte(`"bar"`)},
|
||||
{Key: []byte{0x0, 0x1}, Value: []byte(`{"count":8}`)},
|
||||
}
|
||||
keeper.setContractState(ctx, addr, contractModel)
|
||||
|
||||
|
@ -75,13 +75,13 @@ func TestQueryContractState(t *testing.T) {
|
|||
srcPath: []string{QueryGetContractState, addr.String(), QueryMethodContractStateRaw},
|
||||
srcReq: abci.RequestQuery{Data: []byte("foo")},
|
||||
expModelLen: 1,
|
||||
expModelContains: []model{{Key: []byte("foo"), Value: []byte(`["bar"]`)}},
|
||||
expModelContains: []model{{Key: []byte("foo"), Value: []byte(`"bar"`)}},
|
||||
},
|
||||
"query raw binary key": {
|
||||
srcPath: []string{QueryGetContractState, addr.String(), QueryMethodContractStateRaw},
|
||||
srcReq: abci.RequestQuery{Data: []byte{0x0, 0x1}},
|
||||
expModelLen: 1,
|
||||
expModelContains: []model{{Key: []byte{0x0, 0x1}, Value: []byte("798")},
|
||||
expModelContains: []model{{Key: []byte{0x0, 0x1}, Value: []byte(`{"count":8}`)}},
|
||||
},
|
||||
"query smart": {
|
||||
srcPath: []string{QueryGetContractState, addr.String(), QueryMethodContractStateSmart},
|
||||
|
|
|
@ -398,25 +398,20 @@ func assertContractList(t *testing.T, q sdk.Querier, ctx sdk.Context, addrs []st
|
|||
assert.Equal(t, addrs, res)
|
||||
}
|
||||
|
||||
type model struct {
|
||||
Key string `json:"key"`
|
||||
Value string `json:"val"`
|
||||
}
|
||||
|
||||
func assertContractState(t *testing.T, q sdk.Querier, ctx sdk.Context, addr sdk.AccAddress, expected state) {
|
||||
path := []string{QueryGetContractState, addr.String(), keeper.QueryMethodContractStateAll}
|
||||
bz, sdkerr := q(ctx, path, abci.RequestQuery{})
|
||||
require.NoError(t, sdkerr)
|
||||
|
||||
var res []model
|
||||
var res []Model
|
||||
err := json.Unmarshal(bz, &res)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(res), "#v", res)
|
||||
require.Equal(t, "config", res[0].Key)
|
||||
require.Equal(t, []byte("config"), []byte(res[0].Key))
|
||||
|
||||
expectedBz, err := json.Marshal(expected)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, string(expectedBz), res[0].Value)
|
||||
assert.Equal(t, json.RawMessage(expectedBz), res[0].Value)
|
||||
}
|
||||
|
||||
func assertContractInfo(t *testing.T, q sdk.Querier, ctx sdk.Context, addr sdk.AccAddress, codeID uint64, creator sdk.AccAddress) {
|
||||
|
|
Loading…
Reference in New Issue