Skip to content

Commit dce2242

Browse files
committed
test(logic): add test for max variables
1 parent 6b3b156 commit dce2242

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

x/logic/keeper/grpc_query_ask_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func TestGRPCAsk(t *testing.T) {
3939
maxResultCount int
4040
predicateBlacklist []string
4141
maxGas uint64
42+
maxVariables uint64
4243
predicateCosts map[string]uint64
4344
expectedAnswer *types.Answer
4445
expectedError string
@@ -142,15 +143,20 @@ func TestGRPCAsk(t *testing.T) {
142143
{
143144
query: "bank_balances(X, Y).",
144145
maxGas: 3000,
145-
expectedError: "out of gas: logic <panic: {ValuePerByte}> (4204/3000): limit exceeded",
146+
expectedError: "out of gas: logic <panic: {ValuePerByte}> (4222/3000): limit exceeded",
146147
},
147148
{
148149
query: "block_height(X).",
149150
maxGas: 3000,
150151
predicateCosts: map[string]uint64{
151152
"block_height/1": 10000,
152153
},
153-
expectedError: "out of gas: logic <block_height/1> (12353/3000): limit exceeded",
154+
expectedError: "out of gas: logic <block_height/1> (12371/3000): limit exceeded",
155+
},
156+
{
157+
query: "length(List, 100000).",
158+
maxVariables: 1000,
159+
expectedError: "maximum number of variables reached: limit exceeded",
154160
},
155161
{
156162
program: "father(bob, 'élodie').",
@@ -348,6 +354,8 @@ foo(a4).
348354
maxResultCount := sdkmath.NewUint(uint64(lo.If(tc.maxResultCount == 0, 1).Else(tc.maxResultCount)))
349355
params := types.DefaultParams()
350356
params.Limits.MaxResultCount = &maxResultCount
357+
maxVariables := sdkmath.NewUint(tc.maxVariables)
358+
params.Limits.MaxVariables = &maxVariables
351359
if tc.predicateBlacklist != nil {
352360
params.Interpreter.PredicatesFilter.Blacklist = tc.predicateBlacklist
353361
}

0 commit comments

Comments
 (0)