Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
mov.test.cpp
Go to the documentation of this file.
1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
3
4#include <cstdint>
5
12
13namespace bb::avm2::constraining {
14namespace {
15
16using tracegen::TestTraceContainer;
18using C = Column;
20
21TEST(MovConstrainingTest, MovFF)
22{
23 TestTraceContainer trace({
24 { { C::precomputed_first_row, 1 } },
25 {
26 { C::execution_sel, 1 },
27 { C::execution_sel_execute_mov, 1 },
28 { C::execution_register_0_, FF::modulus_minus_two },
29 { C::execution_register_1_, FF::modulus_minus_two },
30 { C::execution_mem_tag_reg_0_, static_cast<uint8_t>(MemoryTag::FF) },
31 { C::execution_mem_tag_reg_1_, static_cast<uint8_t>(MemoryTag::FF) },
32 },
33 });
34
35 check_relation<execution>(trace, execution::SR_MOV_SAME_VALUE, execution::SR_MOV_SAME_TAG);
36}
37
38class MovAnyTagTest : public ::testing::TestWithParam<MemoryTag> {};
39
40TEST_P(MovAnyTagTest, MovAnyTag)
41{
42 const auto tag = GetParam();
43 TestTraceContainer trace({
44 { { C::precomputed_first_row, 1 } },
45 {
46 { C::execution_sel, 1 },
47 { C::execution_sel_execute_mov, 1 },
48 { C::execution_register_0_, 1 },
49 { C::execution_register_1_, 1 },
50 { C::execution_mem_tag_reg_0_, static_cast<uint8_t>(tag) },
51 { C::execution_mem_tag_reg_1_, static_cast<uint8_t>(tag) },
52 },
53 });
54
55 check_relation<execution>(trace, execution::SR_MOV_SAME_VALUE, execution::SR_MOV_SAME_TAG);
56}
57
59 MovConstrainingTest,
60 MovAnyTagTest,
61 ::testing::Values(
63
64TEST(MovConstrainingTest, NegativeMovDifferentTag)
65{
66 TestTraceContainer trace({
67 { { C::precomputed_first_row, 1 } },
68 {
69 { C::execution_sel, 1 },
70 { C::execution_sel_execute_mov, 1 },
71 { C::execution_register_0_, 17 },
72 { C::execution_register_1_, 17 },
73 { C::execution_mem_tag_reg_0_, static_cast<uint8_t>(MemoryTag::U8) },
74 { C::execution_mem_tag_reg_1_, static_cast<uint8_t>(MemoryTag::U16) },
75 },
76 });
77
78 EXPECT_THROW_WITH_MESSAGE(check_relation<execution>(trace, execution::SR_MOV_SAME_TAG), "MOV_SAME_TAG");
79}
80
81TEST(MovConstrainingTest, NegativeMovDifferentValue)
82{
83 TestTraceContainer trace({
84 { { C::precomputed_first_row, 1 } },
85 {
86 { C::execution_sel, 1 },
87 { C::execution_sel_execute_mov, 1 },
88 { C::execution_register_0_, 17 },
89 { C::execution_register_1_, 18 },
90 { C::execution_mem_tag_reg_0_, static_cast<uint8_t>(MemoryTag::U32) },
91 { C::execution_mem_tag_reg_1_, static_cast<uint8_t>(MemoryTag::U32) },
92 },
93 });
94
95 EXPECT_THROW_WITH_MESSAGE(check_relation<execution>(trace, execution::SR_MOV_SAME_VALUE), "MOV_SAME_VALUE");
96}
97
98} // namespace
99} // namespace bb::avm2::constraining
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessageRegex)
Definition assert.hpp:192
static constexpr size_t SR_MOV_SAME_TAG
Definition execution.hpp:57
static constexpr size_t SR_MOV_SAME_VALUE
Definition execution.hpp:56
TestTraceContainer trace
INSTANTIATE_TEST_SUITE_P(PaddingVariants, AvmRecursiveTestsParameterized, ::testing::Values(false, true), [](const auto &info) { return info.param ? "Padded" :"Unpadded";})
TEST_P(AvmRecursiveTestsParameterized, GoblinRecursion)
A test of the Goblinized AVM recursive verifier.
TEST(AvmFixedVKTests, FixedVKCommitments)
Test that the fixed VK commitments agree with the ones computed from precomputed columns.
static constexpr uint256_t modulus_minus_two
NiceMock< MockExecution > execution