#include <common/system.h>
#include <policy/rbf.h>
#include <random.h>
#include <test/util/txmempool.h>
#include <txmempool.h>
#include <util/time.h>
#include <test/util/setup_common.h>
#include <boost/test/unit_test.hpp>
#include <optional>
#include <vector>
BOOST_FIXTURE_TEST_SUITE(rbf_tests, BasicTestingSetup)
static inline CTransactionRef make_tx(const std::vector<CTransactionRef>& inputs,
const std::vector<CAmount>& output_values)
{
CMutableTransaction tx = CMutableTransaction();
tx.vin.resize(inputs.size());
tx.vout.resize(output_values.size());
for (size_t i = 0; i < inputs.size(); ++i) {
tx.vin[i].prevout.hash = inputs[i]->GetHash();
tx.vin[i].prevout.n = 0;
CScriptWitness witness;
witness.stack.emplace_back(i + 10);
tx.vin[i].scriptWitness = witness;
}
for (size_t i = 0; i < output_values.size(); ++i) {
tx.vout[i].scriptPubKey = CScript() << OP_11 << OP_EQUAL;
tx.vout[i].nValue = output_values[i];
}
return MakeTransactionRef(tx);
}
static CTransactionRef add_descendants(const CTransactionRef& tx, int32_t num_descendants, CTxMemPool& pool)
EXCLUSIVE_LOCKS_REQUIRED(::cs_main, pool.cs)
{
AssertLockHeld(::cs_main);
AssertLockHeld(pool.cs);
TestMemPoolEntryHelper entry;
auto tx_to_spend = tx;
for (int32_t i{0}; i < num_descendants; ++i) {
auto next_tx = make_tx({tx_to_spend}, {(50 - i) * CENT});
TryAddToMempool(pool, entry.FromTx(next_tx));
BOOST_CHECK(pool.GetIter(next_tx->GetHash()).has_value());
tx_to_spend = next_tx;
}
return tx_to_spend;
}
BOOST_FIXTURE_TEST_CASE(rbf_helper_functions, TestChain100Setup)
{
CTxMemPool& pool = *Assert(m_node.mempool);
LOCK2(::cs_main, pool.cs);
TestMemPoolEntryHelper entry;
const CAmount low_fee{CENT/100};
const CAmount normal_fee{CENT/10};
const CAmount high_fee{CENT};
const auto tx1 = make_tx( {m_coinbase_txns[0]}, {10 * COIN});
TryAddToMempool(pool, entry.Fee(normal_fee).FromTx(tx1));
const auto tx2 = make_tx( {tx1}, {995 * CENT});
TryAddToMempool(pool, entry.Fee(normal_fee).FromTx(tx2));
const auto tx3 = make_tx( {m_coinbase_txns[1]}, {1099 * CENT});
TryAddToMempool(pool, entry.Fee(low_fee).FromTx(tx3));
const auto tx4 = make_tx( {tx3}, {999 * CENT});
TryAddToMempool(pool, entry.Fee(high_fee).FromTx(tx4));
const auto tx5 = make_tx( {m_coinbase_txns[2]}, {1099 * CENT});
TryAddToMempool(pool, entry.Fee(low_fee).FromTx(tx5));
const auto tx6 = make_tx( {tx5}, {1098 * CENT});
TryAddToMempool(pool, entry.Fee(low_fee).FromTx(tx6));
pool.PrioritiseTransaction(tx6->GetHash(), 1 * COIN);
const auto tx7 = make_tx( {m_coinbase_txns[3]}, {999 * CENT});
TryAddToMempool(pool, entry.Fee(high_fee).FromTx(tx7));
const auto tx8 = make_tx( {m_coinbase_txns[4]}, {999 * CENT});
TryAddToMempool(pool, entry.Fee(high_fee).FromTx(tx8));
const auto tx11 = make_tx( {m_coinbase_txns[7]}, {995 * CENT});
TryAddToMempool(pool, entry.Fee(normal_fee).FromTx(tx11));
const auto tx12 = make_tx( {m_coinbase_txns[8]}, {995 * CENT});
TryAddToMempool(pool, entry.Fee(normal_fee).FromTx(tx12));
const auto tx13 = make_tx( {m_coinbase_txns[9]}, {995 * CENT, 995 * CENT});
TryAddToMempool(pool, entry.Fee(normal_fee).FromTx(tx13));
const auto entry1_normal = pool.GetIter(tx1->GetHash()).value();
const auto entry2_normal = pool.GetIter(tx2->GetHash()).value();
const auto entry3_low = pool.GetIter(tx3->GetHash()).value();
const auto entry4_high = pool.GetIter(tx4->GetHash()).value();
const auto entry5_low = pool.GetIter(tx5->GetHash()).value();
const auto entry6_low_prioritised = pool.GetIter(tx6->GetHash()).value();
const auto entry7_high = pool.GetIter(tx7->GetHash()).value();
const auto entry8_high = pool.GetIter(tx8->GetHash()).value();
BOOST_CHECK_EQUAL(entry1_normal->GetFee(), normal_fee);
BOOST_CHECK_EQUAL(entry2_normal->GetFee(), normal_fee);
BOOST_CHECK_EQUAL(entry3_low->GetFee(), low_fee);
BOOST_CHECK_EQUAL(entry4_high->GetFee(), high_fee);
BOOST_CHECK_EQUAL(entry5_low->GetFee(), low_fee);
BOOST_CHECK_EQUAL(entry6_low_prioritised->GetFee(), low_fee);
BOOST_CHECK_EQUAL(entry7_high->GetFee(), high_fee);
BOOST_CHECK_EQUAL(entry8_high->GetFee(), high_fee);
CTxMemPool::setEntries set_12_normal{entry1_normal, entry2_normal};
CTxMemPool::setEntries set_34_cpfp{entry3_low, entry4_high};
CTxMemPool::setEntries set_56_low{entry5_low, entry6_low_prioritised};
CTxMemPool::setEntries set_78_high{entry7_high, entry8_high};
CTxMemPool::setEntries all_entries{entry1_normal, entry2_normal, entry3_low, entry4_high,
entry5_low, entry6_low_prioritised, entry7_high, entry8_high};
CTxMemPool::setEntries empty_set;
const auto unused_txid = Txid::FromUint256(GetRandHash());
BOOST_CHECK(EntriesAndTxidsDisjoint(empty_set, {tx1->GetHash()}, unused_txid) == std::nullopt);
BOOST_CHECK(EntriesAndTxidsDisjoint(set_12_normal, {tx3->GetHash()}, unused_txid) == std::nullopt);
BOOST_CHECK(EntriesAndTxidsDisjoint({entry2_normal}, {tx2->GetHash()}, unused_txid).has_value());
BOOST_CHECK(EntriesAndTxidsDisjoint(set_12_normal, {tx1->GetHash()}, unused_txid).has_value());
BOOST_CHECK(EntriesAndTxidsDisjoint(set_12_normal, {tx2->GetHash()}, unused_txid).has_value());
BOOST_CHECK(EntriesAndTxidsDisjoint({entry2_normal}, {tx1->GetHash()}, unused_txid) == std::nullopt);
const CFeeRate incremental_relay_feerate{DEFAULT_INCREMENTAL_RELAY_FEE};
const CFeeRate higher_relay_feerate{2 * DEFAULT_INCREMENTAL_RELAY_FEE};
BOOST_CHECK(PaysForRBF(high_fee,
high_fee,
1,
CFeeRate(0),
unused_txid)
== std::nullopt);
BOOST_CHECK(PaysForRBF(high_fee, high_fee - 1, 1, CFeeRate(0), unused_txid).has_value());
BOOST_CHECK(PaysForRBF(high_fee + 1, high_fee, 1, CFeeRate(0), unused_txid).has_value());
BOOST_CHECK(PaysForRBF(high_fee, high_fee + 1, 11, incremental_relay_feerate, unused_txid).has_value());
BOOST_CHECK(PaysForRBF(high_fee, high_fee + 1, 10, incremental_relay_feerate, unused_txid) == std::nullopt);
BOOST_CHECK(PaysForRBF(high_fee, high_fee + 2, 11, higher_relay_feerate, unused_txid).has_value());
BOOST_CHECK(PaysForRBF(high_fee, high_fee + 4, 20, higher_relay_feerate, unused_txid) == std::nullopt);
BOOST_CHECK(PaysForRBF(low_fee, high_fee, 99999999, incremental_relay_feerate, unused_txid).has_value());
BOOST_CHECK(PaysForRBF(low_fee, high_fee + 99999999, 99999999, incremental_relay_feerate, unused_txid) == std::nullopt);
}
BOOST_FIXTURE_TEST_CASE(rbf_conflicts_calculator, TestChain100Setup)
{
CTxMemPool& pool = *Assert(m_node.mempool);
LOCK2(::cs_main, pool.cs);
TestMemPoolEntryHelper entry;
const CAmount normal_fee{CENT/10};
const int NUM_OUTPUTS = 51;
std::vector<CAmount> output_values;
output_values.reserve(NUM_OUTPUTS);
for (int i = 0; i < NUM_OUTPUTS; ++i) {
output_values.push_back(1 * COIN);
}
const auto parent_tx_1 = make_tx( {m_coinbase_txns[0]}, output_values);
const auto parent_tx_2 = make_tx( {m_coinbase_txns[1]}, output_values);
TryAddToMempool(pool, entry.Fee(normal_fee).FromTx(parent_tx_1));
TryAddToMempool(pool, entry.Fee(normal_fee).FromTx(parent_tx_2));
std::vector<CTransactionRef> direct_children;
for (const auto& parent_tx : {parent_tx_1, parent_tx_2}) {
for (auto i = 0; i < NUM_OUTPUTS; ++i) {
auto pretx = make_tx( {parent_tx}, {995 * CENT});
CMutableTransaction tx(*pretx);
tx.vin[0].prevout.n = i;
TryAddToMempool(pool, entry.Fee(normal_fee).FromTx(tx));
BOOST_CHECK(pool.GetIter(tx.GetHash()).has_value());
direct_children.push_back(MakeTransactionRef(tx));
}
}
const auto parent_entry_1 = pool.GetIter(parent_tx_1->GetHash()).value();
const auto parent_entry_2 = pool.GetIter(parent_tx_2->GetHash()).value();
const auto conflicting_transaction = make_tx({parent_tx_1, parent_tx_2}, {50 * CENT});
CTxMemPool::setEntries all_conflicts, dummy;
BOOST_CHECK(GetEntriesForConflicts( *conflicting_transaction.get(),
pool,
{parent_entry_1, parent_entry_2},
all_conflicts) == std::nullopt);
dummy.clear();
BOOST_CHECK(GetEntriesForConflicts( *conflicting_transaction.get(),
pool,
all_conflicts,
dummy) == std::nullopt);
BOOST_CHECK_EQUAL(all_conflicts.size(), dummy.size());
dummy.clear();
pool.removeForBlock({parent_tx_1, parent_tx_2}, 1);
for (const auto& child : direct_children) {
add_descendants(child, 10, pool);
}
CTxMemPool::setEntries conflicts;
for (auto i = 0; i < 100; ++i) {
conflicts.insert(pool.GetIter(direct_children[i]->GetHash()).value());
}
BOOST_CHECK(GetEntriesForConflicts( *conflicting_transaction.get(),
pool,
conflicts,
dummy) == std::nullopt);
conflicts.insert(pool.GetIter(direct_children[100]->GetHash()).value());
BOOST_CHECK(GetEntriesForConflicts( *conflicting_transaction.get(),
pool,
conflicts,
dummy).has_value());
}
BOOST_FIXTURE_TEST_CASE(improves_feerate, TestChain100Setup)
{
CTxMemPool& pool = *Assert(m_node.mempool);
LOCK2(::cs_main, pool.cs);
TestMemPoolEntryHelper entry;
const CAmount low_fee{CENT/100};
const CAmount normal_fee{CENT/10};
const auto tx1 = make_tx( {m_coinbase_txns[0], m_coinbase_txns[1]}, {10 * COIN});
TryAddToMempool(pool, entry.Fee(low_fee).FromTx(tx1));
const auto tx2 = make_tx( {tx1}, {995 * CENT});
TryAddToMempool(pool, entry.Fee(normal_fee).FromTx(tx2));
const auto entry1 = pool.GetIter(tx1->GetHash()).value();
const auto tx1_fee = entry1->GetModifiedFee();
const auto entry2 = pool.GetIter(tx2->GetHash()).value();
const auto tx2_fee = entry2->GetModifiedFee();
const auto tx1_conflict = make_tx( {m_coinbase_txns[0], m_coinbase_txns[2]}, {10 * COIN});
const auto tx3 = make_tx( {tx1_conflict}, {995 * CENT});
auto entry3 = entry.FromTx(tx3);
auto changeset = pool.GetChangeSet();
changeset->StageRemoval(entry1);
changeset->StageRemoval(entry2);
changeset->StageAddition(tx1_conflict, tx1_fee, 0, 1, 0, false, 4, LockPoints());
changeset->StageAddition(tx3, tx2_fee, 0, 1, 0, false, 4, LockPoints());
const auto res1 = ImprovesFeerateDiagram(*changeset);
BOOST_CHECK(res1.has_value());
BOOST_CHECK(res1.value().first == DiagramCheckError::FAILURE);
BOOST_CHECK(res1.value().second == "insufficient feerate: does not improve feerate diagram");
changeset.reset();
changeset = pool.GetChangeSet();
changeset->StageRemoval(entry1);
changeset->StageRemoval(entry2);
changeset->StageAddition(tx1_conflict, tx1_fee+1, 0, 1, 0, false, 4, LockPoints());
changeset->StageAddition(tx3, tx2_fee, 0, 1, 0, false, 4, LockPoints());
BOOST_CHECK(ImprovesFeerateDiagram(*changeset) == std::nullopt);
changeset.reset();
pool.PrioritiseTransaction(entry1->GetSharedTx()->GetHash(), 1);
changeset = pool.GetChangeSet();
changeset->StageRemoval(entry1);
changeset->StageRemoval(entry2);
changeset->StageAddition(tx1_conflict, tx1_fee+1, 0, 1, 0, false, 4, LockPoints());
changeset->StageAddition(tx3, tx2_fee, 0, 1, 0, false, 4, LockPoints());
const auto res2 = ImprovesFeerateDiagram(*changeset);
BOOST_CHECK(res2.has_value());
BOOST_CHECK(res2.value().first == DiagramCheckError::FAILURE);
BOOST_CHECK(res2.value().second == "insufficient feerate: does not improve feerate diagram");
changeset.reset();
pool.PrioritiseTransaction(entry1->GetSharedTx()->GetHash(), -1);
CMutableTransaction tx4{entry3.GetTx()};
tx4.vin[0].scriptWitness = CScriptWitness(); auto entry4 = entry.FromTx(MakeTransactionRef(tx4));
changeset = pool.GetChangeSet();
changeset->StageRemoval(entry1);
changeset->StageRemoval(entry2);
changeset->StageAddition(tx1_conflict, tx1_fee, 0, 1, 0, false, 4, LockPoints());
changeset->StageAddition(entry4.GetSharedTx(), tx2_fee, 0, 1, 0, false, 4, LockPoints());
BOOST_CHECK(ImprovesFeerateDiagram(*changeset) == std::nullopt);
changeset.reset();
const auto tx5 = make_tx( {tx2}, {995 * CENT});
TryAddToMempool(pool, entry.Fee(normal_fee).FromTx(tx5));
const auto entry5 = pool.GetIter(tx5->GetHash()).value();
changeset = pool.GetChangeSet();
changeset->StageRemoval(entry1);
changeset->StageRemoval(entry2);
changeset->StageRemoval(entry5);
changeset->StageAddition(tx1_conflict, tx1_fee, 0, 1, 0, false, 4, LockPoints());
changeset->StageAddition(entry4.GetSharedTx(), tx2_fee + entry5->GetModifiedFee() + 1, 0, 1, 0, false, 4, LockPoints());
const auto res3 = ImprovesFeerateDiagram(*changeset);
BOOST_CHECK(res3 == std::nullopt);
}
BOOST_FIXTURE_TEST_CASE(calc_feerate_diagram_rbf, TestChain100Setup)
{
CTxMemPool& pool = *Assert(m_node.mempool);
LOCK2(::cs_main, pool.cs);
TestMemPoolEntryHelper entry;
const CAmount low_fee{CENT/100};
const CAmount high_fee{CENT};
const auto low_tx = make_tx( {m_coinbase_txns[0]}, {10 * COIN});
TryAddToMempool(pool, entry.Fee(low_fee).FromTx(low_tx));
const auto entry_low = pool.GetIter(low_tx->GetHash()).value();
const auto low_size = entry_low->GetAdjustedWeight();
const auto replacement_tx = make_tx( {m_coinbase_txns[0]}, {9 * COIN});
auto entry_replacement = entry.FromTx(replacement_tx);
{
auto changeset = pool.GetChangeSet();
changeset->StageRemoval(entry_low);
changeset->StageAddition(replacement_tx, 0, 0, 1, 0, false, 4, LockPoints());
const auto replace_one{changeset->CalculateChunksForRBF()};
BOOST_CHECK(replace_one.has_value());
std::vector<FeeFrac> expected_old_chunks{{low_fee, low_size}};
BOOST_CHECK(replace_one->first == expected_old_chunks);
std::vector<FeeFrac> expected_new_chunks{{0, entry_replacement.GetAdjustedWeight()}};
BOOST_CHECK(replace_one->second == expected_new_chunks);
}
{
auto changeset = pool.GetChangeSet();
changeset->StageRemoval(entry_low);
changeset->StageAddition(replacement_tx, high_fee, 0, 1, 0, false, 4, LockPoints());
const auto replace_one_fee{changeset->CalculateChunksForRBF()};
BOOST_CHECK(replace_one_fee.has_value());
std::vector<FeeFrac> expected_old_diagram{{low_fee, low_size}};
BOOST_CHECK(replace_one_fee->first == expected_old_diagram);
std::vector<FeeFrac> expected_new_diagram{{high_fee, entry_replacement.GetAdjustedWeight()}};
BOOST_CHECK(replace_one_fee->second == expected_new_diagram);
}
const auto high_tx = make_tx( {low_tx}, {995 * CENT});
TryAddToMempool(pool, entry.Fee(high_fee).FromTx(high_tx));
const auto entry_high = pool.GetIter(high_tx->GetHash()).value();
const auto high_size = entry_high->GetAdjustedWeight();
{
auto changeset = pool.GetChangeSet();
changeset->StageRemoval(entry_low);
changeset->StageRemoval(entry_high);
changeset->StageAddition(replacement_tx, high_fee, 0, 1, 0, false, 4, LockPoints());
const auto replace_single_chunk{changeset->CalculateChunksForRBF()};
BOOST_CHECK(replace_single_chunk.has_value());
std::vector<FeeFrac> expected_old_chunks{{low_fee + high_fee, low_size + high_size}};
BOOST_CHECK(replace_single_chunk->first == expected_old_chunks);
std::vector<FeeFrac> expected_new_chunks{{high_fee, entry_replacement.GetAdjustedWeight()}};
BOOST_CHECK(replace_single_chunk->second == expected_new_chunks);
}
{
auto changeset = pool.GetChangeSet();
changeset->StageRemoval(entry_high);
changeset->StageAddition(replacement_tx, high_fee, 0, 1, 0, false, 4, LockPoints());
const auto replace_cpfp_child{changeset->CalculateChunksForRBF()};
BOOST_CHECK(replace_cpfp_child.has_value());
std::vector<FeeFrac> expected_old_chunks{{low_fee + high_fee, low_size + high_size}};
BOOST_CHECK(replace_cpfp_child->first == expected_old_chunks);
std::vector<FeeFrac> expected_new_chunks{{high_fee, entry_replacement.GetAdjustedWeight()}, {low_fee, low_size}};
BOOST_CHECK(replace_cpfp_child->second == expected_new_chunks);
}
const auto high_tx_2 = make_tx( {m_coinbase_txns[1]}, {10 * COIN});
TryAddToMempool(pool, entry.Fee(high_fee).FromTx(high_tx_2));
const auto entry_high_2 = pool.GetIter(high_tx_2->GetHash()).value();
const auto high_size_2 = entry_high_2->GetAdjustedWeight();
const auto low_tx_2 = make_tx( {high_tx_2}, {9 * COIN});
TryAddToMempool(pool, entry.Fee(low_fee).FromTx(low_tx_2));
const auto entry_low_2 = pool.GetIter(low_tx_2->GetHash()).value();
const auto low_size_2 = entry_low_2->GetAdjustedWeight();
{
auto changeset = pool.GetChangeSet();
changeset->StageRemoval(entry_high_2);
changeset->StageRemoval(entry_low_2);
changeset->StageAddition(replacement_tx, high_fee, 0, 1, 0, false, 4, LockPoints());
const auto replace_two_chunks_single_cluster{changeset->CalculateChunksForRBF()};
BOOST_CHECK(replace_two_chunks_single_cluster.has_value());
std::vector<FeeFrac> expected_old_chunks{{high_fee, high_size_2}, {low_fee, low_size_2}};
BOOST_CHECK(replace_two_chunks_single_cluster->first == expected_old_chunks);
std::vector<FeeFrac> expected_new_chunks{{high_fee, low_size_2}};
BOOST_CHECK(replace_two_chunks_single_cluster->second == expected_new_chunks);
}
const auto conflict_1 = make_tx( {m_coinbase_txns[2]}, {10 * COIN});
TryAddToMempool(pool, entry.Fee(low_fee).FromTx(conflict_1));
const auto conflict_1_entry = pool.GetIter(conflict_1->GetHash()).value();
const auto conflict_2 = make_tx( {m_coinbase_txns[3]}, {10 * COIN});
TryAddToMempool(pool, entry.Fee(low_fee).FromTx(conflict_2));
const auto conflict_2_entry = pool.GetIter(conflict_2->GetHash()).value();
const auto conflict_3 = make_tx( {m_coinbase_txns[4]}, {10 * COIN});
TryAddToMempool(pool, entry.Fee(low_fee).FromTx(conflict_3));
const auto conflict_3_entry = pool.GetIter(conflict_3->GetHash()).value();
{
auto changeset = pool.GetChangeSet();
changeset->StageRemoval(conflict_1_entry);
changeset->StageRemoval(conflict_2_entry);
changeset->StageRemoval(conflict_3_entry);
changeset->StageAddition(replacement_tx, high_fee, 0, 1, 0, false, 4, LockPoints());
const auto replace_multiple_clusters{changeset->CalculateChunksForRBF()};
BOOST_CHECK(replace_multiple_clusters.has_value());
BOOST_CHECK(replace_multiple_clusters->first.size() == 3);
BOOST_CHECK(replace_multiple_clusters->second.size() == 1);
}
const auto conflict_1_child = make_tx({conflict_1}, {995 * CENT});
TryAddToMempool(pool, entry.Fee(low_fee).FromTx(conflict_1_child));
const auto conflict_1_child_entry = pool.GetIter(conflict_1_child->GetHash()).value();
{
auto changeset = pool.GetChangeSet();
changeset->StageRemoval(conflict_1_entry);
changeset->StageRemoval(conflict_2_entry);
changeset->StageRemoval(conflict_3_entry);
changeset->StageRemoval(conflict_1_child_entry);
changeset->StageAddition(replacement_tx, high_fee, 0, 1, 0, false, 4, LockPoints());
const auto replace_multiple_clusters_2{changeset->CalculateChunksForRBF()};
BOOST_CHECK(replace_multiple_clusters_2.has_value());
BOOST_CHECK(replace_multiple_clusters_2->first.size() == 4);
BOOST_CHECK(replace_multiple_clusters_2->second.size() == 1);
}
}
BOOST_AUTO_TEST_CASE(feerate_chunks_utilities)
{
std::vector<FeeFrac> old_chunks{{{950, 300}, {100, 100}}};
std::vector<FeeFrac> new_chunks{{{1000, 300}, {50, 100}}};
BOOST_CHECK(std::is_lt(CompareChunks(old_chunks, new_chunks)));
BOOST_CHECK(std::is_gt(CompareChunks(new_chunks, old_chunks)));
old_chunks = {{950, 300}, {100, 100}};
new_chunks = {{1000, 300}, {0, 100}};
BOOST_CHECK(CompareChunks(old_chunks, new_chunks) == std::partial_ordering::unordered);
BOOST_CHECK(CompareChunks(new_chunks, old_chunks) == std::partial_ordering::unordered);
old_chunks = {{950, 300}, {100, 100}};
new_chunks = {{1100, 300}};
BOOST_CHECK(std::is_lt(CompareChunks(old_chunks, new_chunks)));
BOOST_CHECK(std::is_gt(CompareChunks(new_chunks, old_chunks)));
old_chunks = {{950, 300}, {100, 100}};
new_chunks = {{1100, 100}, {0, 100}};
BOOST_CHECK(std::is_lt(CompareChunks(old_chunks, new_chunks)));
BOOST_CHECK(std::is_gt(CompareChunks(new_chunks, old_chunks)));
old_chunks = {{950, 300}, {100, 100}};
new_chunks = {{750, 100}, {249, 250}, {151, 650}};
BOOST_CHECK(CompareChunks(old_chunks, new_chunks) == std::partial_ordering::unordered);
BOOST_CHECK(CompareChunks(new_chunks, old_chunks) == std::partial_ordering::unordered);
old_chunks = {{950, 300}, {100, 100}};
new_chunks = {{750, 100}, {250, 250}, {150, 150}};
BOOST_CHECK(std::is_lt(CompareChunks(old_chunks, new_chunks)));
BOOST_CHECK(std::is_gt(CompareChunks(new_chunks, old_chunks)));
old_chunks = {{950, 300}, {100, 100}};
new_chunks = {{950, 300}, {100, 100}};
BOOST_CHECK(std::is_eq(CompareChunks(old_chunks, new_chunks)));
BOOST_CHECK(std::is_eq(CompareChunks(new_chunks, old_chunks)));
old_chunks = {{950, 300}, {100, 99}};
new_chunks = {{950, 300}, {100, 100}};
BOOST_CHECK(std::is_gt(CompareChunks(old_chunks, new_chunks)));
BOOST_CHECK(std::is_lt(CompareChunks(new_chunks, old_chunks)));
old_chunks = {{950, 300}, {100, 99}};
new_chunks = {{950, 300}, {100, 100}, {0, 1}, {0, 1}};
BOOST_CHECK(std::is_gt(CompareChunks(old_chunks, new_chunks)));
BOOST_CHECK(std::is_lt(CompareChunks(new_chunks, old_chunks)));
new_chunks = {{950, 300}, {100, 100}, {0, 1}, {0, 1}, {1, 1}};
BOOST_CHECK(CompareChunks(old_chunks, new_chunks) == std::partial_ordering::unordered);
BOOST_CHECK(CompareChunks(new_chunks, old_chunks) == std::partial_ordering::unordered);
}
BOOST_AUTO_TEST_SUITE_END()