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),
153 EXPECT_THAT(rows.at(2),
173TEST(CalldataTraceGenTest, BasicRetrievalAndHashingEmpty)
175 TestTraceContainer
trace;
178 const auto events = { simulation::CalldataEvent{
183 builder.process_retrieval(events, trace);
184 builder.process_hashing(events, trace);
190 EXPECT_THAT(rows.at(1),
197 EXPECT_THAT(rows.at(1),
217TEST(CalldataTraceGenTest, LongerHash)
219 TestTraceContainer
trace;
229 simulation::CalldataEvent{
237 const auto calldata_rows = std::span(rows.begin() + 1, rows.end());
240 EXPECT_THAT(calldata_rows, SizeIs(34));
242 uint32_t expected_index = 0;
243 for (
auto row : calldata_rows) {
250 ROW_FIELD_EQ(calldata_hashing_output_hash, output_hash)));
255 AllOf(
ROW_FIELD_EQ(calldata_hashing_index_0_, expected_index),
256 ROW_FIELD_EQ(calldata_hashing_index_1_, expected_index + 1),
257 ROW_FIELD_EQ(calldata_hashing_index_2_, expected_index + 2),
258 ROW_FIELD_EQ(calldata_hashing_input_0_, preimage.at(expected_index)),
259 ROW_FIELD_EQ(calldata_hashing_input_1_, preimage.at(expected_index + 1)),
261 ROW_FIELD_EQ(calldata_hashing_input_2_, expected_index == 99 ? 0 : preimage.at(expected_index + 2)),
262 ROW_FIELD_EQ(calldata_hashing_rounds_rem, 34 - (expected_index / 3))));
266 AllOf(
ROW_FIELD_EQ(calldata_hashing_start, expected_index == 0 ? 1 : 0),
267 ROW_FIELD_EQ(calldata_hashing_sel_not_start, expected_index == 0 ? 0 : 1),
268 ROW_FIELD_EQ(calldata_hashing_latch, expected_index == 99 ? 1 : 0),
271 ROW_FIELD_EQ(calldata_hashing_sel_not_padding_2, expected_index == 99 ? 0 : 1)));
#define DOM_SEP__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