20TEST(EmitUnencryptedLogTest, Basic)
22 StrictMock<MockMemory>
memory;
23 StrictMock<MockContext>
context;
30 uint32_t log_size = 2;
31 uint64_t end_log_address = 28;
40 .WillOnce(Return(
false));
43 EXPECT_CALL(
context, get_side_effect_states()).WillOnce(ReturnRef(side_effect_states));
44 EXPECT_CALL(
context, set_side_effect_states(next_side_effect_states));
48 value = MemoryValue::from<FF>(
FF(address));
52 EXPECT_CALL(
memory, get_space_id()).WillOnce(Return(57));
53 EXPECT_CALL(
context, get_is_static()).WillOnce(Return(
false));
59 .contract_address = address,
61 .log_address = log_offset,
66 .values = { MemoryValue::from<FF>(
FF(log_offset)), MemoryValue::from<FF>(
FF(log_offset + 1)) },
67 .error_memory_out_of_bounds =
false,
68 .error_too_many_log_fields =
false,
69 .error_tag_mismatch =
false,
72 EXPECT_THAT(
event_emitter.dump_events(), ElementsAre(expect_event));
75TEST(EmitUnencryptedLogTest, NegativeMemoryOutOfBounds)
77 StrictMock<MockMemory>
memory;
78 StrictMock<MockContext>
context;
85 uint32_t log_size = 2;
86 uint64_t end_log_address =
static_cast<uint64_t
>(log_offset) + log_size - 1;
95 .WillOnce(Return(
false));
98 EXPECT_CALL(
context, get_side_effect_states()).WillOnce(ReturnRef(side_effect_states));
99 EXPECT_CALL(
context, set_side_effect_states(next_side_effect_states));
101 EXPECT_CALL(
memory, get_space_id()).WillOnce(Return(57));
102 EXPECT_CALL(
context, get_is_static()).WillOnce(Return(
false));
109 .contract_address = address,
111 .log_address = log_offset,
112 .log_size = log_size,
118 .error_memory_out_of_bounds =
true,
119 .error_too_many_log_fields =
false,
120 .error_tag_mismatch =
false,
123 EXPECT_THAT(
event_emitter.dump_events(), ElementsAre(expect_event));
126TEST(EmitUnencryptedLogTest, NegativeTooManyLogs)
128 StrictMock<MockMemory>
memory;
129 StrictMock<MockContext>
context;
136 uint32_t log_size = 2;
137 uint64_t end_log_address = 28;
147 .WillOnce(Return(
true));
150 EXPECT_CALL(
context, get_side_effect_states()).WillOnce(ReturnRef(side_effect_states));
151 EXPECT_CALL(
context, set_side_effect_states(next_side_effect_states));
155 value = MemoryValue::from<FF>(
FF(address));
159 EXPECT_CALL(
memory, get_space_id()).WillOnce(Return(57));
160 EXPECT_CALL(
context, get_is_static()).WillOnce(Return(
false));
167 .contract_address = address,
169 .log_address = log_offset,
170 .log_size = log_size,
174 .values = { MemoryValue::from<FF>(
FF(log_offset)), MemoryValue::from<FF>(
FF(log_offset + 1)) },
175 .error_memory_out_of_bounds =
false,
176 .error_too_many_log_fields =
true,
177 .error_tag_mismatch =
false,
180 EXPECT_THAT(
event_emitter.dump_events(), ElementsAre(expect_event));
183TEST(EmitUnencryptedLogTest, NegativeTagMismatch)
185 StrictMock<MockMemory>
memory;
186 StrictMock<MockContext>
context;
193 uint32_t log_size = 2;
194 uint64_t end_log_address = 28;
203 .WillOnce(Return(
false));
206 EXPECT_CALL(
context, get_side_effect_states()).WillOnce(ReturnRef(side_effect_states));
207 EXPECT_CALL(
context, set_side_effect_states(next_side_effect_states));
211 value = MemoryValue::from<uint32_t>(address);
215 EXPECT_CALL(
memory, get_space_id()).WillOnce(Return(57));
216 EXPECT_CALL(
context, get_is_static()).WillOnce(Return(
false));
223 .contract_address = address,
225 .log_address = log_offset,
226 .log_size = log_size,
230 .values = { MemoryValue::from<uint32_t>(log_offset), MemoryValue::from<uint32_t>(log_offset + 1) },
231 .error_memory_out_of_bounds =
false,
232 .error_too_many_log_fields =
false,
233 .error_tag_mismatch =
true,
236 EXPECT_THAT(
event_emitter.dump_events(), ElementsAre(expect_event));
239TEST(EmitUnencryptedLogTest, NegativeStatic)
241 StrictMock<MockMemory>
memory;
242 StrictMock<MockContext>
context;
249 uint32_t log_size = 2;
250 uint64_t end_log_address = 28;
259 .WillOnce(Return(
false));
262 EXPECT_CALL(
context, get_side_effect_states()).WillOnce(ReturnRef(side_effect_states));
263 EXPECT_CALL(
context, set_side_effect_states(next_side_effect_states));
267 value = MemoryValue::from<FF>(
FF(address));
271 EXPECT_CALL(
memory, get_space_id()).WillOnce(Return(57));
272 EXPECT_CALL(
context, get_is_static()).WillOnce(Return(
true));
279 .contract_address = address,
281 .log_address = log_offset,
282 .log_size = log_size,
286 .values = { MemoryValue::from<FF>(
FF(log_offset)), MemoryValue::from<FF>(
FF(log_offset + 1)) },
288 .error_memory_out_of_bounds =
false,
289 .error_too_many_log_fields =
false,
290 .error_tag_mismatch =
false,
293 EXPECT_THAT(
event_emitter.dump_events(), ElementsAre(expect_event));