From 6045b2a1fa2b7c354cabff9acf22ed777670cbcf Mon Sep 17 00:00:00 2001 From: JCW Date: Fri, 10 Apr 2026 15:10:48 +0100 Subject: [PATCH] Fix comments --- src/tests/libxrpl/helpers/IOU.h | 1 + src/tests/libxrpl/helpers/TestFamily.h | 2 + .../libxrpl/helpers/TestServiceRegistry.h | 33 ++++++------ src/tests/libxrpl/helpers/TxTest.cpp | 7 +-- src/tests/libxrpl/helpers/TxTest.h | 6 ++- src/tests/libxrpl/tx/AccountSet.cpp | 54 ++++++++++--------- 6 files changed, 58 insertions(+), 45 deletions(-) diff --git a/src/tests/libxrpl/helpers/IOU.h b/src/tests/libxrpl/helpers/IOU.h index 5413de81de..1e845f5ae6 100644 --- a/src/tests/libxrpl/helpers/IOU.h +++ b/src/tests/libxrpl/helpers/IOU.h @@ -11,6 +11,7 @@ #include #include #include +#include namespace xrpl::test { diff --git a/src/tests/libxrpl/helpers/TestFamily.h b/src/tests/libxrpl/helpers/TestFamily.h index 0538a4e158..98c5a379e4 100644 --- a/src/tests/libxrpl/helpers/TestFamily.h +++ b/src/tests/libxrpl/helpers/TestFamily.h @@ -5,6 +5,8 @@ #include #include +#include + namespace xrpl { namespace test { diff --git a/src/tests/libxrpl/helpers/TestServiceRegistry.h b/src/tests/libxrpl/helpers/TestServiceRegistry.h index 5fdf38c0f2..6cf09d0c2c 100644 --- a/src/tests/libxrpl/helpers/TestServiceRegistry.h +++ b/src/tests/libxrpl/helpers/TestServiceRegistry.h @@ -13,6 +13,7 @@ #include #include +#include #include namespace xrpl { @@ -101,7 +102,7 @@ public: } TimeKeeper& - timeKeeper() override + getTimeKeeper() override { throw std::logic_error("TestServiceRegistry::timeKeeper() not implemented"); } @@ -119,7 +120,7 @@ public: } CachedSLEs& - cachedSLEs() override + getCachedSLEs() override { return cachedSLEs_; } @@ -162,44 +163,44 @@ public: } ValidatorList& - validators() override + getValidators() override { throw std::logic_error("TestServiceRegistry::validators() not implemented"); } ValidatorSite& - validatorSites() override + getValidatorSites() override { throw std::logic_error("TestServiceRegistry::validatorSites() not implemented"); } ManifestCache& - validatorManifests() override + getValidatorManifests() override { throw std::logic_error("TestServiceRegistry::validatorManifests() not implemented"); } ManifestCache& - publisherManifests() override + getPublisherManifests() override { throw std::logic_error("TestServiceRegistry::publisherManifests() not implemented"); } // Network services Overlay& - overlay() override + getOverlay() override { throw std::logic_error("TestServiceRegistry::overlay() not implemented"); } Cluster& - cluster() override + getCluster() override { throw std::logic_error("TestServiceRegistry::cluster() not implemented"); } PeerReservationTable& - peerReservations() override + getPeerReservations() override { throw std::logic_error("TestServiceRegistry::peerReservations() not implemented"); } @@ -267,19 +268,19 @@ public: } PendingSaves& - pendingSaves() override + getPendingSaves() override { return pendingSaves_; } OpenLedger& - openLedger() override + getOpenLedger() override { throw std::logic_error("TestServiceRegistry::openLedger() not implemented"); } OpenLedger const& - openLedger() const override + getOpenLedger() const override { throw std::logic_error("TestServiceRegistry::openLedger() const not implemented"); } @@ -336,7 +337,7 @@ public: } beast::Journal - journal(std::string const& name) override + getJournal(std::string const& name) override { return logs_.journal(name); } @@ -348,13 +349,13 @@ public: } Logs& - logs() override + getLogs() override { return logs_; } std::optional const& - trapTxID() const override + getTrapTxID() const override { return trapTxID_; } @@ -367,7 +368,7 @@ public: // Temporary: Get the underlying Application Application& - app() override + getApp() override { throw std::logic_error( "TestServiceRegistry::app() not implemented - no Application available in tests"); diff --git a/src/tests/libxrpl/helpers/TxTest.cpp b/src/tests/libxrpl/helpers/TxTest.cpp index ef82b7e753..c611af462b 100644 --- a/src/tests/libxrpl/helpers/TxTest.cpp +++ b/src/tests/libxrpl/helpers/TxTest.cpp @@ -83,7 +83,8 @@ TxTest::getRules() const [[nodiscard]] TxResult TxTest::submit(std::shared_ptr stx) { - auto const result = apply(registry_, *openLedger_, *stx, tapNONE, registry_.journal("apply")); + auto const result = + apply(registry_, *openLedger_, *stx, tapNONE, registry_.getJournal("apply")); // Track successfully applied transactions for canonical reordering on close // We make a copy since the TransactionBase doesn't own the STTx @@ -180,7 +181,7 @@ TxTest::close() OpenView accum(&*newLedger); for (auto const& [key, tx] : txSet) { - auto result = apply(registry_, accum, *tx, tapNONE, registry_.journal("apply")); + auto result = apply(registry_, accum, *tx, tapNONE, registry_.getJournal("apply")); if (!result.applied) { throw std::runtime_error("TxTest::close: failed to apply transaction"); @@ -229,7 +230,7 @@ TxTest::getBalance(AccountID const& account, IOU const& iou) const auto const rippleState = ledger_entries::RippleState{sle}; auto balance = rippleState.getBalance(); - balance.setIssuer(iou.issue().account); + balance.get().account = iou.issue().account; if (account > iou.issue().account) balance.negate(); return balance; diff --git a/src/tests/libxrpl/helpers/TxTest.h b/src/tests/libxrpl/helpers/TxTest.h index 4b6294acc2..9560b0c674 100644 --- a/src/tests/libxrpl/helpers/TxTest.h +++ b/src/tests/libxrpl/helpers/TxTest.h @@ -18,7 +18,6 @@ #include #include -#include #include #include #include @@ -27,6 +26,9 @@ #include #include #include +#include +#include +#include #include namespace xrpl::test { @@ -260,7 +262,7 @@ public: * @param accountFlags Optional account flags to set. */ void - createAccount(Account const& account, XRPAmount xrp, uint32_t accountFlags = asfDefaultRipple); + createAccount(Account const& account, XRPAmount xrp, uint32_t accountFlags = 0); /** * @brief Get the account root object from the current open ledger. diff --git a/src/tests/libxrpl/tx/AccountSet.cpp b/src/tests/libxrpl/tx/AccountSet.cpp index b1fe55263f..9e9eb908a4 100644 --- a/src/tests/libxrpl/tx/AccountSet.cpp +++ b/src/tests/libxrpl/tx/AccountSet.cpp @@ -15,6 +15,13 @@ #include #include +#include +#include +#include +#include +#include +#include + namespace xrpl::test { TEST(AccountSet, NullAccountSet) @@ -22,7 +29,7 @@ TEST(AccountSet, NullAccountSet) TxTest env; Account const alice("alice"); - env.createAccount(alice, XRP(10), 0); + env.createAccount(alice, XRP(10)); auto& view = env.getOpenLedger(); @@ -39,13 +46,13 @@ TEST(AccountSet, MostFlags) Account const alice("alice"); TxTest env; - env.createAccount(alice, XRP(10000), 0); + env.createAccount(alice, XRP(10000)); // Give alice a regular key so she can legally set and clear // her asfDisableMaster flag. Account const alie{"alie", KeyType::secp256k1}; - env.createAccount(alie, XRP(10000), 0); + env.createAccount(alie, XRP(10000)); env.close(); EXPECT_EQ( @@ -145,7 +152,7 @@ TEST(AccountSet, SetAndResetAccountTxnID) TxTest env; Account const alice("alice"); - env.createAccount(alice, XRP(10000), 0); + env.createAccount(alice, XRP(10000)); std::uint32_t const orig_flags = env.getAccountRoot(alice).getFlags(); @@ -177,7 +184,7 @@ TEST(AccountSet, SetNoFreeze) Account const alice("alice"); Account const eric("eric"); - env.createAccount(alice, XRP(10000), 0); + env.createAccount(alice, XRP(10000)); env.close(); // Set eric as alice's regular key (eric doesn't need to be funded) @@ -219,7 +226,7 @@ TEST(AccountSet, Domain) TxTest env; Account const alice("alice"); - env.createAccount(alice, XRP(10000), 0); + env.createAccount(alice, XRP(10000)); env.close(); // The Domain field is represented as the hex string of the lowercase @@ -285,7 +292,7 @@ TEST(AccountSet, MessageKey) TxTest env; Account const alice("alice"); - env.createAccount(alice, XRP(10000), 0); + env.createAccount(alice, XRP(10000)); env.close(); // Generate a random ed25519 key pair for the message key @@ -325,7 +332,7 @@ TEST(AccountSet, WalletID) TxTest env; Account const alice("alice"); - env.createAccount(alice, XRP(10000), 0); + env.createAccount(alice, XRP(10000)); env.close(); std::string_view locator = "9633EC8AF54F16B5286DB1D7B519EF49EEFC050C0C8AC4384F1D88ACD1BFDF05"; @@ -355,7 +362,7 @@ TEST(AccountSet, EmailHash) TxTest env; Account const alice("alice"); - env.createAccount(alice, XRP(10000), 0); + env.createAccount(alice, XRP(10000)); env.close(); std::string_view mh = "5F31A79367DC3137FADA860C05742EE6"; @@ -403,7 +410,7 @@ TEST(AccountSet, TransferRate) TxTest env; Account const alice("alice"); - env.createAccount(alice, XRP(10000), 0); + env.createAccount(alice, XRP(10000)); env.close(); for (auto const& r : testData) @@ -435,7 +442,7 @@ TEST(AccountSet, BadInputs) TxTest env; Account const alice("alice"); - env.createAccount(alice, XRP(10000), 0); + env.createAccount(alice, XRP(10000)); env.close(); // Setting and clearing the same flag is invalid @@ -516,7 +523,7 @@ TEST(AccountSet, RequireAuthWithDir) Account const alice("alice"); Account const bob("bob"); - env.createAccount(alice, XRP(10000), 0); + env.createAccount(alice, XRP(10000)); env.close(); // alice should have an empty directory @@ -563,7 +570,7 @@ TEST(AccountSet, Ticket) TxTest env; Account const alice("alice"); - env.createAccount(alice, XRP(10000), 0); + env.createAccount(alice, XRP(10000)); env.close(); // Get alice's current sequence - the ticket will be created at seq + 1 @@ -616,7 +623,7 @@ TEST(AccountSet, BadSigningKey) TxTest env; Account const alice("alice"); - env.createAccount(alice, XRP(10000), 0); + env.createAccount(alice, XRP(10000)); env.close(); // Build a valid transaction first, then corrupt the signing key @@ -647,9 +654,9 @@ TEST(AccountSet, Gateway) { TxTest env; - env.createAccount(gw, XRP(10000)); - env.createAccount(alice, XRP(10000)); - env.createAccount(bob, XRP(10000)); + env.createAccount(gw, XRP(10000), asfDefaultRipple); + env.createAccount(alice, XRP(10000), asfDefaultRipple); + env.createAccount(bob, XRP(10000), asfDefaultRipple); env.close(); // Set up trust lines: alice and bob trust gw for USD @@ -700,12 +707,12 @@ TEST(AccountSet, Gateway) // Test out-of-bounds legacy transfer rates (4.0 and 4.294967295) // These require direct ledger modification since the transactor blocks them - for (double transferRate : {4.0, 4.294967295}) + for (std::uint32_t transferRate : {4000000000U, 4294967295U}) { TxTest env; - env.createAccount(gw, XRP(10000)); - env.createAccount(alice, XRP(10000)); - env.createAccount(bob, XRP(10000)); + env.createAccount(gw, XRP(10000), asfDefaultRipple); + env.createAccount(alice, XRP(10000), asfDefaultRipple); + env.createAccount(bob, XRP(10000), asfDefaultRipple); env.close(); // Set up trust lines @@ -734,13 +741,12 @@ TEST(AccountSet, Gateway) auto slePtr = view.read(keylet::account(gw.id())); ASSERT_NE(slePtr, nullptr); auto sleCopy = std::make_shared(*slePtr); - (*sleCopy)[sfTransferRate] = static_cast(transferRate * QUALITY_ONE); + (*sleCopy)[sfTransferRate] = transferRate; view.rawReplace(sleCopy); // Calculate the amount with the legacy transfer rate auto const amount = USD.amount(1); - auto const amountWithRate = - multiply(amount, Rate(static_cast(transferRate * QUALITY_ONE))); + auto const amountWithRate = multiply(amount, Rate(transferRate)); // Gateway pays alice 10 USD EXPECT_EQ(