diff --git a/include/xrpl/beast/container/detail/aged_unordered_container.h b/include/xrpl/beast/container/detail/aged_unordered_container.h index 4c0882b04a..ea24141bfb 100644 --- a/include/xrpl/beast/container/detail/aged_unordered_container.h +++ b/include/xrpl/beast/container/detail/aged_unordered_container.h @@ -2319,7 +2319,6 @@ AgedUnorderedContainer return iterator(iter); } -#if 1 // Use insert() instead of insert_check() insert_commit() // set, map template < bool IsMulti, @@ -2349,43 +2348,6 @@ AgedUnorderedContainer deleteElement(p); return std::make_pair(iterator(result.first), false); } -#else // As original, use insert_check() / insert_commit () pair. -// set, map -template < - bool IsMulti, - bool IsMap, - class Key, - class T, - class Clock, - class Hash, - class KeyEqual, - class Allocator> -template -auto -AgedUnorderedContainer::emplace( - Args&&... args) -> std::pair - requires(!maybe_multi) -{ - maybe_rehash(1); - // VFALCO NOTE Its unfortunate that we need to - // construct element here - element* const p(new_element(std::forward(args)...)); - typename cont_type::insert_commit_data d; - auto const result(m_cont.insert_check( - extract(p->value), - std::cref(m_config.hashFunction()), - std::cref(m_config.keyValueEqual()), - d)); - if (result.second) - { - auto const iter(m_cont.insert_commit(*p, d)); - chronological.list.push_back(*p); - return std::make_pair(iterator(iter), true); - } - delete_element(p); - return std::make_pair(iterator(result.first), false); -} -#endif // 0 // multiset, multimap template < diff --git a/src/test/overlay/short_read_test.cpp b/src/test/overlay/short_read_test.cpp index f235008d89..d856231b8d 100644 --- a/src/test/overlay/short_read_test.cpp +++ b/src/test/overlay/short_read_test.cpp @@ -328,7 +328,6 @@ private: fail("handshake", ec); return; } -#if 1 boost::asio::async_read_until( stream, buf, @@ -339,9 +338,6 @@ private: error_code const& ec, std::size_t bytesTransferred) { self->onRead(ec, bytesTransferred); })); -#else - close(); -#endif } void @@ -533,7 +529,6 @@ private: } write(buf, "HELLO\n"); -#if 1 boost::asio::async_write( stream, buf.data(), @@ -543,11 +538,6 @@ private: error_code const& ec, std::size_t bytesTransferred) { self->onWrite(ec, bytesTransferred); })); -#else - stream_.async_shutdown(bind_executor( - strand_, - [self = shared_from_this()](error_code const& ec) { self->on_shutdown(ec); })); -#endif } void @@ -559,7 +549,6 @@ private: fail("write", ec); return; } -#if 1 boost::asio::async_read_until( stream, buf, @@ -570,11 +559,6 @@ private: error_code const& ec, std::size_t bytesTransferred) { self->onRead(ec, bytesTransferred); })); -#else - stream_.async_shutdown(bind_executor( - strand_, - [self = shared_from_this()](error_code const& ec) { self->on_shutdown(ec); })); -#endif } void diff --git a/src/test/shamap/FetchPack_test.cpp b/src/test/shamap/FetchPack_test.cpp deleted file mode 100644 index f2e7578ee2..0000000000 --- a/src/test/shamap/FetchPack_test.cpp +++ /dev/null @@ -1,153 +0,0 @@ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -namespace xrpl::tests { - -class FetchPack_test : public beast::unit_test::Suite -{ -public: - static constexpr auto kTableItems = 100; - static constexpr auto kTableItemsExtra = 20; - - using Map = hash_map; - using Table = SHAMap; - using Item = SHAMapItem; - - struct TestFilter : SHAMapSyncFilter - { - TestFilter(Map& map, beast::Journal journal) : map(map), journal(journal) - { - } - - void - gotNode( - bool fromFilter, - SHAMapHash const& nodeHash, - std::uint32_t ledgerSeq, - Blob&& nodeData, // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved) - SHAMapNodeType type) const override - { - } - - [[nodiscard]] std::optional - getNode(SHAMapHash const& nodeHash) const override - { - auto const it = map.find(nodeHash); - if (it == map.end()) - { - JLOG(journal.fatal()) << "Test filter missing node"; - return std::nullopt; - } - return it->second; - } - - Map& map; - beast::Journal journal; - }; - - static boost::intrusive_ptr - makeRandomItemMember(beast::xor_shift_engine& r) - { - Serializer s; - for (int d = 0; d < 3; ++d) - s.add32(xrpl::randInt(r)); - return makeShamapitem(s.getSHA512Half(), s.slice()); - } - - static void - addRandomItems(std::size_t n, Table& t, beast::xor_shift_engine& r) - { - for (std::size_t i = 0; i < n; ++i) - { - auto const result(t.addItem(SHAMapNodeType::TnAccountState, makeRandomItemMember(r))); - assert(result); - (void)result; - } - } - - void - onFetch(Map& map, SHAMapHash const& hash, Blob const& blob) - { - BEAST_EXPECT(sha512Half(makeSlice(blob)) == hash.asUInt256()); - map.emplace(hash, blob); - } - - void - run() override - { - testFetchPack(); - } - - // Exercises a fetch-pack round trip: build a SHAMap, serialize every node - // into a pack keyed by node hash, then rebuild the map in a fresh SHAMap by - // sourcing every node from the pack through a SHAMapSyncFilter and comparing - // the result. This covers the filter-based reconstruction path (fetchRoot + - // getMissingNodes with a SHAMapSyncFilter), complementing SHAMapSync_test, - // which drives the getNodeFat/addKnownNode path. - void - testFetchPack() - { - test::SuiteJournal journal("FetchPack_test", *this); - TestNodeFamily f(journal), f2(journal); - beast::xor_shift_engine r; - - // Build a source map. getHash() unshares the tree and computes every - // node hash; this must happen before serializing nodes below, otherwise - // inner nodes still carry stale cached hashes. - auto const source = std::make_shared(SHAMapType::FREE, f); - addRandomItems(kTableItems + kTableItemsExtra, *source, r); - source->setImmutable(); - auto const rootHash = source->getHash(); - - // Turn the source into a fetch pack: node hash -> serialized node. - Map map; - source->visitNodes([this, &map](SHAMapTreeNode& node) { - Serializer s; - node.serializeWithPrefix(s); - onFetch(map, node.getHash(), s.getData()); - return true; - }); - - // Rebuild the map in a fresh family, sourcing every node from the pack - // through the SHAMapSyncFilter. - auto const rebuilt = std::make_shared
(SHAMapType::FREE, rootHash.asUInt256(), f2); - TestFilter filter(map, journal); - rebuilt->setSynching(); - BEAST_EXPECT(rebuilt->fetchRoot(rootHash, &filter)); - - // Everything should be in the pack, so no nodes should be missing. - BEAST_EXPECT(rebuilt->getMissingNodes(2048, &filter).empty()); - rebuilt->clearSynching(); - - BEAST_EXPECT(rebuilt->deepCompare(*source)); - } -}; - -BEAST_DEFINE_TESTSUITE(FetchPack, shamap, xrpl); - -} // namespace xrpl::tests