4#include <gmock/gmock.h>
5#include <gtest/gtest.h>
31TEST(CalldataTraceGenTest, BasicHashing)
33 TestTraceContainer
trace;
38 simulation::CalldataEvent{
40 .calldata = { 10, 20, 30 },
47 EXPECT_THAT(rows.at(1),
68 EXPECT_THAT(rows.at(2),
89TEST(CalldataTraceGenTest, BasicRetrievalAndHashing)
91 TestTraceContainer
trace;
95 const auto events = { simulation::CalldataEvent{
99 simulation::CalldataEvent{
104 builder.process_retrieval(events, trace);
105 builder.process_hashing(events, trace);
109 EXPECT_THAT(rows.at(1),
116 EXPECT_THAT(rows.at(2),
124 EXPECT_THAT(rows.at(3),
133 EXPECT_THAT(rows.at(1),
174TEST(CalldataTraceGenTest, BasicRetrievalAndHashingEmpty)
176 TestTraceContainer
trace;
179 const auto events = { simulation::CalldataEvent{
184 builder.process_retrieval(events, trace);
185 builder.process_hashing(events, trace);
191 EXPECT_THAT(rows.at(1),
219TEST(CalldataTraceGenTest, LongerHash)
221 TestTraceContainer
trace;
231 simulation::CalldataEvent{
239 const auto calldata_rows = std::span(rows.begin() + 1, rows.end());
242 EXPECT_THAT(calldata_rows, SizeIs(34));
244 uint32_t expected_index = 0;
245 for (
auto row : calldata_rows) {
252 ROW_FIELD_EQ(calldata_hashing_output_hash, output_hash)));
257 AllOf(
ROW_FIELD_EQ(calldata_hashing_index_0_, expected_index),
258 ROW_FIELD_EQ(calldata_hashing_index_1_, expected_index + 1),
259 ROW_FIELD_EQ(calldata_hashing_index_2_, expected_index + 2),
260 ROW_FIELD_EQ(calldata_hashing_input_0_, preimage.at(expected_index)),
261 ROW_FIELD_EQ(calldata_hashing_input_1_, preimage.at(expected_index + 1)),
263 ROW_FIELD_EQ(calldata_hashing_input_2_, expected_index == 99 ? 0 : preimage.at(expected_index + 2)),
264 ROW_FIELD_EQ(calldata_hashing_rounds_rem, 34 - (expected_index / 3))));
268 AllOf(
ROW_FIELD_EQ(calldata_hashing_start, expected_index == 0 ? 1 : 0),
269 ROW_FIELD_EQ(calldata_hashing_sel_not_start, expected_index == 0 ? 0 : 1),
270 ROW_FIELD_EQ(calldata_hashing_latch, expected_index == 99 ? 1 : 0),
273 ROW_FIELD_EQ(calldata_hashing_sel_not_padding_2, expected_index == 99 ? 0 : 1)));
#define GENERATOR_INDEX__PUBLIC_CALLDATA
std::vector< AvmFullRowConstRef > as_rows() const
static FF hash(const std::vector< FF > &input)
Hashes a vector of field elements.
#define ROW_FIELD_EQ(field_name, expression)
std::vector< FF > random_fields(size_t n)
TEST(BoomerangMegaCircuitBuilder, BasicCircuit)
std::vector< MemoryValue > calldata