Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timemarkovqtum committed Aug 20, 2024
1 parent c27e646 commit b308854
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
16 changes: 6 additions & 10 deletions src/test/data/script_tests.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/test/data/tx_valid.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@

["Valid CHECKSEQUENCEVERIFY even with negative tx version number"],
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x7c17aff532f22beb54069942f9bf567a66133eaf EQUAL"]],
"ffffffff01000100000000000000000000000000000000000000000000000000000000000000000000030251b2010000000100000000000000000000000000", "NONE"],
"ffffffff01000100000000000000000000000000000000000000000000000000000000000000000000030251b2010000000100001000000000000000000000", "NONE"],

["Valid P2WPKH (Private key of segwit tests is L5AQtV2HDm4xGsseLokK2VAT2EtYKcTm3c7HwqnJBFt9LdaQULsM)"],
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 1000]],
Expand Down
6 changes: 3 additions & 3 deletions src/test/disconnected_transactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ BOOST_AUTO_TEST_CASE(disconnectpool_memory_limits)
// transactions would realistically be in a block together, they just need distinct txids and
// uniform size for this test to work.
std::vector<CTransactionRef> block_vtx(m_coinbase_txns);
BOOST_CHECK_EQUAL(block_vtx.size(), 100);
BOOST_CHECK_EQUAL(block_vtx.size(), 2000);

// Roughly estimate sizes to sanity check that DisconnectedBlockTransactions::DynamicMemoryUsage
// is within an expected range.
Expand All @@ -25,7 +25,7 @@ BOOST_AUTO_TEST_CASE(disconnectpool_memory_limits)
std::unordered_map<uint256, CTransaction*, SaltedTxidHasher> temp_map;
temp_map.reserve(1);
const size_t MAP_1{memusage::DynamicUsage(temp_map)};
temp_map.reserve(100);
temp_map.reserve(2000);
const size_t MAP_100{memusage::DynamicUsage(temp_map)};

const size_t TX_USAGE{RecursiveDynamicUsage(block_vtx.front())};
Expand Down Expand Up @@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE(disconnectpool_memory_limits)
// Record usage so we can check size limiting in the next test.
size_t usage_full{0};
{
const size_t USAGE_100_OVERESTIMATE{MAP_100 + ENTRY_USAGE_ESTIMATE * 100};
const size_t USAGE_100_OVERESTIMATE{MAP_100 + ENTRY_USAGE_ESTIMATE * 2000};
DisconnectedBlockTransactions disconnectpool{USAGE_100_OVERESTIMATE};
auto evicted_txns{disconnectpool.AddTransactionsFromBlock(block_vtx)};
BOOST_CHECK_EQUAL(evicted_txns.size(), 0);
Expand Down
4 changes: 2 additions & 2 deletions src/test/net_peer_connection_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE(test_addnode_getaddednodeinfo_and_connection_detection)

// Connect a localhost peer.
{
ASSERT_DEBUG_LOG("Added connection to 127.0.0.1:8333 peer=1");
ASSERT_DEBUG_LOG("Added connection to 127.0.0.1:3888 peer=1");
AddPeer(id, nodes, *peerman, *connman, ConnectionType::MANUAL, /*onion_peer=*/false, /*address=*/"127.0.0.1");
BOOST_REQUIRE(nodes.back() != nullptr);
}
Expand All @@ -99,7 +99,7 @@ BOOST_AUTO_TEST_CASE(test_addnode_getaddednodeinfo_and_connection_detection)
// address that resolves to multiple IPs, including that of the connected peer.
// The connection attempt should consistently fail due to the check in ConnectNode().
for (int i = 0; i < 10; ++i) {
ASSERT_DEBUG_LOG("Not opening a connection to localhost, already connected to 127.0.0.1:8333");
ASSERT_DEBUG_LOG("Not opening a connection to localhost, already connected to 127.0.0.1:3888");
BOOST_CHECK(!connman->ConnectNodePublic(*peerman, "localhost", ConnectionType::MANUAL));
}

Expand Down

0 comments on commit b308854

Please sign in to comment.