4#include <gmock/gmock.h>
5#include <gtest/gtest.h>
31TEST(CalldataTraceGenTest, BasicHashing)
33 TestTraceContainer
trace;
38 simulation::CalldataEvent{
41 .calldata = { 10, 20, 30 },
48 EXPECT_THAT(rows.at(1),
69 EXPECT_THAT(rows.at(2),
90TEST(CalldataTraceGenTest, BasicRetrievalAndHashing)
92 TestTraceContainer
trace;
95 const auto events = { simulation::CalldataEvent{
100 simulation::CalldataEvent{
113 EXPECT_THAT(rows.at(1),
121 EXPECT_THAT(rows.at(2),
128 EXPECT_THAT(rows.at(3),
136 EXPECT_THAT(rows.at(1),
177TEST(CalldataTraceGenTest, BasicRetrievalAndHashingEmpty)
179 TestTraceContainer
trace;
182 const auto events = { simulation::CalldataEvent{
195 EXPECT_THAT(rows.at(1),
223TEST(CalldataTraceGenTest, LongerHash)
225 TestTraceContainer
trace;
235 simulation::CalldataEvent{
237 .calldata_size = 100,
244 const auto calldata_rows = std::span(rows.begin() + 1, rows.end());
247 EXPECT_THAT(calldata_rows, SizeIs(34));
249 uint32_t expected_index = 0;
250 for (
auto row : calldata_rows) {
257 ROW_FIELD_EQ(calldata_hashing_output_hash, output_hash)));
262 AllOf(
ROW_FIELD_EQ(calldata_hashing_index_0_, expected_index),
263 ROW_FIELD_EQ(calldata_hashing_index_1_, expected_index + 1),
264 ROW_FIELD_EQ(calldata_hashing_index_2_, expected_index + 2),
265 ROW_FIELD_EQ(calldata_hashing_input_0_, preimage.at(expected_index)),
266 ROW_FIELD_EQ(calldata_hashing_input_1_, preimage.at(expected_index + 1)),
268 ROW_FIELD_EQ(calldata_hashing_input_2_, expected_index == 99 ? 0 : preimage.at(expected_index + 2)),
269 ROW_FIELD_EQ(calldata_hashing_rounds_rem, 34 - (expected_index / 3))));
273 AllOf(
ROW_FIELD_EQ(calldata_hashing_start, expected_index == 0 ? 1 : 0),
274 ROW_FIELD_EQ(calldata_hashing_sel_not_start, expected_index == 0 ? 0 : 1),
275 ROW_FIELD_EQ(calldata_hashing_latch, expected_index == 99 ? 1 : 0),
278 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)
TEST(EmitUnencryptedLogTest, Basic)
std::vector< FF > random_fields(size_t n)
std::vector< FF > calldata