From 637d4031e11c8f376e1c103a924f01ac1784bbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Mon, 4 Nov 2024 11:13:51 +0100 Subject: [PATCH] Clone blocks passed in test --- nano/core_test/node.cpp | 8 ++++---- nano/test_common/testutil.cpp | 7 +++++++ nano/test_common/testutil.hpp | 4 ++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/nano/core_test/node.cpp b/nano/core_test/node.cpp index 0cadbbaaa..7a50183ca 100644 --- a/nano/core_test/node.cpp +++ b/nano/core_test/node.cpp @@ -2211,12 +2211,12 @@ TEST (node, epoch_conflict_confirm) .build (); // Process initial blocks - ASSERT_TRUE (nano::test::process (node0, { send, send2, open })); - ASSERT_TRUE (nano::test::process (node1, { send, send2, open })); + ASSERT_TRUE (nano::test::process (node0, nano::test::clone ({ send, send2, open }))); + ASSERT_TRUE (nano::test::process (node1, nano::test::clone ({ send, send2, open }))); // Process conflicting blocks on nodes as blocks coming from live network - ASSERT_TRUE (nano::test::process_live (node0, { change, epoch_open })); - ASSERT_TRUE (nano::test::process_live (node1, { change, epoch_open })); + ASSERT_TRUE (nano::test::process_live (node0, nano::test::clone ({ change, epoch_open }))); + ASSERT_TRUE (nano::test::process_live (node1, nano::test::clone ({ change, epoch_open }))); // Ensure blocks were propagated to both nodes ASSERT_TIMELY (5s, nano::test::exists (node0, { change, epoch_open })); diff --git a/nano/test_common/testutil.cpp b/nano/test_common/testutil.cpp index 563bc6884..75a72baae 100644 --- a/nano/test_common/testutil.cpp +++ b/nano/test_common/testutil.cpp @@ -242,6 +242,13 @@ std::vector nano::test::blocks_to_hashes (std::vector> nano::test::clone (std::vector> blocks) +{ + std::vector> clones; + std::transform (blocks.begin (), blocks.end (), std::back_inserter (clones), [] (auto & block) { return block->clone (); }); + return clones; +} + std::shared_ptr nano::test::fake_channel (nano::node & node, nano::account node_id) { auto channel = std::make_shared (node); diff --git a/nano/test_common/testutil.hpp b/nano/test_common/testutil.hpp index bcf6d255a..a30925131 100644 --- a/nano/test_common/testutil.hpp +++ b/nano/test_common/testutil.hpp @@ -390,6 +390,10 @@ namespace test * Converts list of blocks to list of hashes */ std::vector blocks_to_hashes (std::vector> blocks); + /* + * Clones list of blocks + */ + std::vector> clone (std::vector> blocks); /* * Creates a new fake channel associated with `node` */