20TEST(EmitUnencryptedLogTest, Basic)
22 StrictMock<MockMemory>
memory;
23 StrictMock<MockContext>
context;
24 StrictMock<MockGreaterThan> greater_than;
30 uint32_t log_size = 2;
31 uint64_t end_log_address = 28;
41 EXPECT_CALL(
context, get_side_effect_states()).WillOnce(ReturnRef(side_effect_states));
42 EXPECT_CALL(
context, set_side_effect_states(next_side_effect_states));
46 value = MemoryValue::from<FF>(
FF(address));
50 EXPECT_CALL(
memory, get_space_id()).WillOnce(Return(57));
51 EXPECT_CALL(
context, get_is_static()).WillOnce(Return(
false));
57 .contract_address = address,
59 .log_address = log_offset,
64 .values = { MemoryValue::from<FF>(
FF(log_offset)), MemoryValue::from<FF>(
FF(log_offset + 1)) },
65 .error_too_large =
false,
66 .error_memory_out_of_bounds =
false,
67 .error_too_many_logs =
false,
68 .error_tag_mismatch =
false,
71 EXPECT_THAT(
event_emitter.dump_events(), ElementsAre(expect_event));
74TEST(EmitUnencryptedLogTest, NegativeTooLarge)
76 StrictMock<MockMemory>
memory;
77 StrictMock<MockContext>
context;
78 StrictMock<MockGreaterThan> greater_than;
85 uint64_t end_log_address = log_offset + log_size - 1;
95 EXPECT_CALL(
context, get_side_effect_states()).WillOnce(ReturnRef(side_effect_states));
96 EXPECT_CALL(
context, set_side_effect_states(next_side_effect_states));
100 value = MemoryValue::from<FF>(
FF(address));
104 EXPECT_CALL(
memory, get_space_id()).WillOnce(Return(57));
105 EXPECT_CALL(
context, get_is_static()).WillOnce(Return(
false));
113 expected_values.push_back(MemoryValue::from<FF>(
FF(log_offset + i)));
118 .contract_address = address,
120 .log_address = log_offset,
121 .log_size = log_size,
125 .values = expected_values,
126 .error_too_large =
true,
127 .error_memory_out_of_bounds =
false,
128 .error_too_many_logs =
false,
129 .error_tag_mismatch =
false,
132 EXPECT_THAT(
event_emitter.dump_events(), ElementsAre(expect_event));
135TEST(EmitUnencryptedLogTest, NegativeMemoryOutOfBounds)
137 StrictMock<MockMemory>
memory;
138 StrictMock<MockContext>
context;
139 StrictMock<MockGreaterThan> greater_than;
145 uint32_t log_size = 2;
146 uint64_t end_log_address =
static_cast<uint64_t
>(log_offset) + log_size - 1;
156 EXPECT_CALL(
context, get_side_effect_states()).WillOnce(ReturnRef(side_effect_states));
157 EXPECT_CALL(
context, set_side_effect_states(next_side_effect_states));
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,
175 .error_too_large =
false,
176 .error_memory_out_of_bounds =
true,
177 .error_too_many_logs =
false,
178 .error_tag_mismatch =
false,
181 EXPECT_THAT(
event_emitter.dump_events(), ElementsAre(expect_event));
184TEST(EmitUnencryptedLogTest, NegativeTooManyLogs)
186 StrictMock<MockMemory>
memory;
187 StrictMock<MockContext>
context;
188 StrictMock<MockGreaterThan> greater_than;
194 uint32_t log_size = 2;
195 uint64_t end_log_address = 28;
205 EXPECT_CALL(
context, get_side_effect_states()).WillOnce(ReturnRef(side_effect_states));
206 EXPECT_CALL(
context, set_side_effect_states(next_side_effect_states));
210 value = MemoryValue::from<FF>(
FF(address));
214 EXPECT_CALL(
memory, get_space_id()).WillOnce(Return(57));
215 EXPECT_CALL(
context, get_is_static()).WillOnce(Return(
false));
222 .contract_address = address,
224 .log_address = log_offset,
225 .log_size = log_size,
229 .values = { MemoryValue::from<FF>(
FF(log_offset)), MemoryValue::from<FF>(
FF(log_offset + 1)) },
230 .error_too_large =
false,
231 .error_memory_out_of_bounds =
false,
232 .error_too_many_logs =
true,
233 .error_tag_mismatch =
false,
236 EXPECT_THAT(
event_emitter.dump_events(), ElementsAre(expect_event));
239TEST(EmitUnencryptedLogTest, NegativeTagMismatch)
241 StrictMock<MockMemory>
memory;
242 StrictMock<MockContext>
context;
243 StrictMock<MockGreaterThan> greater_than;
249 uint32_t log_size = 2;
250 uint64_t end_log_address = 28;
260 EXPECT_CALL(
context, get_side_effect_states()).WillOnce(ReturnRef(side_effect_states));
261 EXPECT_CALL(
context, set_side_effect_states(next_side_effect_states));
265 value = MemoryValue::from<uint32_t>(address);
269 EXPECT_CALL(
memory, get_space_id()).WillOnce(Return(57));
270 EXPECT_CALL(
context, get_is_static()).WillOnce(Return(
false));
277 .contract_address = address,
279 .log_address = log_offset,
280 .log_size = log_size,
284 .values = { MemoryValue::from<uint32_t>(log_offset), MemoryValue::from<uint32_t>(log_offset + 1) },
285 .error_too_large =
false,
286 .error_memory_out_of_bounds =
false,
287 .error_too_many_logs =
false,
288 .error_tag_mismatch =
true,
291 EXPECT_THAT(
event_emitter.dump_events(), ElementsAre(expect_event));
294TEST(EmitUnencryptedLogTest, NegativeStatic)
296 StrictMock<MockMemory>
memory;
297 StrictMock<MockContext>
context;
298 StrictMock<MockGreaterThan> greater_than;
304 uint32_t log_size = 2;
305 uint64_t end_log_address = 28;
315 EXPECT_CALL(
context, get_side_effect_states()).WillOnce(ReturnRef(side_effect_states));
316 EXPECT_CALL(
context, set_side_effect_states(next_side_effect_states));
320 value = MemoryValue::from<FF>(
FF(address));
324 EXPECT_CALL(
memory, get_space_id()).WillOnce(Return(57));
325 EXPECT_CALL(
context, get_is_static()).WillOnce(Return(
true));
332 .contract_address = address,
334 .log_address = log_offset,
335 .log_size = log_size,
339 .values = { MemoryValue::from<FF>(
FF(log_offset)), MemoryValue::from<FF>(
FF(log_offset + 1)) },
340 .error_too_large =
false,
341 .error_memory_out_of_bounds =
false,
342 .error_too_many_logs =
false,
343 .error_tag_mismatch =
false,
346 EXPECT_THAT(
event_emitter.dump_events(), ElementsAre(expect_event));