Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
class_id_derivation.test.cpp
Go to the documentation of this file.
2
3#include <cstdint>
4#include <gmock/gmock.h>
5#include <gtest/gtest.h>
6
14
15using ::testing::IsEmpty;
16using ::testing::SizeIs;
17
18namespace bb::avm2::simulation {
19
20namespace {
21
22using simulation::FakePoseidon2;
23
24TEST(AvmSimulationClassIdDerivationTest, Positive)
25{
26 EventEmitter<ClassIdDerivationEvent> class_id_derivation_event_emitter;
27 FakePoseidon2 poseidon2 = FakePoseidon2();
28
29 ClassIdDerivation class_id_derivation(poseidon2, class_id_derivation_event_emitter);
30
31 ContractClass klass = { .artifact_hash = FF::random_element(),
32 .private_function_root = FF::random_element(),
33 .public_bytecode_commitment = FF::random_element(),
34 .packed_bytecode = { 0x01, 0x02, 0x03, 0x04 } };
36 klass.artifact_hash,
37 klass.private_function_root,
38 klass.public_bytecode_commitment });
39
40 class_id_derivation.assert_derivation(class_id, klass);
41
42 auto events = class_id_derivation_event_emitter.dump_events();
43 EXPECT_THAT(events, SizeIs(1));
44 EXPECT_EQ(events[0].class_id, class_id);
45 EXPECT_EQ(events[0].klass.artifact_hash, klass.artifact_hash);
46
47 // Second derivation for the same class ID should be a cache hit and should not emit an event
48 class_id_derivation.assert_derivation(class_id, klass);
49 events = class_id_derivation_event_emitter.dump_events();
50 EXPECT_THAT(events, IsEmpty());
51}
52
53} // namespace
54} // namespace bb::avm2::simulation
#define GENERATOR_INDEX__CONTRACT_LEAF
static FF hash(const std::vector< FF > &input)
Hashes a vector of field elements.
TEST(EmitUnencryptedLogTest, Basic)
FF ContractClassId