Skip to content

Commit

Permalink
chore: fix negative tests in AVM circuit for context input lookups (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanks12 authored Jul 2, 2024
1 parent 6fafff6 commit ad2f654
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace tests_avm {
using namespace bb;
using namespace bb::avm_trace;

auto const BAD_LOOKUP = "LOOKUP_INTO_KERNEL";

class AvmKernelTests : public ::testing::Test {
protected:
// TODO(640): The Standard Honk on Grumpkin test suite fails unless the SRS is initialised for every test.
Expand Down Expand Up @@ -614,6 +616,8 @@ void negative_test_incorrect_ia_kernel_lookup(OpcodesFunc apply_opcodes,
auto& ta = trace.at(1);

ta.main_ia = incorrect_ia;
// memory trace should only have one row for these tests as well, so first row has looked-up val
ta.mem_val = incorrect_ia;

check_trace(/*indirect*/ false, trace);

Expand Down Expand Up @@ -643,7 +647,7 @@ TEST_F(AvmKernelNegativeTests, incorrectIaSender)
/*w_in_tag=*/AvmMemoryTag::FF);
};

negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, "PERM_MAIN_MEM_A");
negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, BAD_LOOKUP);
}

TEST_F(AvmKernelNegativeTests, incorrectIaAddress)
Expand All @@ -669,7 +673,7 @@ TEST_F(AvmKernelNegativeTests, incorrectIaAddress)
/*w_in_tag=*/AvmMemoryTag::FF);
};

negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, "PERM_MAIN_MEM_A");
negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, BAD_LOOKUP);
}

TEST_F(AvmKernelNegativeTests, incorrectIaStorageAddress)
Expand All @@ -695,7 +699,7 @@ TEST_F(AvmKernelNegativeTests, incorrectIaStorageAddress)
/*w_in_tag=*/AvmMemoryTag::FF);
};

negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, "PERM_MAIN_MEM_A");
negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, BAD_LOOKUP);
}

TEST_F(AvmKernelNegativeTests, incorrectIaFunctionSelector)
Expand All @@ -721,7 +725,7 @@ TEST_F(AvmKernelNegativeTests, incorrectIaFunctionSelector)
/*w_in_tag=*/AvmMemoryTag::U32);
};

negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, "PERM_MAIN_MEM_A");
negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, BAD_LOOKUP);
}

TEST_F(AvmKernelNegativeTests, incorrectIaDaGas)
Expand All @@ -747,7 +751,7 @@ TEST_F(AvmKernelNegativeTests, incorrectIaDaGas)
/*w_in_tag=*/AvmMemoryTag::FF);
};

negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, "PERM_MAIN_MEM_A");
negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, BAD_LOOKUP);
}

TEST_F(AvmKernelNegativeTests, incorrectIal2Gas)
Expand All @@ -773,7 +777,7 @@ TEST_F(AvmKernelNegativeTests, incorrectIal2Gas)
/*w_in_tag=*/AvmMemoryTag::FF);
};

negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, "PERM_MAIN_MEM_A");
negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, BAD_LOOKUP);
}

TEST_F(AvmKernelNegativeTests, incorrectIaTransactionFee)
Expand All @@ -799,7 +803,7 @@ TEST_F(AvmKernelNegativeTests, incorrectIaTransactionFee)
/*w_in_tag=*/AvmMemoryTag::FF);
};

negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, "PERM_MAIN_MEM_A");
negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, BAD_LOOKUP);
}

TEST_F(AvmKernelNegativeTests, incorrectIaChainId)
Expand All @@ -825,7 +829,7 @@ TEST_F(AvmKernelNegativeTests, incorrectIaChainId)
/*w_in_tag=*/AvmMemoryTag::FF);
};

negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, "PERM_MAIN_MEM_A");
negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, BAD_LOOKUP);
}

TEST_F(AvmKernelNegativeTests, incorrectIaVersion)
Expand All @@ -851,7 +855,7 @@ TEST_F(AvmKernelNegativeTests, incorrectIaVersion)
/*w_in_tag=*/AvmMemoryTag::FF);
};

negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, "PERM_MAIN_MEM_A");
negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, BAD_LOOKUP);
}

TEST_F(AvmKernelNegativeTests, incorrectIaBlockNumber)
Expand All @@ -877,7 +881,7 @@ TEST_F(AvmKernelNegativeTests, incorrectIaBlockNumber)
/*w_in_tag=*/AvmMemoryTag::FF);
};

negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, "PERM_MAIN_MEM_A");
negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, BAD_LOOKUP);
}

TEST_F(AvmKernelNegativeTests, incorrectIaTimestamp)
Expand All @@ -903,7 +907,7 @@ TEST_F(AvmKernelNegativeTests, incorrectIaTimestamp)
/*w_in_tag=*/AvmMemoryTag::U64);
};

negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, "PERM_MAIN_MEM_A");
negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, BAD_LOOKUP);
}

TEST_F(AvmKernelNegativeTests, incorrectIaCoinbase)
Expand All @@ -929,7 +933,7 @@ TEST_F(AvmKernelNegativeTests, incorrectIaCoinbase)
/*w_in_tag=*/AvmMemoryTag::FF);
};

negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, "PERM_MAIN_MEM_A");
negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, BAD_LOOKUP);
}

// KERNEL OUTPUTS
Expand Down

0 comments on commit ad2f654

Please sign in to comment.