Skip to content

Commit

Permalink
test(logic): add test for max variables
Browse files Browse the repository at this point in the history
  • Loading branch information
bdeneux committed Jul 24, 2024
1 parent 6b3b156 commit dce2242
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions x/logic/keeper/grpc_query_ask_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func TestGRPCAsk(t *testing.T) {
maxResultCount int
predicateBlacklist []string
maxGas uint64
maxVariables uint64
predicateCosts map[string]uint64
expectedAnswer *types.Answer
expectedError string
Expand Down Expand Up @@ -142,15 +143,20 @@ func TestGRPCAsk(t *testing.T) {
{
query: "bank_balances(X, Y).",
maxGas: 3000,
expectedError: "out of gas: logic <panic: {ValuePerByte}> (4204/3000): limit exceeded",
expectedError: "out of gas: logic <panic: {ValuePerByte}> (4222/3000): limit exceeded",
},
{
query: "block_height(X).",
maxGas: 3000,
predicateCosts: map[string]uint64{
"block_height/1": 10000,
},
expectedError: "out of gas: logic <block_height/1> (12353/3000): limit exceeded",
expectedError: "out of gas: logic <block_height/1> (12371/3000): limit exceeded",
},
{
query: "length(List, 100000).",
maxVariables: 1000,
expectedError: "maximum number of variables reached: limit exceeded",
},
{
program: "father(bob, 'élodie').",
Expand Down Expand Up @@ -348,6 +354,8 @@ foo(a4).
maxResultCount := sdkmath.NewUint(uint64(lo.If(tc.maxResultCount == 0, 1).Else(tc.maxResultCount)))
params := types.DefaultParams()
params.Limits.MaxResultCount = &maxResultCount
maxVariables := sdkmath.NewUint(tc.maxVariables)
params.Limits.MaxVariables = &maxVariables
if tc.predicateBlacklist != nil {
params.Interpreter.PredicatesFilter.Blacklist = tc.predicateBlacklist
}
Expand Down

0 comments on commit dce2242

Please sign in to comment.