@agoric/cosmos 0.35.0-upgrade-14-dev-8be87aa.0 → 0.35.0-upgrade-14-dev-c8f9e7b.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Makefile +25 -12
- package/ante/ante.go +7 -5
- package/app/app.go +62 -47
- package/app/export.go +13 -6
- package/cmd/agd/main.go +5 -3
- package/cmd/libdaemon/main.go +5 -2
- package/daemon/cmd/genaccounts.go +13 -9
- package/daemon/cmd/root.go +27 -11
- package/daemon/cmd/root_test.go +1 -1
- package/daemon/cmd/testnet.go +17 -6
- package/daemon/main.go +3 -2
- package/git-revision.txt +1 -1
- package/go.mod +95 -64
- package/go.sum +592 -243
- package/package.json +2 -2
- package/proto/agoric/vstorage/query.proto +53 -1
- package/scripts/protocgen.sh +12 -1
- package/third_party/proto/buf.yaml +1 -0
- package/third_party/proto/cosmos/base/query/v1beta1/pagination.proto +4 -1
- package/third_party/proto/cosmos/base/v1beta1/coin.proto +7 -4
- package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +16 -6
- package/third_party/proto/cosmos_proto/cosmos.proto +97 -0
- package/third_party/proto/google/api/annotations.proto +1 -1
- package/third_party/proto/google/api/http.proto +181 -120
- package/third_party/proto/google/api/httpbody.proto +9 -6
- package/third_party/proto/google/protobuf/any.proto +1 -7
- package/third_party/proto/ibc/core/channel/v1/channel.proto +15 -1
- package/third_party/proto/ibc/core/client/v1/client.proto +9 -6
- package/upgradegaia.sh +13 -4
- package/vm/action.go +24 -21
- package/vm/action_test.go +5 -5
- package/vm/controller.go +9 -10
- package/x/lien/keeper/account.go +3 -3
- package/x/lien/keeper/keeper.go +5 -4
- package/x/lien/keeper/keeper_test.go +8 -8
- package/x/lien/lien.go +6 -4
- package/x/lien/lien_test.go +20 -16
- package/x/swingset/client/cli/query.go +2 -2
- package/x/swingset/client/cli/tx.go +48 -33
- package/x/swingset/client/proposal_handler.go +2 -17
- package/x/swingset/keeper/keeper.go +8 -11
- package/x/swingset/keeper/keeper_test.go +1 -1
- package/x/swingset/keeper/msg_server.go +2 -4
- package/x/swingset/keeper/proposal.go +10 -0
- package/x/swingset/keeper/querier.go +14 -6
- package/x/swingset/proposal_handler.go +3 -3
- package/x/swingset/swingset.go +4 -2
- package/x/swingset/types/codec.go +2 -2
- package/x/swingset/types/msgs.pb.go +16 -16
- package/x/swingset/types/proposal.go +5 -5
- package/x/swingset/types/types.go +30 -28
- package/x/vbank/keeper/keeper.go +3 -2
- package/x/vbank/keeper/querier.go +6 -2
- package/x/vbank/keeper/rewards.go +1 -1
- package/x/vbank/vbank.go +11 -10
- package/x/vbank/vbank_test.go +8 -8
- package/x/vibc/ibc.go +27 -26
- package/x/vibc/keeper/keeper.go +19 -18
- package/x/vibc/types/expected_keepers.go +13 -5
- package/x/vibc/types/msgs.go +1 -1
- package/x/vibc/types/msgs.pb.go +1 -1
- package/x/vstorage/README.md +138 -0
- package/x/vstorage/capdata/capdata.go +298 -0
- package/x/vstorage/capdata/capdata_test.go +352 -0
- package/x/vstorage/client/cli/query.go +51 -4
- package/x/vstorage/keeper/grpc_query.go +221 -0
- package/x/vstorage/keeper/keeper.go +3 -2
- package/x/vstorage/keeper/keeper_grpc_test.go +300 -0
- package/x/vstorage/keeper/keeper_test.go +1 -1
- package/x/vstorage/keeper/querier.go +6 -2
- package/x/vstorage/types/query.pb.go +646 -36
- package/x/vstorage/types/query.pb.gw.go +119 -0
- package/x/vstorage/vstorage.go +16 -15
- package/x/vstorage/vstorage_test.go +5 -5
|
@@ -10,6 +10,7 @@ import (
|
|
|
10
10
|
"strconv"
|
|
11
11
|
"strings"
|
|
12
12
|
|
|
13
|
+
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
|
13
14
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
14
15
|
db "github.com/tendermint/tm-db"
|
|
15
16
|
|
|
@@ -62,7 +63,7 @@ func cutPrefix(s, prefix []byte) (after []byte, found bool) {
|
|
|
62
63
|
// for the various parts of the state machine
|
|
63
64
|
type Keeper struct {
|
|
64
65
|
changeManager ChangeManager
|
|
65
|
-
storeKey
|
|
66
|
+
storeKey storetypes.StoreKey
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
func (bcm *BatchingChangeManager) Track(ctx sdk.Context, k Keeper, entry agoric.KVEntry, isLegacy bool) {
|
|
@@ -116,7 +117,7 @@ func NewBatchingChangeManager() *BatchingChangeManager {
|
|
|
116
117
|
return &bcm
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
func NewKeeper(storeKey
|
|
120
|
+
func NewKeeper(storeKey storetypes.StoreKey) Keeper {
|
|
120
121
|
return Keeper{
|
|
121
122
|
storeKey: storeKey,
|
|
122
123
|
changeManager: NewBatchingChangeManager(),
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
package keeper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"reflect"
|
|
6
|
+
"strings"
|
|
7
|
+
"testing"
|
|
8
|
+
|
|
9
|
+
grpcCodes "google.golang.org/grpc/codes"
|
|
10
|
+
grpcStatus "google.golang.org/grpc/status"
|
|
11
|
+
|
|
12
|
+
agoric "github.com/Agoric/agoric-sdk/golang/cosmos/types"
|
|
13
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/capdata"
|
|
14
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/types"
|
|
15
|
+
|
|
16
|
+
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
func ptr[T any](v T) *T {
|
|
20
|
+
return &v
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
func mustJsonMarshal(val any) string {
|
|
24
|
+
jsonText, err := capdata.JsonMarshal(val)
|
|
25
|
+
if err != nil {
|
|
26
|
+
panic(err)
|
|
27
|
+
}
|
|
28
|
+
return string(jsonText)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
func mustMarshalStreamCell(blockHeight string, values []string) string {
|
|
32
|
+
cell := map[string]any{
|
|
33
|
+
"blockHeight": blockHeight,
|
|
34
|
+
"values": values,
|
|
35
|
+
}
|
|
36
|
+
return mustJsonMarshal(cell)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
func TestCapData(t *testing.T) {
|
|
40
|
+
testKit := makeTestKit()
|
|
41
|
+
ctx, keeper := testKit.ctx, testKit.vstorageKeeper
|
|
42
|
+
querier := Querier{keeper}
|
|
43
|
+
|
|
44
|
+
type testCase struct {
|
|
45
|
+
label string
|
|
46
|
+
data *string
|
|
47
|
+
request types.QueryCapDataRequest
|
|
48
|
+
expected types.QueryCapDataResponse
|
|
49
|
+
errCode grpcCodes.Code
|
|
50
|
+
errContains *string
|
|
51
|
+
}
|
|
52
|
+
testCases := []testCase{}
|
|
53
|
+
|
|
54
|
+
// Test simple cases (various kinds of bad data up to simple flat JSON-compatible CapData).
|
|
55
|
+
decodableSmallcaps := `{"body":"#true","slots":[]}`
|
|
56
|
+
decodableLegacy := `{"body":"true","slots":[]}`
|
|
57
|
+
testCases = append(testCases, []testCase{
|
|
58
|
+
{label: "no data",
|
|
59
|
+
data: nil,
|
|
60
|
+
request: types.QueryCapDataRequest{RemotableValueFormat: "string"},
|
|
61
|
+
errCode: grpcCodes.FailedPrecondition,
|
|
62
|
+
errContains: ptr("no data"),
|
|
63
|
+
},
|
|
64
|
+
{label: "zero-length data",
|
|
65
|
+
data: ptr(""),
|
|
66
|
+
request: types.QueryCapDataRequest{RemotableValueFormat: "string"},
|
|
67
|
+
errCode: grpcCodes.FailedPrecondition,
|
|
68
|
+
errContains: ptr("JSON"),
|
|
69
|
+
},
|
|
70
|
+
{label: "cell with empty string",
|
|
71
|
+
data: ptr(mustMarshalStreamCell("1", []string{decodableSmallcaps, "", decodableLegacy})),
|
|
72
|
+
request: types.QueryCapDataRequest{RemotableValueFormat: "string"},
|
|
73
|
+
errCode: grpcCodes.FailedPrecondition,
|
|
74
|
+
errContains: ptr("JSON"),
|
|
75
|
+
},
|
|
76
|
+
{label: "non-JSON data",
|
|
77
|
+
data: ptr("foo"),
|
|
78
|
+
request: types.QueryCapDataRequest{RemotableValueFormat: "string"},
|
|
79
|
+
errCode: grpcCodes.FailedPrecondition,
|
|
80
|
+
errContains: ptr("invalid"),
|
|
81
|
+
},
|
|
82
|
+
{label: "cell with non-JSON",
|
|
83
|
+
data: ptr(mustMarshalStreamCell("1", []string{decodableSmallcaps, "foo", decodableLegacy})),
|
|
84
|
+
request: types.QueryCapDataRequest{RemotableValueFormat: "string"},
|
|
85
|
+
errCode: grpcCodes.FailedPrecondition,
|
|
86
|
+
errContains: ptr("invalid"),
|
|
87
|
+
},
|
|
88
|
+
{label: "lone non-CapData",
|
|
89
|
+
data: ptr("{}"),
|
|
90
|
+
request: types.QueryCapDataRequest{RemotableValueFormat: "string"},
|
|
91
|
+
errCode: grpcCodes.FailedPrecondition,
|
|
92
|
+
errContains: ptr("invalid CapData"),
|
|
93
|
+
},
|
|
94
|
+
{label: "cell with non-CapData",
|
|
95
|
+
data: ptr(mustMarshalStreamCell("1", []string{decodableSmallcaps, "{}", decodableLegacy})),
|
|
96
|
+
request: types.QueryCapDataRequest{RemotableValueFormat: "string"},
|
|
97
|
+
errCode: grpcCodes.FailedPrecondition,
|
|
98
|
+
errContains: ptr("invalid CapData"),
|
|
99
|
+
},
|
|
100
|
+
{label: "lone smallcaps CapData",
|
|
101
|
+
data: ptr(decodableSmallcaps),
|
|
102
|
+
request: types.QueryCapDataRequest{RemotableValueFormat: "string"},
|
|
103
|
+
expected: types.QueryCapDataResponse{Value: `true`},
|
|
104
|
+
},
|
|
105
|
+
{label: "cell with smallcaps CapData",
|
|
106
|
+
data: ptr(mustMarshalStreamCell("1", []string{decodableSmallcaps})),
|
|
107
|
+
request: types.QueryCapDataRequest{RemotableValueFormat: "string"},
|
|
108
|
+
expected: types.QueryCapDataResponse{BlockHeight: "1", Value: `true`},
|
|
109
|
+
},
|
|
110
|
+
{label: "lone legacy CapData",
|
|
111
|
+
data: ptr(decodableLegacy),
|
|
112
|
+
request: types.QueryCapDataRequest{RemotableValueFormat: "string"},
|
|
113
|
+
expected: types.QueryCapDataResponse{Value: `true`},
|
|
114
|
+
},
|
|
115
|
+
{label: "cell with legacy CapData",
|
|
116
|
+
data: ptr(mustMarshalStreamCell("1", []string{decodableLegacy})),
|
|
117
|
+
request: types.QueryCapDataRequest{RemotableValueFormat: "string"},
|
|
118
|
+
expected: types.QueryCapDataResponse{BlockHeight: "1", Value: `true`},
|
|
119
|
+
},
|
|
120
|
+
}...)
|
|
121
|
+
|
|
122
|
+
// Test option validation.
|
|
123
|
+
testCases = append(testCases, []testCase{
|
|
124
|
+
{label: "explicit JSON Lines",
|
|
125
|
+
data: ptr(decodableSmallcaps),
|
|
126
|
+
request: types.QueryCapDataRequest{MediaType: "JSON Lines", RemotableValueFormat: "string"},
|
|
127
|
+
expected: types.QueryCapDataResponse{Value: `true`},
|
|
128
|
+
},
|
|
129
|
+
{label: "invalid media type",
|
|
130
|
+
data: ptr(decodableSmallcaps),
|
|
131
|
+
request: types.QueryCapDataRequest{MediaType: "JSONLines", RemotableValueFormat: "string"},
|
|
132
|
+
errCode: grpcCodes.InvalidArgument,
|
|
133
|
+
errContains: ptr("media_type"),
|
|
134
|
+
},
|
|
135
|
+
{label: "invalid item format",
|
|
136
|
+
data: ptr(decodableSmallcaps),
|
|
137
|
+
request: types.QueryCapDataRequest{ItemFormat: "deep", RemotableValueFormat: "string"},
|
|
138
|
+
errCode: grpcCodes.InvalidArgument,
|
|
139
|
+
errContains: ptr("item_format"),
|
|
140
|
+
},
|
|
141
|
+
{label: "missing remotable value format",
|
|
142
|
+
data: ptr(decodableSmallcaps),
|
|
143
|
+
request: types.QueryCapDataRequest{},
|
|
144
|
+
errCode: grpcCodes.InvalidArgument,
|
|
145
|
+
errContains: ptr("remotable_value_format"),
|
|
146
|
+
},
|
|
147
|
+
{label: "invalid remotable value format",
|
|
148
|
+
data: ptr(decodableSmallcaps),
|
|
149
|
+
request: types.QueryCapDataRequest{RemotableValueFormat: "foo"},
|
|
150
|
+
errCode: grpcCodes.InvalidArgument,
|
|
151
|
+
errContains: ptr("remotable_value_format"),
|
|
152
|
+
},
|
|
153
|
+
}...)
|
|
154
|
+
|
|
155
|
+
// Test formatting options against sufficiently complex CapData,
|
|
156
|
+
// deriving legacy encoding from smallcaps encoding to ensure equivalence
|
|
157
|
+
// and deriving expectations from marshalling to avoid spurious mismatches
|
|
158
|
+
// from Go's unpredictable field ordering (e.g., `{"a":0,"b":1}` vs. `{"b":1,"a":0}`).
|
|
159
|
+
slots := []any{"a"}
|
|
160
|
+
deepSmallcapsBody := `{"arr":[{"bigint":"+42","remotable":"$0.Alleged: Foo brand","ref2":"$0"}]}`
|
|
161
|
+
deepLegacyBody := deepSmallcapsBody
|
|
162
|
+
legacyFromSmallcaps := [][2]string{
|
|
163
|
+
[2]string{`"+42"`, `{"@qclass":"bigint","digits":"42"}`},
|
|
164
|
+
[2]string{`"$0.Alleged: Foo brand"`, `{"@qclass":"slot","index":0,"iface":"Alleged: Foo brand"}`},
|
|
165
|
+
[2]string{`"$0"`, `{"@qclass":"slot","index":0}`},
|
|
166
|
+
}
|
|
167
|
+
for _, pair := range legacyFromSmallcaps {
|
|
168
|
+
deepLegacyBody = strings.Replace(deepLegacyBody, pair[0], pair[1], -1)
|
|
169
|
+
}
|
|
170
|
+
cell := mustMarshalStreamCell("1", []string{
|
|
171
|
+
mustJsonMarshal(map[string]any{"body": "#" + deepSmallcapsBody, "slots": slots}),
|
|
172
|
+
mustJsonMarshal(map[string]any{"body": deepLegacyBody, "slots": slots}),
|
|
173
|
+
})
|
|
174
|
+
mustMarshalTwoLines := func(val any) string {
|
|
175
|
+
line := mustJsonMarshal(val)
|
|
176
|
+
return fmt.Sprintf("%s\n%s", line, line)
|
|
177
|
+
}
|
|
178
|
+
testCases = append(testCases, testCase{label: "remotables as strings",
|
|
179
|
+
data: ptr(cell),
|
|
180
|
+
request: types.QueryCapDataRequest{RemotableValueFormat: "string"},
|
|
181
|
+
expected: types.QueryCapDataResponse{
|
|
182
|
+
BlockHeight: "1",
|
|
183
|
+
Value: mustMarshalTwoLines(map[string]any{
|
|
184
|
+
"arr": []any{
|
|
185
|
+
map[string]any{
|
|
186
|
+
"bigint": "42",
|
|
187
|
+
"remotable": "[Alleged: Foo brand <a>]",
|
|
188
|
+
"ref2": "[Alleged: Foo brand <a>]",
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
}),
|
|
192
|
+
},
|
|
193
|
+
})
|
|
194
|
+
testCases = append(testCases, testCase{label: "remotables as strings, flat",
|
|
195
|
+
data: ptr(cell),
|
|
196
|
+
request: types.QueryCapDataRequest{ItemFormat: "flat", RemotableValueFormat: "string"},
|
|
197
|
+
expected: types.QueryCapDataResponse{
|
|
198
|
+
BlockHeight: "1",
|
|
199
|
+
Value: mustMarshalTwoLines(map[string]any{
|
|
200
|
+
"arr-0-bigint": "42",
|
|
201
|
+
"arr-0-remotable": "[Alleged: Foo brand <a>]",
|
|
202
|
+
"arr-0-ref2": "[Alleged: Foo brand <a>]",
|
|
203
|
+
}),
|
|
204
|
+
},
|
|
205
|
+
})
|
|
206
|
+
testCases = append(testCases, testCase{label: "remotables as objects",
|
|
207
|
+
data: ptr(cell),
|
|
208
|
+
request: types.QueryCapDataRequest{RemotableValueFormat: "object"},
|
|
209
|
+
expected: types.QueryCapDataResponse{
|
|
210
|
+
BlockHeight: "1",
|
|
211
|
+
Value: mustMarshalTwoLines(map[string]any{
|
|
212
|
+
"arr": []any{
|
|
213
|
+
map[string]any{
|
|
214
|
+
"bigint": "42",
|
|
215
|
+
"remotable": map[string]any{"id": "a", "allegedName": "Foo brand"},
|
|
216
|
+
"ref2": map[string]any{"id": "a", "allegedName": "Foo brand"},
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
}),
|
|
220
|
+
},
|
|
221
|
+
})
|
|
222
|
+
testCases = append(testCases, testCase{label: "remotables as objects, flat",
|
|
223
|
+
data: ptr(cell),
|
|
224
|
+
request: types.QueryCapDataRequest{ItemFormat: "flat", RemotableValueFormat: "object"},
|
|
225
|
+
expected: types.QueryCapDataResponse{
|
|
226
|
+
BlockHeight: "1",
|
|
227
|
+
Value: mustMarshalTwoLines(map[string]any{
|
|
228
|
+
"arr-0-bigint": "42",
|
|
229
|
+
"arr-0-remotable-id": "a",
|
|
230
|
+
"arr-0-remotable-allegedName": "Foo brand",
|
|
231
|
+
"arr-0-ref2-id": "a",
|
|
232
|
+
"arr-0-ref2-allegedName": "Foo brand",
|
|
233
|
+
}),
|
|
234
|
+
},
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
// Test errors from CapData that includes unsupported values.
|
|
238
|
+
expectNotImplemented := func(label, capdataBody string, slots []any) testCase {
|
|
239
|
+
if slots == nil {
|
|
240
|
+
slots = []any{}
|
|
241
|
+
}
|
|
242
|
+
serialized := mustJsonMarshal(map[string]any{
|
|
243
|
+
"body": capdataBody,
|
|
244
|
+
"slots": slots,
|
|
245
|
+
})
|
|
246
|
+
return testCase{
|
|
247
|
+
label: label,
|
|
248
|
+
data: ptr(serialized),
|
|
249
|
+
request: types.QueryCapDataRequest{RemotableValueFormat: "string"},
|
|
250
|
+
errCode: grpcCodes.FailedPrecondition,
|
|
251
|
+
errContains: ptr("not implemented"),
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
testCases = append(testCases, []testCase{
|
|
255
|
+
expectNotImplemented("smallcaps undefined", `#"#undefined"`, nil),
|
|
256
|
+
expectNotImplemented("smallcaps NaN", `#"#NaN"`, nil),
|
|
257
|
+
expectNotImplemented("smallcaps infinity", `#"#Infinity"`, nil),
|
|
258
|
+
expectNotImplemented("smallcaps negative infinity", `#"#-Infinity"`, nil),
|
|
259
|
+
expectNotImplemented("smallcaps symbol", `#"%foo"`, nil),
|
|
260
|
+
expectNotImplemented("smallcaps promise", `#"&0"`, []any{"a"}),
|
|
261
|
+
expectNotImplemented("smallcaps tagged", `#{"#tag":"copySet","payload":[]}`, nil),
|
|
262
|
+
expectNotImplemented("smallcaps error", `#{"#error":"foo","name":"Error"}`, nil),
|
|
263
|
+
expectNotImplemented("legacy undefined", `{"@qclass":"undefined"}`, nil),
|
|
264
|
+
expectNotImplemented("legacy NaN", `{"@qclass":"NaN"}`, nil),
|
|
265
|
+
expectNotImplemented("legacy infinity", `{"@qclass":"Infinity"}`, nil),
|
|
266
|
+
expectNotImplemented("legacy negative infinity", `{"@qclass":"-Infinity"}`, nil),
|
|
267
|
+
expectNotImplemented("legacy symbol", `{"@qclass":"symbol","name":"foo"}`, nil),
|
|
268
|
+
expectNotImplemented("smallcaps tagged", `{"@qclass":"tagged","tag":"copySet","payload":[]}`, nil),
|
|
269
|
+
expectNotImplemented("smallcaps error", `{"@qclass":"error","message":"foo","name":"Error"}`, nil),
|
|
270
|
+
expectNotImplemented("smallcaps Hilbert Hotel", `{"@qclass":"hilbert","original":"foo"}`, nil),
|
|
271
|
+
}...)
|
|
272
|
+
for _, desc := range testCases {
|
|
273
|
+
desc.request.Path = "key"
|
|
274
|
+
if desc.data == nil {
|
|
275
|
+
keeper.SetStorage(ctx, agoric.NewKVEntryWithNoValue(desc.request.Path))
|
|
276
|
+
} else {
|
|
277
|
+
keeper.SetStorage(ctx, agoric.NewKVEntry(desc.request.Path, *desc.data))
|
|
278
|
+
}
|
|
279
|
+
resp, err := querier.CapData(sdk.WrapSDKContext(ctx), &desc.request)
|
|
280
|
+
if desc.errCode == grpcCodes.OK {
|
|
281
|
+
if err != nil {
|
|
282
|
+
t.Errorf("%s: got unexpected error %v", desc.label, err)
|
|
283
|
+
} else if reflect.DeepEqual(resp, &desc.expected) {
|
|
284
|
+
continue
|
|
285
|
+
}
|
|
286
|
+
if resp.Value != desc.expected.Value {
|
|
287
|
+
lines := strings.Split(resp.Value, "\n")
|
|
288
|
+
t.Errorf("%s: wrong result value lines: %#q", desc.label, lines)
|
|
289
|
+
} else {
|
|
290
|
+
t.Errorf("%s: wrong result: %#v", desc.label, resp)
|
|
291
|
+
}
|
|
292
|
+
} else if err == nil {
|
|
293
|
+
t.Errorf("%s: got no error, want error %q", desc.label, *desc.errContains)
|
|
294
|
+
} else if code := grpcStatus.Code(err); code != desc.errCode {
|
|
295
|
+
t.Errorf("%s: got error code %q, want %q", desc.label, code, desc.errCode)
|
|
296
|
+
} else if desc.errContains != nil && !strings.Contains(err.Error(), *desc.errContains) {
|
|
297
|
+
t.Errorf("%s: got error %v, want error %q", desc.label, err, *desc.errContains)
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
@@ -31,7 +31,7 @@ func makeTestKit() testKit {
|
|
|
31
31
|
|
|
32
32
|
db := dbm.NewMemDB()
|
|
33
33
|
ms := store.NewCommitMultiStore(db)
|
|
34
|
-
ms.MountStoreWithDB(vstorageStoreKey,
|
|
34
|
+
ms.MountStoreWithDB(vstorageStoreKey, storetypes.StoreTypeIAVL, db)
|
|
35
35
|
err := ms.LoadLatestVersion()
|
|
36
36
|
if err != nil {
|
|
37
37
|
panic(err)
|
|
@@ -33,7 +33,11 @@ func getVstorageEntryPath(urlPathSegments []string) (string, error) {
|
|
|
33
33
|
// be used to extend it to a vstorage path such as "foo.bar.baz").
|
|
34
34
|
func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
|
35
35
|
return func(ctx sdk.Context, urlPathSegments []string, req abci.RequestQuery) (res []byte, err error) {
|
|
36
|
-
|
|
36
|
+
var queryType string
|
|
37
|
+
if len(urlPathSegments) > 0 {
|
|
38
|
+
queryType = urlPathSegments[0]
|
|
39
|
+
}
|
|
40
|
+
switch queryType {
|
|
37
41
|
case QueryData:
|
|
38
42
|
entryPath, entryPathErr := getVstorageEntryPath(urlPathSegments[1:])
|
|
39
43
|
if entryPathErr != nil {
|
|
@@ -47,7 +51,7 @@ func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier
|
|
|
47
51
|
}
|
|
48
52
|
return queryChildren(ctx, entryPath, req, keeper, legacyQuerierCdc)
|
|
49
53
|
default:
|
|
50
|
-
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown vstorage query
|
|
54
|
+
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown vstorage query path")
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
}
|