mirror of https://github.com/certusone/wasmd.git
Return empty result for unknown raw key query
This commit is contained in:
parent
1874a6c580
commit
6a76047d57
|
@ -190,10 +190,13 @@ func (k Keeper) QueryRaw(ctx sdk.Context, contractAddress sdk.AccAddress, key []
|
|||
}
|
||||
prefixStoreKey := types.GetContractStorePrefixKey(contractAddress)
|
||||
prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), prefixStoreKey)
|
||||
return []types.Model{{
|
||||
Key: string(key),
|
||||
Value: string(prefixStore.Get(key)),
|
||||
}}
|
||||
if val := prefixStore.Get(key); val != nil {
|
||||
return []types.Model{{
|
||||
Key: string(key),
|
||||
Value: string(val),
|
||||
}}
|
||||
}
|
||||
return []types.Model{}
|
||||
}
|
||||
|
||||
func (k Keeper) contractInstance(ctx sdk.Context, contractAddress sdk.AccAddress) (types.CodeInfo, prefix.Store, sdk.Error) {
|
||||
|
|
|
@ -88,10 +88,9 @@ func TestQueryContractState(t *testing.T) {
|
|||
//expModelContains: []model{}, // stopping here as contract internals are not stable
|
||||
},
|
||||
"query unknown raw key": {
|
||||
srcPath: []string{QueryGetContractState, addr.String(), QueryMethodContractStateRaw},
|
||||
srcReq: abci.RequestQuery{Data: []byte("unknown")},
|
||||
expModelLen: 1,
|
||||
expModelContains: []model{{Key: "unknown", Value: ""}},
|
||||
srcPath: []string{QueryGetContractState, addr.String(), QueryMethodContractStateRaw},
|
||||
srcReq: abci.RequestQuery{Data: []byte("unknown")},
|
||||
expModelLen: 0,
|
||||
},
|
||||
"query empty raw key": {
|
||||
srcPath: []string{QueryGetContractState, addr.String(), QueryMethodContractStateRaw},
|
||||
|
|
Loading…
Reference in New Issue