diff --git a/src/avalanche/proofbuilder.h b/src/avalanche/proofbuilder.h --- a/src/avalanche/proofbuilder.h +++ b/src/avalanche/proofbuilder.h @@ -41,8 +41,8 @@ : sequence(sequence_), expirationTime(expirationTime_), master(std::move(master_)) {} - bool addUTXO(COutPoint utxo, Amount amount, uint32_t height, - bool is_coinbase, CKey key); + [[nodiscard]] bool addUTXO(COutPoint utxo, Amount amount, uint32_t height, + bool is_coinbase, CKey key); Proof build(); diff --git a/src/avalanche/test/orphanproofpool_tests.cpp b/src/avalanche/test/orphanproofpool_tests.cpp --- a/src/avalanche/test/orphanproofpool_tests.cpp +++ b/src/avalanche/test/orphanproofpool_tests.cpp @@ -25,8 +25,8 @@ ProofBuilder pb(0, 0, CPubKey()); for (size_t i = 0; i < nStakes; i++) { TxId txid(GetRandHash()); - pb.addUTXO(COutPoint(txid, 0), v, height, false, - CKey::MakeCompressedKey()); + BOOST_CHECK(pb.addUTXO(COutPoint(txid, 0), v, height, false, + CKey::MakeCompressedKey())); } return std::make_shared(pb.build()); } diff --git a/src/avalanche/test/peermanager_tests.cpp b/src/avalanche/test/peermanager_tests.cpp --- a/src/avalanche/test/peermanager_tests.cpp +++ b/src/avalanche/test/peermanager_tests.cpp @@ -464,7 +464,7 @@ COutPoint utxo(TxId(GetRandHash()), 0); Amount amount = 1 * COIN; const int height = 1234; - pb.addUTXO(utxo, amount, height, false, key); + BOOST_CHECK(pb.addUTXO(utxo, amount, height, false, key)); auto proof = std::make_shared(pb.build()); const ProofId &proofid = proof->getId(); @@ -548,7 +548,7 @@ const auto getPeerId = [&](const std::vector &outpoints) { ProofBuilder pb(0, 0, CPubKey()); for (const auto &o : outpoints) { - pb.addUTXO(o, v, height, false, key); + BOOST_CHECK(pb.addUTXO(o, v, height, false, key)); } return pm.getPeerId(std::make_shared(pb.build())); @@ -580,7 +580,7 @@ { ProofBuilder pb(0, 0, CPubKey()); COutPoint o(txid1, 3); - pb.addUTXO(o, v, height, false, key); + BOOST_CHECK(pb.addUTXO(o, v, height, false, key)); PeerId peerid = pm.getPeerId(std::make_shared( TestProofBuilder::buildDuplicatedStakes(pb))); BOOST_CHECK_EQUAL(peerid, NO_PEER); @@ -615,7 +615,7 @@ const auto makeProof = [&](const COutPoint &outpoint, const int h) { ProofBuilder pb(0, 0, CPubKey()); - pb.addUTXO(outpoint, v, h, false, key); + BOOST_CHECK(pb.addUTXO(outpoint, v, h, false, key)); return std::make_shared(pb.build()); }; diff --git a/src/avalanche/test/proof_tests.cpp b/src/avalanche/test/proof_tests.cpp --- a/src/avalanche/test/proof_tests.cpp +++ b/src/avalanche/test/proof_tests.cpp @@ -49,9 +49,9 @@ for (int i = 0; i < 3; i++) { key.MakeNewKey(true); - pb.addUTXO(COutPoint(TxId(GetRandHash()), InsecureRand32()), - int64_t(InsecureRand32()) * COIN / 100, InsecureRand32(), - InsecureRandBool(), key); + BOOST_CHECK(pb.addUTXO(COutPoint(TxId(GetRandHash()), InsecureRand32()), + int64_t(InsecureRand32()) * COIN / 100, + InsecureRand32(), InsecureRandBool(), key)); } Proof p = pb.build(); @@ -351,7 +351,7 @@ const CKey &k) { // Generate a proof that match the UTXO. ProofBuilder pb(0, 0, pubkey); - pb.addUTXO(o, v, h, is_coinbase, k); + BOOST_CHECK(pb.addUTXO(o, v, h, is_coinbase, k)); Proof p = pb.build(); ProofValidationState state; @@ -411,7 +411,8 @@ // Dust thresold { ProofBuilder pb(0, 0, pubkey); - pb.addUTXO(pkh_outpoint, Amount::zero(), height, false, key); + BOOST_CHECK( + pb.addUTXO(pkh_outpoint, Amount::zero(), height, false, key)); Proof p = pb.build(); ProofValidationState state; @@ -421,8 +422,8 @@ { ProofBuilder pb(0, 0, pubkey); - pb.addUTXO(pkh_outpoint, PROOF_DUST_THRESHOLD - 1 * SATOSHI, height, - false, key); + BOOST_CHECK(pb.addUTXO(pkh_outpoint, PROOF_DUST_THRESHOLD - 1 * SATOSHI, + height, false, key)); Proof p = pb.build(); ProofValidationState state; @@ -433,7 +434,7 @@ // Duplicated input { ProofBuilder pb(0, 0, pubkey); - pb.addUTXO(pkh_outpoint, value, height, false, key); + BOOST_CHECK(pb.addUTXO(pkh_outpoint, value, height, false, key)); Proof p = TestProofBuilder::buildDuplicatedStakes(pb); ProofValidationState state; @@ -450,8 +451,8 @@ false); ProofBuilder pb(0, 0, pubkey); - pb.addUTXO(pkh_outpoint, value, height, false, key); - pb.addUTXO(other_pkh_outpoint, value, height, false, key); + BOOST_CHECK(pb.addUTXO(pkh_outpoint, value, height, false, key)); + BOOST_CHECK(pb.addUTXO(other_pkh_outpoint, value, height, false, key)); Proof p = TestProofBuilder::buildWithReversedOrderStakes(pb); ProofValidationState state; @@ -479,7 +480,7 @@ auto computeProofId = [&]() { ProofBuilder pb(0, 0, pubkey); for (const COutPoint &outpoint : outpoints) { - pb.addUTXO(outpoint, value, height, false, key); + BOOST_CHECK(pb.addUTXO(outpoint, value, height, false, key)); } Proof p = pb.build(); diff --git a/src/avalanche/test/util.cpp b/src/avalanche/test/util.cpp --- a/src/avalanche/test/util.cpp +++ b/src/avalanche/test/util.cpp @@ -11,6 +11,8 @@ #include