1#include <gtest/gtest.h>
26TEST(RamTable, TagCorrectness)
43 table_values.emplace_back(entry_1);
44 table_values.emplace_back(entry_2);
45 table_values.emplace_back(entry_3);
51 EXPECT_EQ(table.
read(
field_ct(0)).get_origin_tag(), submitted_value_origin_tag);
53 EXPECT_EQ(table.
read(
field_ct(1)).get_origin_tag(), challenge_origin_tag);
61 EXPECT_EQ(table.
read(
field_ct(1)).get_origin_tag(), next_challenge_tag);
66 EXPECT_THROW(table.
read(0) + table.
read(2), std::runtime_error);
70TEST(RamTable, RamTableInitReadConsistency)
75 const size_t table_size = 10;
76 for (
size_t i = 0; i < table_size; ++i) {
85 for (
size_t i = 0; i < 10; ++i) {
89 const auto to_add = table.
read(index);
92 const auto to_add = table.
read(i);
95 expected += table_values[i].get_value();
101 EXPECT_EQ(verified,
true);
104TEST(RamTable, RamTableReadWriteConsistency)
107 const size_t table_size = 10;
109 std::vector<fr> table_values(table_size);
113 for (
size_t i = 0; i < table_size; ++i) {
119 const auto update = [&]() {
120 for (
size_t i = 0; i < table_size / 2; ++i) {
125 table.
write(2 * i, table_values[2 * i]);
130 const auto read = [&]() {
131 for (
size_t i = 0; i < table_size / 2; ++i) {
132 const size_t index = table_size - 2 - (i * 2);
135 result += table.
read(index + 1);
137 expected += table_values[index];
138 expected += table_values[index + 1];
151 EXPECT_EQ(verified,
true);
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
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.
RNG & get_debug_randomness(bool reset, std::uint_fast64_t seed)
Entry point for Barretenberg command-line interface.
void read(B &it, field2< base_field, Params > &value)
TEST(MegaCircuitBuilder, CopyConstructor)
UltraCircuitBuilder_< UltraExecutionTraceBlocks > UltraCircuitBuilder
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
stdlib::field_t< Builder > field_ct
stdlib::witness_t< Builder > witness_ct
static field random_element(numeric::RNG *engine=nullptr) noexcept