1#include <gtest/gtest.h>
11template <
typename Builder>
class RamTableTests :
public ::testing::Test {
17using BuilderTypes = testing::Types<UltraCircuitBuilder, MegaCircuitBuilder>;
29TEST(RamTable, TagCorrectness)
49 table_values.emplace_back(entry_1);
50 table_values.emplace_back(entry_2);
51 table_values.emplace_back(entry_3);
57 EXPECT_EQ(table.
read(
field_ct(0)).get_origin_tag(), submitted_value_origin_tag);
59 EXPECT_EQ(table.
read(
field_ct(1)).get_origin_tag(), challenge_origin_tag);
67 EXPECT_EQ(table.
read(
field_ct(1)).get_origin_tag(), next_challenge_tag);
72 EXPECT_THROW(table.
read(0) + table.
read(2), std::runtime_error);
82 using field_ct =
typename TestFixture::field_ct;
83 using witness_ct =
typename TestFixture::witness_ct;
88 const size_t table_size = 10;
89 for (
size_t i = 0; i < table_size; ++i) {
98 for (
size_t i = 0; i < 10; ++i) {
105 const auto to_add = table.
read(i);
108 expected += table_values[i].get_value();
114 EXPECT_EQ(verified,
true);
120 using field_ct =
typename TestFixture::field_ct;
121 using witness_ct =
typename TestFixture::witness_ct;
122 using ram_table_ct =
typename TestFixture::ram_table_ct;
124 const size_t table_size = 10;
125 const size_t num_reads = 2 * table_size;
127 std::vector<fr> table_values(table_size);
131 for (
size_t i = 0; i < table_size; ++i) {
137 const auto update = [&]() {
138 for (
size_t i = 0; i < table_size / 2; ++i) {
143 table.
write(2 * i, table_values[2 * i]);
148 const auto read = [&]() {
149 for (
size_t i = 0; i < num_reads / 2; ++i) {
154 result += table.
read(index_2);
156 expected += table_values[index_1];
157 expected += table_values[index_2];
170 EXPECT_EQ(verified,
true);
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
virtual uint32_t get_random_uint32()=0
bb::fr get_value() const
Given a := *this, compute its value given by a.v * a.mul + a.add.
void set_origin_tag(const OriginTag &new_tag) const
field_pt read(const field_pt &index) const
Read a field element from the RAM table at an index value.
void write(const field_pt &index, const field_pt &value)
Write a field element from the RAM table at an index value.
bn254::witness_ct witness_ct
stdlib::field_t< Builder > field_ct
RNG & get_debug_randomness(bool reset, std::uint_fast64_t seed)
Entry point for Barretenberg command-line interface.
TYPED_TEST_SUITE(ShpleminiTest, TestSettings)
void read(uint8_t const *&it, Chonk::VerificationKey &vk)
UltraCircuitBuilder_< UltraExecutionTraceBlocks > UltraCircuitBuilder
TYPED_TEST(ShpleminiTest, CorrectnessOfMultivariateClaimBatching)
TEST(BoomerangMegaCircuitBuilder, BasicCircuit)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
This file contains part of the logic for the Origin Tag mechanism that tracks the use of in-circuit p...
#define STANDARD_TESTING_TAGS
::testing::Types< UltraCircuitBuilder, MegaCircuitBuilder > BuilderTypes
static field random_element(numeric::RNG *engine=nullptr) noexcept