Debian Codegraph @

tests/core_tests/tx_pool.cpp

raw symbols SCIP
1 // Copyright (c) 2019-2022, The Monero Project
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification, are
6 // permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice, this list of
9 // conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 // of conditions and the following disclaimer in the documentation and/or other
13 // materials provided with the distribution.
14 //
15 // 3. Neither the name of the copyright holder nor the names of its contributors may be
16 // used to endorse or promote products derived from this software without specific
17 // prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 #include "tx_pool.h"
30
31 #include <boost/chrono/chrono.hpp>
32 #include <boost/thread/thread_only.hpp>
33 #include <limits>
34 #include "string_tools.h"
35
36 #define INIT_MEMPOOL_TEST() \
37 uint64_t send_amount = 1000; \
38 uint64_t ts_start = 1338224400; \
39 GENERATE_ACCOUNT(miner_account); \
40 GENERATE_ACCOUNT(bob_account); \
41 MAKE_GENESIS_BLOCK(events, blk_0, miner_account, ts_start); \
42 REWIND_BLOCKS(events, blk_0r, blk_0, miner_account); \
43
44
45 txpool_base::txpool_base()
46 : test_chain_unit_base()
47 , m_broadcasted_tx_count(0)
48 , m_all_tx_count(0)
49 {
50 REGISTER_CALLBACK_METHOD(txpool_spend_key_public, increase_broadcasted_tx_count);
51 REGISTER_CALLBACK_METHOD(txpool_spend_key_public, increase_all_tx_count);
52 REGISTER_CALLBACK_METHOD(txpool_spend_key_public, check_txpool_spent_keys);
53 }
54
55 bool txpool_base::increase_broadcasted_tx_count(cryptonote::core& /*c*/, size_t /*ev_index*/, const std::vector<test_event_entry>& /*events*/)
56 {
57 ++m_broadcasted_tx_count;
58 return true;
59 }
60
61 bool txpool_base::increase_all_tx_count(cryptonote::core& /*c*/, size_t /*ev_index*/, const std::vector<test_event_entry>& /*events*/)
62 {
63 ++m_all_tx_count;
64 return true;
65 }
66
67 bool txpool_base::check_txpool_spent_keys(cryptonote::core& c, size_t /*ev_index*/, const std::vector<test_event_entry>& events)
68 {
69 std::vector<cryptonote::tx_info> infos{};
70 std::vector<cryptonote::spent_key_image_info> key_images{};
71 if (!c.get_pool_transactions_and_spent_keys_info(infos, key_images) || infos.size() != m_broadcasted_tx_count || key_images.size() != m_broadcasted_tx_count)
72 {
73 MERROR("Failed broadcasted spent keys retrieval - Expected Broadcasted Count: " << m_broadcasted_tx_count << " Actual Info Count: " << infos.size() << " Actual Key Image Count: " << key_images.size());
74 return false;
75 }
76
77 infos.clear();
78 key_images.clear();
79 if (!c.get_pool_transactions_and_spent_keys_info(infos, key_images, false) || infos.size() != m_broadcasted_tx_count || key_images.size() != m_broadcasted_tx_count)
80 {
81 MERROR("Failed broadcasted spent keys retrieval - Expected Broadcasted Count: " << m_broadcasted_tx_count << " Actual Info Count: " << infos.size() << " Actual Key Image Count: " << key_images.size());
82 return false;
83 }
84
85 infos.clear();
86 key_images.clear();
87 if (!c.get_pool_transactions_and_spent_keys_info(infos, key_images, true) || infos.size() != m_all_tx_count || key_images.size() != m_all_tx_count)
88 {
89 MERROR("Failed all spent keys retrieval - Expected All Count: " << m_all_tx_count << " Actual Info Count: " << infos.size() << " Actual Key Image Count: " << key_images.size());
90 return false;
91 }
92
93 return true;
94 }
95
96 bool txpool_spend_key_public::generate(std::vector<test_event_entry>& events) const
97 {
98 INIT_MEMPOOL_TEST();
99
100 DO_CALLBACK(events, "check_txpool_spent_keys");
101 MAKE_TX(events, tx_0, miner_account, bob_account, send_amount, blk_0);
102 DO_CALLBACK(events, "increase_broadcasted_tx_count");
103 DO_CALLBACK(events, "increase_all_tx_count");
104 DO_CALLBACK(events, "check_txpool_spent_keys");
105
106 return true;
107 }
108
109 bool txpool_spend_key_all::generate(std::vector<test_event_entry>& events)
110 {
111 INIT_MEMPOOL_TEST();
112 SET_EVENT_VISITOR_SETT(events, event_visitor_settings::set_txs_do_not_relay);
113
114 DO_CALLBACK(events, "check_txpool_spent_keys");
115 MAKE_TX(events, tx_0, miner_account, bob_account, send_amount, blk_0);
116 DO_CALLBACK(events, "increase_all_tx_count");
117 DO_CALLBACK(events, "check_txpool_spent_keys");
118
119 return true;
120 }
121
122 txpool_double_spend_base::txpool_double_spend_base()
123 : txpool_base()
124 , m_broadcasted_hashes()
125 , m_no_relay_hashes()
126 , m_all_hashes()
127 , m_no_new_index(0)
128 , m_failed_index(0)
129 , m_new_timestamp_index(0)
130 , m_last_tx(crypto::hash{})
131 {
132 REGISTER_CALLBACK_METHOD(txpool_double_spend_base, mark_no_new);
133 REGISTER_CALLBACK_METHOD(txpool_double_spend_base, mark_failed);
134 REGISTER_CALLBACK_METHOD(txpool_double_spend_base, mark_timestamp_change);
135 REGISTER_CALLBACK_METHOD(txpool_double_spend_base, timestamp_change_pause);
136 REGISTER_CALLBACK_METHOD(txpool_double_spend_base, check_unchanged);
137 REGISTER_CALLBACK_METHOD(txpool_double_spend_base, check_new_broadcasted);
138 REGISTER_CALLBACK_METHOD(txpool_double_spend_base, check_new_hidden);
139 REGISTER_CALLBACK_METHOD(txpool_double_spend_base, check_new_no_relay);
140 }
141
142 bool txpool_double_spend_base::mark_no_new(cryptonote::core& /*c*/, size_t ev_index, const std::vector<test_event_entry>& /*events*/)
143 {
144 m_no_new_index = ev_index + 1;
145 return true;
146 }
147
148 bool txpool_double_spend_base::mark_failed(cryptonote::core& /*c*/, size_t ev_index, const std::vector<test_event_entry>& /*events*/)
149 {
150 m_failed_index = ev_index + 1;
151 return true;
152 }
153
154 bool txpool_double_spend_base::mark_timestamp_change(cryptonote::core& /*c*/, size_t ev_index, const std::vector<test_event_entry>& /*events*/)
155 {
156 m_new_timestamp_index = ev_index + 1;
157 return true;
158 }
159
160 bool txpool_double_spend_base::timestamp_change_pause(cryptonote::core& /*c*/, size_t /*ev_index*/, const std::vector<test_event_entry>& /*events*/)
161 {
162 boost::this_thread::sleep_for(boost::chrono::seconds{1} + boost::chrono::milliseconds{100});
163 return true;
164 }
165
166 bool txpool_double_spend_base::check_changed(cryptonote::core& c, const size_t ev_index, relay_test condition)
167 {
168 const std::size_t new_broadcasted_hash_count = m_broadcasted_hashes.size() + unsigned(condition == relay_test::broadcasted);
169 const std::size_t new_all_hash_count = m_all_hashes.size() + unsigned(condition == relay_test::hidden) + unsigned(condition == relay_test::no_relay);
170
171 std::vector<crypto::hash> hashes{};
172 if (!c.get_pool_transaction_hashes(hashes))
173 {
174 MERROR("Failed to get broadcasted transaction pool hashes");
175 return false;
176 }
177
178 for (const crypto::hash& hash : hashes)
179 m_broadcasted_hashes.insert(hash);
180
181 if (new_broadcasted_hash_count != m_broadcasted_hashes.size())
182 {
183 MERROR("Expected " << new_broadcasted_hash_count << " broadcasted hashes but got " << m_broadcasted_hashes.size());
184 return false;
185 }
186
187 if (m_broadcasted_hashes.size() != c.get_pool_transactions_count())
188 {
189 MERROR("Expected " << m_broadcasted_hashes.size() << " broadcasted hashes but got " << c.get_pool_transactions_count());
190 return false;
191 }
192
193 hashes.clear();
194 if (!c.get_pool_transaction_hashes(hashes, false))
195 {
196 MERROR("Failed to get broadcasted transaction pool hashes");
197 return false;
198 }
199
200 for (const crypto::hash& hash : hashes)
201 m_all_hashes.insert(std::make_pair(hash, 0));
202
203 if (new_broadcasted_hash_count != m_broadcasted_hashes.size())
204 {
205 MERROR("Expected " << new_broadcasted_hash_count << " broadcasted hashes but got " << m_broadcasted_hashes.size());
206 return false;
207 }
208
209 hashes.clear();
210 if (!c.get_pool_transaction_hashes(hashes, true))
211 {
212
213 MERROR("Failed to get all transaction pool hashes");
214 return false;
215 }
216
217 for (const crypto::hash& hash : hashes)
218 m_all_hashes.insert(std::make_pair(hash, 0));
219
220 if (new_all_hash_count != m_all_hashes.size())
221 {
222 MERROR("Expected " << new_all_hash_count << " all hashes but got " << m_all_hashes.size());
223 return false;
224 }
225
226 if (condition == relay_test::no_relay)
227 {
228 if (!m_no_relay_hashes.insert(m_last_tx).second)
229 {
230 MERROR("Expected new no_relay tx but got a duplicate legacy tx");
231 return false;
232 }
233
234 for (const crypto::hash& hash : m_no_relay_hashes)
235 {
236 if (!c.pool_has_tx(hash))
237 {
238 MERROR("Expected public tx " << hash << " to be listed in pool");
239 return false;
240 }
241 }
242 }
243
244 // check receive time changes
245 {
246 std::vector<cryptonote::tx_info> infos{};
247 std::vector<cryptonote::spent_key_image_info> key_images{};
248 if (!c.get_pool_transactions_and_spent_keys_info(infos, key_images, true) || infos.size() != m_all_hashes.size())
249 {
250 MERROR("Unable to retrieve all txpool metadata");
251 return false;
252 }
253
254 for (const cryptonote::tx_info& info : infos)
255 {
256 crypto::hash tx_hash;
257 if (!epee::string_tools::hex_to_pod(info.id_hash, tx_hash))
258 {
259 MERROR("Unable to convert tx_hash hex to binary");
260 return false;
261 }
262
263 const auto entry = m_all_hashes.find(tx_hash);
264 if (entry == m_all_hashes.end())
265 {
266 MERROR("Unable to find tx_hash in set of tracked hashes");
267 return false;
268 }
269
270 if (m_new_timestamp_index == ev_index && m_last_tx == tx_hash)
271 {
272 if (entry->second >= info.receive_time)
273 {
274 MERROR("Last relay time did not change as expected - last at " << entry->second << " and current at " << info.receive_time);
275 return false;
276 }
277 entry->second = info.receive_time;
278 }
279 else if (entry->second != info.receive_time)
280 {
281 MERROR("Last relayed time changed unexpectedly from " << entry->second << " to " << info.receive_time);
282 return false;
283 }
284 }
285 }
286
287 {
288 std::vector<cryptonote::transaction> txes{};
289 if (!c.get_pool_transactions(txes))
290 {
291 MERROR("Failed to get broadcasted transactions from pool");
292 return false;
293 }
294
295 hashes.clear();
296 for (const cryptonote::transaction& tx : txes)
297 hashes.push_back(cryptonote::get_transaction_hash(tx));
298
299 std::unordered_set<crypto::hash> public_hashes = m_broadcasted_hashes;
300 for (const crypto::hash& hash : hashes)
301 {
302 if (!c.pool_has_tx(hash))
303 {
304 MERROR("Expected broadcasted tx " << hash << " to be listed in pool");
305 return false;
306 }
307
308 if (!public_hashes.erase(hash))
309 {
310 MERROR("An unexected transaction was returned from the public pool");
311 return false;
312 }
313 }
314 if (!public_hashes.empty())
315 {
316 MERROR(public_hashes.size() << " transaction(s) were missing from the public pool");
317 return false;
318 }
319 }
320
321 {
322 std::vector<cryptonote::transaction> txes{};
323 if (!c.get_pool_transactions(txes, false))
324 {
325 MERROR("Failed to get broadcasted transactions from pool");
326 return false;
327 }
328
329 hashes.clear();
330 for (const cryptonote::transaction& tx : txes)
331 hashes.push_back(cryptonote::get_transaction_hash(tx));
332
333 std::unordered_set<crypto::hash> public_hashes = m_broadcasted_hashes;
334 for (const crypto::hash& hash : hashes)
335 {
336
337 if (!public_hashes.erase(hash))
338 {
339 MERROR("An unexected transaction was returned from the public pool");
340 return false;
341 }
342 }
343 if (!public_hashes.empty())
344 {
345 MERROR(public_hashes.size() << " transaction(s) were missing from the public pool");
346 return false;
347 }
348 }
349
350 {
351 std::vector<cryptonote::transaction> txes{};
352 if (!c.get_pool_transactions(txes, true))
353 {
354 MERROR("Failed to get all transactions from pool");
355 return false;
356 }
357
358 hashes.clear();
359 for (const cryptonote::transaction& tx : txes)
360 hashes.push_back(cryptonote::get_transaction_hash(tx));
361
362 std::unordered_map<crypto::hash, uint64_t> all_hashes = m_all_hashes;
363 for (const crypto::hash& hash : hashes)
364 {
365 if (!all_hashes.erase(hash))
366 {
367 MERROR("An unexected transaction was returned from the all pool");
368 return false;
369 }
370 }
371 if (!all_hashes.empty())
372 {
373 MERROR(m_broadcasted_hashes.size() << " transaction(s) were missing from the all pool");
374 return false;
375 }
376 }
377
378 {
379 std::vector<cryptonote::tx_backlog_entry> entries{};
380 if (!c.get_txpool_backlog(entries))
381 {
382 MERROR("Failed to get broadcasted txpool backlog");
383 return false;
384 }
385
386 if (m_broadcasted_hashes.size() != entries.size())
387 {
388 MERROR("Expected " << m_broadcasted_hashes.size() << " in the broadcasted txpool backlog but got " << entries.size());
389 return false;
390 }
391 }
392
393 for (const std::pair<const crypto::hash, uint64_t>& hash : m_all_hashes)
394 {
395 cryptonote::blobdata tx_blob{};
396 if (!c.get_pool_transaction(hash.first, tx_blob, cryptonote::relay_category::all))
397 {
398 MERROR("Failed to retrieve tx expected to be in pool: " << hash.first);
399 return false;
400 }
401 }
402
403 {
404 std::unordered_map<crypto::hash, uint64_t> difference = m_all_hashes;
405 for (const crypto::hash& hash : m_broadcasted_hashes)
406 difference.erase(hash);
407
408 for (const crypto::hash& hash : m_no_relay_hashes)
409 difference.erase(hash);
410
411 for (const std::pair<const crypto::hash, uint64_t>& hash : difference)
412 {
413 if (c.pool_has_tx(hash.first))
414 {
415 MERROR("Did not expect private/hidden tx " << hash.first << " to be listed in pool");
416 return false;
417 }
418
419 cryptonote::blobdata tx_blob{};
420 if (c.get_pool_transaction(hash.first, tx_blob, cryptonote::relay_category::broadcasted))
421 {
422 MERROR("Tx " << hash.first << " is not supposed to be in broadcasted pool");
423 return false;
424 }
425
426 if (!c.get_pool_transaction(hash.first, tx_blob, cryptonote::relay_category::all))
427 {
428 MERROR("Tx " << hash.first << " blob could not be retrieved from pool");
429 return false;
430 }
431 }
432 }
433
434 {
435 cryptonote::txpool_stats stats{};
436 if (!c.get_pool_transaction_stats(stats) || stats.txs_total != m_broadcasted_hashes.size())
437 {
438 MERROR("Expected broadcasted stats to list " << m_broadcasted_hashes.size() << " txes but got " << stats.txs_total);
439 return false;
440 }
441
442 if (!c.get_pool_transaction_stats(stats, false) || stats.txs_total != m_broadcasted_hashes.size())
443 {
444 MERROR("Expected broadcasted stats to list " << m_broadcasted_hashes.size() << " txes but got " << stats.txs_total);
445 return false;
446 }
447
448 if (!c.get_pool_transaction_stats(stats, true) || stats.txs_total != m_all_hashes.size())
449 {
450 MERROR("Expected all stats to list " << m_all_hashes.size() << " txes but got " << stats.txs_total);
451 return false;
452 }
453 }
454
455 {
456 std::vector<cryptonote::rpc::tx_in_pool> infos{};
457 cryptonote::rpc::key_images_with_tx_hashes key_images{};
458 if (!c.get_pool_for_rpc(infos, key_images) || infos.size() != m_broadcasted_hashes.size() || key_images.size() != m_broadcasted_hashes.size())
459 {
460 MERROR("Expected broadcasted rpc data to return " << m_broadcasted_hashes.size() << " but got " << infos.size() << " infos and " << key_images.size() << "key images");
461 return false;
462 }
463 }
464 return true;
465 }
466
467 bool txpool_double_spend_base::check_unchanged(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry>& /*events */)
468 {
469 return check_changed(c, ev_index, relay_test::no_change);
470 }
471
472 bool txpool_double_spend_base::check_new_broadcasted(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry>& /*events */)
473 {
474 return check_changed(c, ev_index, relay_test::broadcasted);
475 }
476
477 bool txpool_double_spend_base::check_new_hidden(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry>& /*events */)
478 {
479 return check_changed(c, ev_index, relay_test::hidden);
480 }
481 bool txpool_double_spend_base::check_new_no_relay(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry>& /*events */)
482 {
483 return check_changed(c, ev_index, relay_test::no_relay);
484 }
485
486 bool txpool_double_spend_base::check_tx_verification_context(const cryptonote::tx_verification_context& tvc, bool tx_added, size_t event_idx, const cryptonote::transaction& tx)
487 {
488 m_last_tx = cryptonote::get_transaction_hash(tx);
489 if (m_no_new_index == event_idx)
490 return !tvc.m_verifivation_failed && !tx_added;
491 else if (m_failed_index == event_idx)
492 return tvc.m_verifivation_failed;// && !tx_added;
493 else
494 return !tvc.m_verifivation_failed && tx_added;
495 }
496
497 bool txpool_double_spend_norelay::generate(std::vector<test_event_entry>& events) const
498 {
499 INIT_MEMPOOL_TEST();
500
501 DO_CALLBACK(events, "check_txpool_spent_keys");
502 SET_EVENT_VISITOR_SETT(events, event_visitor_settings::set_txs_do_not_relay);
503 DO_CALLBACK(events, "mark_no_new");
504
505 MAKE_TX(events, tx_0, miner_account, bob_account, send_amount, blk_0);
506
507 DO_CALLBACK(events, "increase_all_tx_count");
508 DO_CALLBACK(events, "check_txpool_spent_keys");
509 DO_CALLBACK(events, "mark_timestamp_change");
510 DO_CALLBACK(events, "check_new_no_relay");
511 DO_CALLBACK(events, "timestamp_change_pause");
512 DO_CALLBACK(events, "mark_no_new");
513 events.push_back(tx_0);
514 DO_CALLBACK(events, "check_txpool_spent_keys");
515 DO_CALLBACK(events, "check_unchanged");
516 SET_EVENT_VISITOR_SETT(events, 0);
517 DO_CALLBACK(events, "timestamp_change_pause");
518 DO_CALLBACK(events, "mark_no_new");
519 events.push_back(tx_0);
520 DO_CALLBACK(events, "check_txpool_spent_keys");
521 DO_CALLBACK(events, "check_unchanged");
522
523 // kepped by block currently does not change txpool status
524 SET_EVENT_VISITOR_SETT(events, event_visitor_settings::set_txs_keeped_by_block);
525 DO_CALLBACK(events, "timestamp_change_pause");
526 DO_CALLBACK(events, "mark_no_new");
527 events.push_back(tx_0);
528 DO_CALLBACK(events, "check_txpool_spent_keys");
529 DO_CALLBACK(events, "check_unchanged");
530
531 return true;
532 }
533
534 bool txpool_double_spend_local::generate(std::vector<test_event_entry>& events) const
535 {
536 INIT_MEMPOOL_TEST();
537
538 DO_CALLBACK(events, "check_txpool_spent_keys");
539 SET_EVENT_VISITOR_SETT(events, event_visitor_settings::set_local_relay);
540 DO_CALLBACK(events, "mark_no_new");
541
542 MAKE_TX(events, tx_0, miner_account, bob_account, send_amount, blk_0);
543
544 DO_CALLBACK(events, "increase_all_tx_count");
545 DO_CALLBACK(events, "check_txpool_spent_keys");
546 DO_CALLBACK(events, "mark_timestamp_change");
547 DO_CALLBACK(events, "check_new_hidden");
548 DO_CALLBACK(events, "timestamp_change_pause");
549 DO_CALLBACK(events, "mark_no_new");
550 events.push_back(tx_0);
551 DO_CALLBACK(events, "check_txpool_spent_keys");
552 DO_CALLBACK(events, "check_unchanged");
553 SET_EVENT_VISITOR_SETT(events, 0);
554 DO_CALLBACK(events, "timestamp_change_pause");
555 events.push_back(tx_0);
556 DO_CALLBACK(events, "increase_broadcasted_tx_count");
557 DO_CALLBACK(events, "check_txpool_spent_keys");
558 DO_CALLBACK(events, "mark_timestamp_change");
559 DO_CALLBACK(events, "check_new_broadcasted");
560 DO_CALLBACK(events, "timestamp_change_pause");
561 DO_CALLBACK(events, "mark_no_new");
562 events.push_back(tx_0);
563 DO_CALLBACK(events, "check_unchanged");
564
565 return true;
566 }
567
568 bool txpool_double_spend_keyimage::generate(std::vector<test_event_entry>& events) const
569 {
570 INIT_MEMPOOL_TEST();
571
572 DO_CALLBACK(events, "check_txpool_spent_keys");
573 SET_EVENT_VISITOR_SETT(events, event_visitor_settings::set_local_relay);
574 DO_CALLBACK(events, "mark_no_new");
575
576 const std::size_t tx_index1 = events.size();
577 MAKE_TX(events, tx_0, miner_account, bob_account, send_amount, blk_0);
578
579 SET_EVENT_VISITOR_SETT(events, event_visitor_settings::set_txs_stem);
580 DO_CALLBACK(events, "increase_all_tx_count");
581 DO_CALLBACK(events, "check_txpool_spent_keys");
582 DO_CALLBACK(events, "mark_timestamp_change");
583 DO_CALLBACK(events, "check_new_hidden");
584 DO_CALLBACK(events, "timestamp_change_pause");
585 DO_CALLBACK(events, "mark_no_new");
586 const std::size_t tx_index2 = events.size();
587 events.push_back(tx_0);
588 DO_CALLBACK(events, "check_txpool_spent_keys");
589 DO_CALLBACK(events, "mark_timestamp_change");
590 DO_CALLBACK(events, "check_unchanged");
591
592 // use same key image with different id
593 cryptonote::transaction tx_1;
594 {
595 auto events_copy = events;
596 events_copy.erase(events_copy.begin() + tx_index1);
597 events_copy.erase(events_copy.begin() + tx_index2 - 1);
598 MAKE_TX(events_copy, tx_temp, miner_account, bob_account, send_amount, blk_0);
599 tx_1 = tx_temp;
600 }
601
602 // same key image
603 DO_CALLBACK(events, "timestamp_change_pause");
604 DO_CALLBACK(events, "mark_failed");
605 events.push_back(tx_1);
606 DO_CALLBACK(events, "check_unchanged");
607
608 return true;
609 }
610
611 bool txpool_stem_loop::generate(std::vector<test_event_entry>& events) const
612 {
613 INIT_MEMPOOL_TEST();
614
615 DO_CALLBACK(events, "check_txpool_spent_keys");
616 SET_EVENT_VISITOR_SETT(events, event_visitor_settings::set_txs_stem);
617 DO_CALLBACK(events, "mark_no_new");
618
619 MAKE_TX(events, tx_0, miner_account, bob_account, send_amount, blk_0);
620
621 DO_CALLBACK(events, "increase_all_tx_count");
622 DO_CALLBACK(events, "check_txpool_spent_keys");
623 DO_CALLBACK(events, "mark_timestamp_change");
624 DO_CALLBACK(events, "check_new_hidden");
625 DO_CALLBACK(events, "timestamp_change_pause");
626 events.push_back(tx_0);
627 DO_CALLBACK(events, "increase_broadcasted_tx_count");
628 DO_CALLBACK(events, "check_txpool_spent_keys");
629 DO_CALLBACK(events, "mark_timestamp_change");
630 DO_CALLBACK(events, "check_new_broadcasted");
631 DO_CALLBACK(events, "timestamp_change_pause");
632 DO_CALLBACK(events, "mark_no_new");
633 events.push_back(tx_0);
634 DO_CALLBACK(events, "check_unchanged");
635
636 return true;
637 }