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)
|
prefixStoreKey := types.GetContractStorePrefixKey(contractAddress)
|
||||||
prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), prefixStoreKey)
|
prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), prefixStoreKey)
|
||||||
return []types.Model{{
|
if val := prefixStore.Get(key); val != nil {
|
||||||
Key: string(key),
|
return []types.Model{{
|
||||||
Value: string(prefixStore.Get(key)),
|
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) {
|
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
|
//expModelContains: []model{}, // stopping here as contract internals are not stable
|
||||||
},
|
},
|
||||||
"query unknown raw key": {
|
"query unknown raw key": {
|
||||||
srcPath: []string{QueryGetContractState, addr.String(), QueryMethodContractStateRaw},
|
srcPath: []string{QueryGetContractState, addr.String(), QueryMethodContractStateRaw},
|
||||||
srcReq: abci.RequestQuery{Data: []byte("unknown")},
|
srcReq: abci.RequestQuery{Data: []byte("unknown")},
|
||||||
expModelLen: 1,
|
expModelLen: 0,
|
||||||
expModelContains: []model{{Key: "unknown", Value: ""}},
|
|
||||||
},
|
},
|
||||||
"query empty raw key": {
|
"query empty raw key": {
|
||||||
srcPath: []string{QueryGetContractState, addr.String(), QueryMethodContractStateRaw},
|
srcPath: []string{QueryGetContractState, addr.String(), QueryMethodContractStateRaw},
|
||||||
|
|
Loading…
Reference in New Issue