mirror of https://github.com/certusone/wasmd.git
WIP: fixing types in tests
This commit is contained in:
parent
99be1ca85e
commit
9d2cbc9c66
|
@ -52,8 +52,8 @@ func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState {
|
|||
var state []types.Model
|
||||
for ; contractStateIterator.Valid(); contractStateIterator.Next() {
|
||||
m := types.Model{
|
||||
Key: string(contractStateIterator.Key()),
|
||||
Value: string(contractStateIterator.Value()),
|
||||
Key: contractStateIterator.Key(),
|
||||
Value: contractStateIterator.Value(),
|
||||
}
|
||||
state = append(state, m)
|
||||
}
|
||||
|
|
|
@ -193,8 +193,8 @@ func (k Keeper) QueryRaw(ctx sdk.Context, contractAddress sdk.AccAddress, key []
|
|||
|
||||
if val := prefixStore.Get(key); val != nil {
|
||||
return append(result, types.Model{
|
||||
Key: string(key),
|
||||
Value: string(val),
|
||||
Key: key,
|
||||
Value: val,
|
||||
})
|
||||
}
|
||||
return result
|
||||
|
|
|
@ -90,9 +90,8 @@ func queryContractState(ctx sdk.Context, bech, queryMethod string, req abci.Requ
|
|||
case QueryMethodContractStateAll:
|
||||
for iter := keeper.GetContractState(ctx, contractAddr); iter.Valid(); iter.Next() {
|
||||
resultData = append(resultData, types.Model{
|
||||
// TODO: binary and raw json
|
||||
Key: string(iter.Key()),
|
||||
Value: string(iter.Value()),
|
||||
Key: iter.Key(),
|
||||
Value: iter.Value(),
|
||||
})
|
||||
}
|
||||
if resultData == nil {
|
||||
|
|
|
@ -15,10 +15,7 @@ import (
|
|||
)
|
||||
|
||||
func TestQueryContractState(t *testing.T) {
|
||||
type model struct {
|
||||
Key string `json:"key"`
|
||||
Value string `json:"val"`
|
||||
}
|
||||
type model = types.Model
|
||||
|
||||
tempDir, err := ioutil.TempDir("", "wasm")
|
||||
require.NoError(t, err)
|
||||
|
@ -48,8 +45,8 @@ func TestQueryContractState(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
contractModel := []types.Model{
|
||||
{Key: "foo", Value: "bar"},
|
||||
{Key: string([]byte{0x0, 0x1}), Value: string([]byte{0x2, 0x3})},
|
||||
{Key: []byte("foo"), Value: []byte("\"bar\"")},
|
||||
{Key: []byte{0x0, 0x1}, Value: []byte("{}")},
|
||||
}
|
||||
keeper.setContractState(ctx, addr, contractModel)
|
||||
|
||||
|
@ -70,21 +67,21 @@ func TestQueryContractState(t *testing.T) {
|
|||
srcPath: []string{QueryGetContractState, addr.String(), QueryMethodContractStateAll},
|
||||
expModelLen: 3,
|
||||
expModelContains: []model{
|
||||
{Key: "foo", Value: "bar"},
|
||||
{Key: string([]byte{0x0, 0x1}), Value: string([]byte{0x2, 0x3})},
|
||||
{Key: []byte("foo"), Value: []byte(`"bar"`)},
|
||||
{Key: []byte{0x0, 0x1}, Value: []byte(`{"count":8}`)},
|
||||
},
|
||||
},
|
||||
"query raw key": {
|
||||
srcPath: []string{QueryGetContractState, addr.String(), QueryMethodContractStateRaw},
|
||||
srcReq: abci.RequestQuery{Data: []byte("foo")},
|
||||
expModelLen: 1,
|
||||
expModelContains: []model{{Key: "foo", Value: "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: string([]byte{0x0, 0x1}), Value: string([]byte{0x2, 0x3})}},
|
||||
expModelContains: []model{{Key: []byte{0x0, 0x1}, Value: []byte("798")},
|
||||
},
|
||||
"query smart": {
|
||||
srcPath: []string{QueryGetContractState, addr.String(), QueryMethodContractStateSmart},
|
||||
|
|
|
@ -20,10 +20,10 @@ type Model struct {
|
|||
|
||||
// CodeInfo is data for the uploaded contract WASM code
|
||||
type CodeInfo struct {
|
||||
CodeHash tmBytes.HexBytes `json:"code_hash"`
|
||||
Creator sdk.AccAddress `json:"creator"`
|
||||
Source string `json:"source"`
|
||||
Builder string `json:"builder"`
|
||||
CodeHash []byte `json:"code_hash"`
|
||||
Creator sdk.AccAddress `json:"creator"`
|
||||
Source string `json:"source"`
|
||||
Builder string `json:"builder"`
|
||||
}
|
||||
|
||||
// NewCodeInfo fills a new Contract struct
|
||||
|
|
Loading…
Reference in New Issue