diff --git a/src/test/utxocommit_tests.cpp b/src/test/utxocommit_tests.cpp --- a/src/test/utxocommit_tests.cpp +++ b/src/test/utxocommit_tests.cpp @@ -170,4 +170,35 @@ LogPrintf("ECMH generation from cursor done\n"); } +BOOST_AUTO_TEST_CASE(utxo_commit_combine) { + + const COutPoint op1 = RandomOutpoint(); + const COutPoint op2 = RandomOutpoint(); + const Coin c1 = RandomCoin(); + const Coin c2 = RandomCoin(); + + CUtxoCommit uc1, uc2, uc3; + + // Test combining empty commits + uc1.Add(uc2); + BOOST_CHECK(uc1 == CUtxoCommit()); + + // Test combining simple commitments + uc1.Add(op1, c1); + uc2.Add(op2, c2); + uc1.Add(uc2); + + uc3.Add(op1, c1); + uc3.Add(op2, c2); + + BOOST_CHECK(uc1 == uc3); + + // Test combining commitments with removed UTXOs + uc3.Clear(); + uc3.Remove(op1, c1); + uc1.Add(uc3); + + BOOST_CHECK(uc1 == uc2); +} + BOOST_AUTO_TEST_SUITE_END()