13#include <boost/test/unit_test.hpp>
31 mtx.vin[0].nSequence = id;
68 const auto it{std::ranges::find(
infos, tx->GetWitnessHash(), [](
const auto& info) { return info.tx->GetWitnessHash(); })};
73 const auto infos{
pb.GetBroadcastInfo()};
101 for (
const auto& info :
pb.GetBroadcastInfo()) {
102 BOOST_CHECK(std::ranges::none_of(info.peers, [](
const auto& peer) { return peer.received.has_value(); }));
118 const auto infos{
pb.GetBroadcastInfo()};
174 pb.NodeDisconnected(1);
223 const auto info{
pb.GetBroadcastInfo()};
243 const auto reset_tx_info{std::ranges::find(
reset_info, tx->GetWitnessHash(), [](
const auto& entry) { return entry.tx->GetWitnessHash(); })};
263 pb.NodeConfirmedReception(0);
275 const auto info{
pb.GetBroadcastInfo()};
277 BOOST_CHECK(info[0].tx->GetWitnessHash() == tx->GetWitnessHash());
289 std::vector<CTransactionRef>
txs;
291 for (
size_t i{0}; i <
num_cap; ++i) {
294 txs.push_back(std::move(tx));
299 for (
size_t i{0}; i <
num_over; ++i) {
306 const auto infos{
pb.GetBroadcastInfo()};
308 for (
const auto& info :
infos) {
312 for (
size_t i{0}; i <
num_cap; ++i) {
314 "tx index " << i <<
" should still be present");
A combination of a network address (CNetAddr) and a (TCP) port.
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
Store a list of transactions to be broadcast privately.
AddResult
Outcome of Add().
@ QueueFull
Rejected: the queue is already at MAX_TRANSACTIONS.
@ AlreadyPresent
The transaction was already present with send attempts remaining; no change.
@ Added
The transaction was newly added or reset after exhausting its send attempts.
static constexpr size_t MAX_TRANSACTIONS
Maximum number of transactions tracked simultaneously.
static constexpr size_t INITIAL_CONNECTION_COUNT
Number of connections to make for initial broadcast.
static constexpr auto INITIAL_STALE_DURATION
If a transaction is not sent to any peer for this duration, then we consider it stale / for rebroadca...
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
static const std::string addr1
static const std::string addr2
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
std::ostream & operator<<(std::ostream &os, PrivateBroadcast::AddResult r)
static CTransactionRef MakeDummyTx(uint32_t id, size_t num_witness)
BOOST_AUTO_TEST_CASE(basic)
A mutable version of CTransaction.
std::vector< std::vector< unsigned char > > stack
BOOST_CHECK_NE(OneL.ToString(), ArrayToString(ZeroArray, 32))
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.