diff --git a/src/test/app/Oracle_test.cpp b/src/test/app/Oracle_test.cpp index 22b933ef59c..c451f408b15 100644 --- a/src/test/app/Oracle_test.cpp +++ b/src/test/app/Oracle_test.cpp @@ -26,19 +26,6 @@ namespace test { struct Oracle_test : public beast::unit_test::suite { private: - static auto - ledgerEntryOracle( - jtx::Env& env, - AccountID const& account, - std::uint32_t const& sequence) - { - Json::Value jvParams; - jvParams[jss::oracle][jss::account] = to_string(account); - jvParams[jss::oracle][jss::oracle_sequence] = sequence; - return env.rpc( - "json", "ledger_entry", to_string(jvParams))[jss::result]; - } - void testInvalidSet() { @@ -403,7 +390,7 @@ struct Oracle_test : public beast::unit_test::suite } for (int i = 0; i < accounts.size(); ++i) { - auto const jv = ledgerEntryOracle(env, accounts[i], oracles[i]); + auto const jv = Oracle::ledgerEntry(env, accounts[i], oracles[i]); try { BEAST_EXPECT( diff --git a/src/test/jtx/Oracle.h b/src/test/jtx/Oracle.h index 9f83629be3e..05da90b9f73 100644 --- a/src/test/jtx/Oracle.h +++ b/src/test/jtx/Oracle.h @@ -33,6 +33,7 @@ using DataSeries = std::vector, std::optional>>; +// Typical defaults for Create struct CreateArg { std::optional owner = std::nullopt; @@ -49,6 +50,7 @@ struct CreateArg std::optional ter = std::nullopt; }; +// Typical defaults for Update struct UpdateArg { std::optional owner = std::nullopt; @@ -82,6 +84,7 @@ struct RemoveArg class Oracle { private: + // Global fee if not 0 static inline std::uint32_t fee = 0; Env& env_; AccountID owner_; @@ -134,8 +137,18 @@ class Oracle bool expectPrice(DataSeries const& pricess) const; + static Json::Value + ledgerEntry( + Env& env, + AccountID const& account, + std::uint32_t sequence, + std::optional const& index = std::nullopt); + Json::Value - ledgerEntry(std::optional const& index = std::nullopt) const; + ledgerEntry(std::optional const& index = std::nullopt) const + { + return Oracle::ledgerEntry(env_, owner_, sequence_, index); + } static void setFee(std::uint32_t f) diff --git a/src/test/jtx/impl/Oracle.cpp b/src/test/jtx/impl/Oracle.cpp index 5ac142d6899..12e4d6176dc 100644 --- a/src/test/jtx/impl/Oracle.cpp +++ b/src/test/jtx/impl/Oracle.cpp @@ -17,14 +17,12 @@ */ //============================================================================== -#include #include #include #include #include -#include #include namespace ripple { @@ -99,8 +97,8 @@ Oracle::expectPrice(DataSeries const& series) const { if (auto const sle = env_.le(keylet::oracle(owner_, sequence_))) { - auto const leSeries = sle->getFieldArray(sfPriceDataSeries); - if (leSeries.size() != series.size()) + auto const& leSeries = sle->getFieldArray(sfPriceDataSeries); + if (leSeries.size() == 0 || leSeries.size() != series.size()) return false; for (auto const& data : series) { @@ -234,11 +232,15 @@ Oracle::set(CreateArg const& arg) } Json::Value -Oracle::ledgerEntry(std::optional const& index) const +Oracle::ledgerEntry( + Env& env, + AccountID const& account, + std::uint32_t sequence, + std::optional const& index) { Json::Value jvParams; - jvParams[jss::oracle][jss::account] = to_string(owner_); - jvParams[jss::oracle][jss::oracle_sequence] = sequence_; + jvParams[jss::oracle][jss::account] = to_string(account); + jvParams[jss::oracle][jss::oracle_sequence] = sequence; if (index) { std::uint32_t i; @@ -247,7 +249,7 @@ Oracle::ledgerEntry(std::optional const& index) const else jvParams[jss::oracle][jss::ledger_index] = *index; } - return env_.rpc("json", "ledger_entry", to_string(jvParams))[jss::result]; + return env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result]; } } // namespace jtx