mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-06 17:27:58 +00:00
@@ -17,12 +17,14 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "data/AmendmentCenter.hpp"
|
||||
#include "data/Types.hpp"
|
||||
#include "rpc/Errors.hpp"
|
||||
#include "rpc/JS.hpp"
|
||||
#include "rpc/RPCHelpers.hpp"
|
||||
#include "rpc/common/Types.hpp"
|
||||
#include "util/AsioContextTestFixture.hpp"
|
||||
#include "util/MockAmendmentCenter.hpp"
|
||||
#include "util/MockBackendTestFixture.hpp"
|
||||
#include "util/MockPrometheus.hpp"
|
||||
#include "util/NameGenerator.hpp"
|
||||
@@ -38,6 +40,7 @@
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/LedgerFormats.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STObject.h>
|
||||
#include <xrpl/protocol/UintTypes.h>
|
||||
@@ -63,6 +66,10 @@ constexpr auto kACCOUNT2 = "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun";
|
||||
constexpr auto kINDEX1 = "E6DBAFC99223B42257915A63DFC6B0C032D4070F9A574B255AD97466726FC321";
|
||||
constexpr auto kINDEX2 = "E6DBAFC99223B42257915A63DFC6B0C032D4070F9A574B255AD97466726FC322";
|
||||
constexpr auto kTXN_ID = "E6DBAFC99223B42257915A63DFC6B0C032D4070F9A574B255AD97466726FC321";
|
||||
constexpr auto kAMM_ACCOUNT = "rnW8FAPgpQgA6VoESnVrUVJHBdq9QAtRZs";
|
||||
constexpr auto kISSUER = "rK9DrarGKnVEo2nYp5MfVRXRYf5yRX3mwD";
|
||||
constexpr auto kLPTOKEN_CURRENCY = "037C35306B24AAB7FF90848206E003279AA47090";
|
||||
constexpr auto kAMM_ID = 54321;
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -77,6 +84,9 @@ class RPCHelpersTest : public util::prometheus::WithPrometheus, public MockBacke
|
||||
{
|
||||
SyncAsioContextTest::TearDown();
|
||||
}
|
||||
|
||||
protected:
|
||||
StrictMockAmendmentCenterSharedPtr mockAmendmentCenterPtr_;
|
||||
};
|
||||
|
||||
TEST_F(RPCHelpersTest, TraverseOwnedNodesMarkerInvalidIndexNotHex)
|
||||
@@ -547,6 +557,247 @@ TEST_F(RPCHelpersTest, ParseIssue)
|
||||
);
|
||||
}
|
||||
|
||||
TEST_F(RPCHelpersTest, AccountHoldsFixLPTAmendmentDisabled)
|
||||
{
|
||||
auto ammAccount = getAccountIdWithString(kAMM_ACCOUNT);
|
||||
auto account = getAccountIdWithString(kACCOUNT);
|
||||
|
||||
auto const lptRippleState = createRippleStateLedgerObject(
|
||||
kLPTOKEN_CURRENCY, kAMM_ACCOUNT, 100, kACCOUNT, 100, kAMM_ACCOUNT, 100, kTXN_ID, 3
|
||||
);
|
||||
auto const lptRippleStateKk = ripple::keylet::line(ammAccount, account, ripple::to_currency(kLPTOKEN_CURRENCY)).key;
|
||||
|
||||
// trustline fetched twice. once in accountHolds and once in isFrozen
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObject(lptRippleStateKk, testing::_, testing::_))
|
||||
.Times(2)
|
||||
.WillRepeatedly(Return(lptRippleState.getSerializer().peekData()));
|
||||
|
||||
auto const ammID = ripple::uint256{kAMM_ID};
|
||||
auto const ammAccountKk = ripple::keylet::account(ammAccount).key;
|
||||
auto const ammAccountRoot = createAccountRootObject(kAMM_ACCOUNT, 0, 2, 200, 2, kINDEX1, 2, 0, ammID);
|
||||
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObject(ammAccountKk, testing::_, testing::_))
|
||||
.WillOnce(Return(ammAccountRoot.getSerializer().peekData()));
|
||||
|
||||
EXPECT_CALL(*mockAmendmentCenterPtr_, isEnabled(testing::_, Amendments::fixFrozenLPTokenTransfer, testing::_))
|
||||
.WillOnce(Return(false));
|
||||
|
||||
boost::asio::spawn(ctx_, [&, this](boost::asio::yield_context yield) {
|
||||
auto ret = accountHolds(
|
||||
*backend_,
|
||||
*mockAmendmentCenterPtr_,
|
||||
0,
|
||||
account,
|
||||
ripple::to_currency(kLPTOKEN_CURRENCY),
|
||||
ammAccount,
|
||||
true,
|
||||
yield
|
||||
);
|
||||
EXPECT_EQ(ret.mantissa(), 1000000000000000);
|
||||
});
|
||||
ctx_.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCHelpersTest, AccountHoldsLPTokenNotAMMAccount)
|
||||
{
|
||||
auto account = getAccountIdWithString(kACCOUNT);
|
||||
auto account2 = getAccountIdWithString(kACCOUNT2);
|
||||
|
||||
auto const usdRippleState =
|
||||
createRippleStateLedgerObject("USD", kACCOUNT2, 100, kACCOUNT, 100, kACCOUNT2, 100, kTXN_ID, 3);
|
||||
auto const usdRippleStateKk = ripple::keylet::line(account2, account, ripple::to_currency("USD")).key;
|
||||
|
||||
// trustline fetched twice. once in accountHolds and once in isFrozen
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObject(usdRippleStateKk, testing::_, testing::_))
|
||||
.Times(2)
|
||||
.WillRepeatedly(Return(usdRippleState.getSerializer().peekData()));
|
||||
|
||||
EXPECT_CALL(*mockAmendmentCenterPtr_, isEnabled(testing::_, Amendments::fixFrozenLPTokenTransfer, testing::_))
|
||||
.WillOnce(Return(true));
|
||||
|
||||
auto const account2Kk = ripple::keylet::account(account2).key;
|
||||
auto const account2Root = createAccountRootObject(kACCOUNT2, 0, 2, 200, 2, kINDEX1, 2, 0);
|
||||
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObject(account2Kk, testing::_, testing::_))
|
||||
.Times(2)
|
||||
.WillRepeatedly(Return(account2Root.getSerializer().peekData()));
|
||||
|
||||
boost::asio::spawn(ctx_, [&, this](boost::asio::yield_context yield) {
|
||||
auto ret = accountHolds(
|
||||
*backend_, *mockAmendmentCenterPtr_, 0, account, ripple::to_currency("USD"), account2, true, yield
|
||||
);
|
||||
EXPECT_EQ(ret.mantissa(), 1000000000000000);
|
||||
});
|
||||
ctx_.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCHelpersTest, AccountHoldsLPTokenAsset1Frozen)
|
||||
{
|
||||
auto ammAccount = getAccountIdWithString(kAMM_ACCOUNT);
|
||||
auto account = getAccountIdWithString(kACCOUNT);
|
||||
auto issuer = getAccountIdWithString(kISSUER);
|
||||
|
||||
auto const lptRippleState = createRippleStateLedgerObject(
|
||||
kLPTOKEN_CURRENCY, kAMM_ACCOUNT, 100, kACCOUNT, 100, kAMM_ACCOUNT, 100, kTXN_ID, 3
|
||||
);
|
||||
auto const lptRippleStateKk = ripple::keylet::line(ammAccount, account, ripple::to_currency(kLPTOKEN_CURRENCY)).key;
|
||||
|
||||
// trustline fetched twice. once in accountHolds and once in isFrozen
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObject(lptRippleStateKk, testing::_, testing::_))
|
||||
.Times(2)
|
||||
.WillRepeatedly(Return(lptRippleState.getSerializer().peekData()));
|
||||
|
||||
EXPECT_CALL(*mockAmendmentCenterPtr_, isEnabled(testing::_, Amendments::fixFrozenLPTokenTransfer, testing::_))
|
||||
.WillOnce(Return(true));
|
||||
|
||||
auto const ammID = ripple::uint256{kAMM_ID};
|
||||
auto const ammAccountKk = ripple::keylet::account(ammAccount).key;
|
||||
auto const ammAccountRoot = createAccountRootObject(kAMM_ACCOUNT, 0, 2, 200, 2, kINDEX1, 2, 0, ammID);
|
||||
|
||||
// accountroot fetched twice, once in isFrozen, once in accountHolds
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObject(ammAccountKk, testing::_, testing::_))
|
||||
.Times(2)
|
||||
.WillRepeatedly(Return(ammAccountRoot.getSerializer().peekData()));
|
||||
|
||||
auto const amm = createAmmObject(kAMM_ACCOUNT, "USD", kISSUER, "XRP", ripple::toBase58(ripple::xrpAccount()));
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObject(ripple::keylet::amm(ammID).key, testing::_, testing::_))
|
||||
.Times(1)
|
||||
.WillOnce(Return(amm.getSerializer().peekData()));
|
||||
|
||||
auto const issuerKk = ripple::keylet::account(issuer).key;
|
||||
auto const issuerAccountRoot = createAccountRootObject(kISSUER, ripple::lsfGlobalFreeze, 2, 200, 2, kINDEX1, 2, 0);
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObject(issuerKk, testing::_, testing::_))
|
||||
.WillOnce(Return(issuerAccountRoot.getSerializer().peekData()));
|
||||
|
||||
boost::asio::spawn(ctx_, [&, this](boost::asio::yield_context yield) {
|
||||
auto ret = accountHolds(
|
||||
*backend_,
|
||||
*mockAmendmentCenterPtr_,
|
||||
0,
|
||||
account,
|
||||
ripple::to_currency(kLPTOKEN_CURRENCY),
|
||||
ammAccount,
|
||||
true,
|
||||
yield
|
||||
);
|
||||
EXPECT_EQ(ret.mantissa(), 0);
|
||||
});
|
||||
ctx_.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCHelpersTest, AccountHoldsLPTokenAsset2Frozen)
|
||||
{
|
||||
auto ammAccount = getAccountIdWithString(kAMM_ACCOUNT);
|
||||
auto account = getAccountIdWithString(kACCOUNT);
|
||||
auto issuer = getAccountIdWithString(kISSUER);
|
||||
|
||||
auto const lptRippleState = createRippleStateLedgerObject(
|
||||
kLPTOKEN_CURRENCY, kAMM_ACCOUNT, 100, kACCOUNT, 100, kAMM_ACCOUNT, 100, kTXN_ID, 3
|
||||
);
|
||||
auto const lptRippleStateKk = ripple::keylet::line(ammAccount, account, ripple::to_currency(kLPTOKEN_CURRENCY)).key;
|
||||
|
||||
// trustline fetched twice. once in accountHolds and once in isFrozen
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObject(lptRippleStateKk, testing::_, testing::_)).Times(2);
|
||||
ON_CALL(*backend_, doFetchLedgerObject(lptRippleStateKk, testing::_, testing::_))
|
||||
.WillByDefault(testing::Return(lptRippleState.getSerializer().peekData()));
|
||||
|
||||
EXPECT_CALL(*mockAmendmentCenterPtr_, isEnabled(testing::_, Amendments::fixFrozenLPTokenTransfer, testing::_))
|
||||
.WillOnce(testing::Return(true));
|
||||
|
||||
auto const ammID = ripple::uint256{kAMM_ID};
|
||||
auto const ammAccountKk = ripple::keylet::account(ammAccount).key;
|
||||
auto const ammAccountRoot = createAccountRootObject(kAMM_ACCOUNT, 0, 2, 200, 2, kINDEX1, 2, 0, ammID);
|
||||
|
||||
// accountroot fetched twice, once in isFrozen, once in accountHolds
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObject(ammAccountKk, testing::_, testing::_))
|
||||
.Times(2)
|
||||
.WillRepeatedly(Return(ammAccountRoot.getSerializer().peekData()));
|
||||
|
||||
auto const amm = createAmmObject(kAMM_ACCOUNT, "XRP", ripple::toBase58(ripple::xrpAccount()), "USD", kISSUER);
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObject(ripple::keylet::amm(ammID).key, testing::_, testing::_))
|
||||
.WillOnce(Return(amm.getSerializer().peekData()));
|
||||
|
||||
auto const issuerKk = ripple::keylet::account(issuer).key;
|
||||
auto const issuerAccountRoot = createAccountRootObject(kISSUER, ripple::lsfGlobalFreeze, 2, 200, 2, kINDEX1, 2, 0);
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObject(issuerKk, testing::_, testing::_))
|
||||
.WillOnce(Return(issuerAccountRoot.getSerializer().peekData()));
|
||||
|
||||
boost::asio::spawn(ctx_, [&, this](boost::asio::yield_context yield) {
|
||||
auto ret = accountHolds(
|
||||
*backend_,
|
||||
*mockAmendmentCenterPtr_,
|
||||
0,
|
||||
account,
|
||||
ripple::to_currency(kLPTOKEN_CURRENCY),
|
||||
ammAccount,
|
||||
true,
|
||||
yield
|
||||
);
|
||||
EXPECT_EQ(ret.mantissa(), 0);
|
||||
});
|
||||
ctx_.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCHelpersTest, AccountHoldsLPTokenUnfrozen)
|
||||
{
|
||||
auto ammAccount = getAccountIdWithString(kAMM_ACCOUNT);
|
||||
auto account = getAccountIdWithString(kACCOUNT);
|
||||
auto issuer = getAccountIdWithString(kISSUER);
|
||||
|
||||
auto const lptRippleState = createRippleStateLedgerObject(
|
||||
kLPTOKEN_CURRENCY, kAMM_ACCOUNT, 100, kACCOUNT, 100, kAMM_ACCOUNT, 100, kTXN_ID, 3
|
||||
);
|
||||
auto const lptRippleStateKk = ripple::keylet::line(ammAccount, account, ripple::to_currency(kLPTOKEN_CURRENCY)).key;
|
||||
|
||||
// trustline fetched twice. once in accountHolds and once in isFrozen
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObject(lptRippleStateKk, testing::_, testing::_))
|
||||
.Times(2)
|
||||
.WillRepeatedly(Return(lptRippleState.getSerializer().peekData()));
|
||||
|
||||
EXPECT_CALL(*mockAmendmentCenterPtr_, isEnabled(testing::_, Amendments::fixFrozenLPTokenTransfer, testing::_))
|
||||
.WillOnce(Return(true));
|
||||
|
||||
auto const ammID = ripple::uint256{kAMM_ID};
|
||||
auto const ammAccountKk = ripple::keylet::account(ammAccount).key;
|
||||
auto const ammAccountRoot = createAccountRootObject(kAMM_ACCOUNT, 0, 2, 200, 2, kINDEX1, 2, 0, ammID);
|
||||
|
||||
// accountroot fetched twice, once in isFrozen, once in accountHolds
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObject(ammAccountKk, testing::_, testing::_))
|
||||
.Times(2)
|
||||
.WillRepeatedly(Return(ammAccountRoot.getSerializer().peekData()));
|
||||
|
||||
auto const amm = createAmmObject(kAMM_ACCOUNT, "XRP", ripple::toBase58(ripple::xrpAccount()), "USD", kISSUER);
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObject(ripple::keylet::amm(ammID).key, testing::_, testing::_))
|
||||
.WillOnce(Return(amm.getSerializer().peekData()));
|
||||
|
||||
auto const issuerKk = ripple::keylet::account(issuer).key;
|
||||
auto const issuerAccountRoot = createAccountRootObject(kISSUER, 0, 2, 200, 2, kINDEX1, 2, 0);
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObject(issuerKk, testing::_, testing::_))
|
||||
.WillOnce(Return(issuerAccountRoot.getSerializer().peekData()));
|
||||
|
||||
auto const usdRippleState =
|
||||
createRippleStateLedgerObject("USD", kISSUER, 100, kACCOUNT, 100, kISSUER, 100, kTXN_ID, 3);
|
||||
auto const usdRippleStateKk = ripple::keylet::line(issuer, account, ripple::to_currency("USD")).key;
|
||||
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObject(usdRippleStateKk, testing::_, testing::_))
|
||||
.WillOnce(Return(usdRippleState.getSerializer().peekData()));
|
||||
|
||||
boost::asio::spawn(ctx_, [&, this](boost::asio::yield_context yield) {
|
||||
auto ret = accountHolds(
|
||||
*backend_,
|
||||
*mockAmendmentCenterPtr_,
|
||||
0,
|
||||
account,
|
||||
ripple::to_currency(kLPTOKEN_CURRENCY),
|
||||
ammAccount,
|
||||
true,
|
||||
yield
|
||||
);
|
||||
EXPECT_EQ(ret.mantissa(), 1000000000000000);
|
||||
});
|
||||
ctx_.run();
|
||||
}
|
||||
|
||||
struct IsAdminCmdParamTestCaseBundle {
|
||||
std::string testName;
|
||||
std::string method;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "rpc/common/Types.hpp"
|
||||
#include "rpc/handlers/AMMInfo.hpp"
|
||||
#include "util/HandlerBaseTestFixture.hpp"
|
||||
#include "util/MockAmendmentCenter.hpp"
|
||||
#include "util/NameGenerator.hpp"
|
||||
#include "util/TestObject.hpp"
|
||||
|
||||
@@ -67,6 +68,9 @@ struct RPCAMMInfoHandlerTest : HandlerBaseTest {
|
||||
{
|
||||
backend_->setRange(10, 30);
|
||||
}
|
||||
|
||||
protected:
|
||||
StrictMockAmendmentCenterSharedPtr mockAmendmentCenterPtr_;
|
||||
};
|
||||
|
||||
struct AMMInfoParamTestCaseBundle {
|
||||
@@ -150,7 +154,7 @@ TEST_P(AMMInfoParameterTest, InvalidParams)
|
||||
{
|
||||
auto const testBundle = GetParam();
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
@@ -183,7 +187,7 @@ TEST_F(RPCAMMInfoHandlerTest, AccountNotFound)
|
||||
kNOTFOUND_ACCOUNT
|
||||
));
|
||||
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(kINPUT, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
@@ -207,7 +211,7 @@ TEST_F(RPCAMMInfoHandlerTest, AMMAccountNotExist)
|
||||
kWRONG_AMM_ACCOUNT
|
||||
));
|
||||
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(kINPUT, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
@@ -230,7 +234,7 @@ TEST_F(RPCAMMInfoHandlerTest, AMMAccountNotInDBIsMalformed)
|
||||
kAMM_ACCOUNT
|
||||
));
|
||||
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(kINPUT, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
@@ -256,7 +260,7 @@ TEST_F(RPCAMMInfoHandlerTest, AMMAccountNotFoundMissingAmmField)
|
||||
kAMM_ACCOUNT
|
||||
));
|
||||
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(kINPUT, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
@@ -291,7 +295,7 @@ TEST_F(RPCAMMInfoHandlerTest, AMMAccountAmmBlobNotFound)
|
||||
kAMM_ACCOUNT
|
||||
));
|
||||
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(kINPUT, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
@@ -330,7 +334,7 @@ TEST_F(RPCAMMInfoHandlerTest, AMMAccountAccBlobNotFound)
|
||||
kAMM_ACCOUNT
|
||||
));
|
||||
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(kINPUT, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
@@ -375,7 +379,7 @@ TEST_F(RPCAMMInfoHandlerTest, HappyPathMinimalFirstXRPNoTrustline)
|
||||
kAMM_ACCOUNT
|
||||
));
|
||||
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(kINPUT, Context{yield});
|
||||
auto expectedResult = json::parse(fmt::format(
|
||||
@@ -457,7 +461,7 @@ TEST_F(RPCAMMInfoHandlerTest, HappyPathWithAccount)
|
||||
kAMM_ACCOUNT2
|
||||
));
|
||||
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(kINPUT, Context{yield});
|
||||
auto const expectedResult = json::parse(fmt::format(
|
||||
@@ -529,7 +533,7 @@ TEST_F(RPCAMMInfoHandlerTest, HappyPathMinimalSecondXRPNoTrustline)
|
||||
kAMM_ACCOUNT
|
||||
));
|
||||
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(kINPUT, Context{yield});
|
||||
auto const expectedResult = json::parse(fmt::format(
|
||||
@@ -599,7 +603,7 @@ TEST_F(RPCAMMInfoHandlerTest, HappyPathNonXRPNoTrustlines)
|
||||
kAMM_ACCOUNT
|
||||
));
|
||||
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(kINPUT, Context{yield});
|
||||
auto const expectedResult = json::parse(fmt::format(
|
||||
@@ -688,7 +692,7 @@ TEST_F(RPCAMMInfoHandlerTest, HappyPathFrozen)
|
||||
kAMM_ACCOUNT
|
||||
));
|
||||
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(kINPUT, Context{yield});
|
||||
auto const expectedResult = json::parse(fmt::format(
|
||||
@@ -778,7 +782,7 @@ TEST_F(RPCAMMInfoHandlerTest, HappyPathFrozenIssuer)
|
||||
kAMM_ACCOUNT
|
||||
));
|
||||
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(kINPUT, Context{yield});
|
||||
auto const expectedResult = json::parse(fmt::format(
|
||||
@@ -860,7 +864,7 @@ TEST_F(RPCAMMInfoHandlerTest, HappyPathWithTrustline)
|
||||
kAMM_ACCOUNT
|
||||
));
|
||||
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(kINPUT, Context{yield});
|
||||
auto expectedResult = json::parse(fmt::format(
|
||||
@@ -937,7 +941,7 @@ TEST_F(RPCAMMInfoHandlerTest, HappyPathWithVoteSlots)
|
||||
kAMM_ACCOUNT
|
||||
));
|
||||
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(kINPUT, Context{yield});
|
||||
auto expectedResult = json::parse(fmt::format(
|
||||
@@ -1030,7 +1034,7 @@ TEST_F(RPCAMMInfoHandlerTest, HappyPathWithAuctionSlot)
|
||||
kAMM_ACCOUNT
|
||||
));
|
||||
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(kINPUT, Context{yield});
|
||||
auto expectedResult = json::parse(fmt::format(
|
||||
@@ -1126,7 +1130,7 @@ TEST_F(RPCAMMInfoHandlerTest, HappyPathWithAssetsMatchingInputOrder)
|
||||
kAMM_ACCOUNT2
|
||||
));
|
||||
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(kINPUT, Context{yield});
|
||||
auto expectedResult = json::parse(fmt::format(
|
||||
@@ -1236,7 +1240,7 @@ TEST_F(RPCAMMInfoHandlerTest, HappyPathWithAssetsPreservesInputOrder)
|
||||
kAMM_ACCOUNT2
|
||||
));
|
||||
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_}};
|
||||
auto const handler = AnyHandler{AMMInfoHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(kINPUT, Context{yield});
|
||||
auto expectedResult = json::parse(fmt::format(
|
||||
|
||||
@@ -136,10 +136,12 @@ private:
|
||||
HandlerType
|
||||
initHandler()
|
||||
{
|
||||
if constexpr (std::is_same_v<HandlerType, AccountInfoHandler> || std::is_same_v<HandlerType, FeatureHandler>) {
|
||||
if constexpr (std::is_same_v<HandlerType, AccountInfoHandler> || std::is_same_v<HandlerType, AMMInfoHandler> ||
|
||||
std::is_same_v<HandlerType, LedgerHandler> || std::is_same_v<HandlerType, BookOffersHandler> ||
|
||||
std::is_same_v<HandlerType, FeatureHandler>) {
|
||||
return HandlerType{this->backend_, this->mockAmendmentCenterPtr_};
|
||||
} else if constexpr (std::is_same_v<HandlerType, SubscribeHandler>) {
|
||||
return HandlerType{this->backend_, this->mockSubscriptionManagerPtr_};
|
||||
return HandlerType{this->backend_, this->mockAmendmentCenterPtr_, this->mockSubscriptionManagerPtr_};
|
||||
} else if constexpr (std::is_same_v<HandlerType, TestServerInfoHandler>) {
|
||||
return HandlerType{
|
||||
this->backend_,
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "data/AmendmentCenter.hpp"
|
||||
#include "data/Types.hpp"
|
||||
#include "rpc/Errors.hpp"
|
||||
#include "rpc/RPCHelpers.hpp"
|
||||
@@ -24,6 +25,7 @@
|
||||
#include "rpc/common/Types.hpp"
|
||||
#include "rpc/handlers/BookOffers.hpp"
|
||||
#include "util/HandlerBaseTestFixture.hpp"
|
||||
#include "util/MockAmendmentCenter.hpp"
|
||||
#include "util/NameGenerator.hpp"
|
||||
#include "util/TestObject.hpp"
|
||||
|
||||
@@ -86,6 +88,9 @@ struct RPCBookOffersHandlerTest : HandlerBaseTest {
|
||||
{
|
||||
backend_->setRange(10, 300);
|
||||
}
|
||||
|
||||
protected:
|
||||
StrictMockAmendmentCenterSharedPtr mockAmendmentCenterPtr_;
|
||||
};
|
||||
|
||||
struct RPCBookOffersParameterTest : RPCBookOffersHandlerTest, WithParamInterface<ParameterTestBundle> {};
|
||||
@@ -93,7 +98,7 @@ struct RPCBookOffersParameterTest : RPCBookOffersHandlerTest, WithParamInterface
|
||||
TEST_P(RPCBookOffersParameterTest, CheckError)
|
||||
{
|
||||
auto bundle = GetParam();
|
||||
auto const handler = AnyHandler{BookOffersHandler{backend_}};
|
||||
auto const handler = AnyHandler{BookOffersHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](boost::asio::yield_context yield) {
|
||||
auto const output = handler.process(json::parse(bundle.testJson), Context{.yield = yield});
|
||||
ASSERT_FALSE(output);
|
||||
@@ -511,6 +516,7 @@ struct BookOffersNormalTestBundle {
|
||||
uint32_t ledgerObjectCalls;
|
||||
std::vector<ripple::STObject> mockedOffers;
|
||||
std::string expectedJson;
|
||||
uint32_t amendmentIsEnabledCalls = 0;
|
||||
};
|
||||
|
||||
struct RPCBookOffersNormalPathTest : public RPCBookOffersHandlerTest,
|
||||
@@ -526,6 +532,11 @@ TEST_P(RPCBookOffersNormalPathTest, CheckOutput)
|
||||
auto const ledgerHeader = createLedgerHeader(kLEDGER_HASH, seq);
|
||||
ON_CALL(*backend_, fetchLedgerBySequence(seq, _)).WillByDefault(Return(ledgerHeader));
|
||||
|
||||
EXPECT_CALL(*mockAmendmentCenterPtr_, isEnabled(_, Amendments::fixFrozenLPTokenTransfer, _))
|
||||
.Times(bundle.amendmentIsEnabledCalls);
|
||||
ON_CALL(*mockAmendmentCenterPtr_, isEnabled(_, Amendments::fixFrozenLPTokenTransfer, _))
|
||||
.WillByDefault(Return(false));
|
||||
|
||||
// return valid book dir
|
||||
EXPECT_CALL(*backend_, doFetchSuccessorKey).Times(bundle.mockedSuccessors.size());
|
||||
for (auto const& [key, value] : bundle.mockedSuccessors) {
|
||||
@@ -548,7 +559,7 @@ TEST_P(RPCBookOffersNormalPathTest, CheckOutput)
|
||||
ON_CALL(*backend_, doFetchLedgerObjects).WillByDefault(Return(bbs));
|
||||
EXPECT_CALL(*backend_, doFetchLedgerObjects).Times(1);
|
||||
|
||||
auto const handler = AnyHandler{BookOffersHandler{backend_}};
|
||||
auto const handler = AnyHandler{BookOffersHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](boost::asio::yield_context yield) {
|
||||
auto const output = handler.process(json::parse(bundle.inputJson), Context{.yield = yield});
|
||||
ASSERT_TRUE(output);
|
||||
@@ -963,7 +974,8 @@ generateNormalPathBookOffersTestBundles()
|
||||
kPAYS20_XRP_GETS10_USD_BOOK_DIR,
|
||||
8,
|
||||
2
|
||||
)
|
||||
),
|
||||
.amendmentIsEnabledCalls = 1,
|
||||
},
|
||||
BookOffersNormalTestBundle{
|
||||
.testName = "PaysXRPGetsUSDWithMultipleOffers",
|
||||
@@ -1059,7 +1071,8 @@ generateNormalPathBookOffersTestBundles()
|
||||
kACCOUNT2,
|
||||
kPAYS20_XRP_GETS10_USD_BOOK_DIR,
|
||||
2
|
||||
)
|
||||
),
|
||||
.amendmentIsEnabledCalls = 1,
|
||||
},
|
||||
BookOffersNormalTestBundle{
|
||||
.testName = "PaysXRPGetsUSDSellingOwnCurrency",
|
||||
@@ -1216,7 +1229,7 @@ TEST_F(RPCBookOffersHandlerTest, LedgerNonExistViaIntSequence)
|
||||
}})",
|
||||
kACCOUNT
|
||||
));
|
||||
auto const handler = AnyHandler{BookOffersHandler{backend_}};
|
||||
auto const handler = AnyHandler{BookOffersHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](boost::asio::yield_context yield) {
|
||||
auto const output = handler.process(kINPUT, Context{.yield = yield});
|
||||
ASSERT_FALSE(output);
|
||||
@@ -1247,7 +1260,7 @@ TEST_F(RPCBookOffersHandlerTest, LedgerNonExistViaSequence)
|
||||
}})",
|
||||
kACCOUNT
|
||||
));
|
||||
auto const handler = AnyHandler{BookOffersHandler{backend_}};
|
||||
auto const handler = AnyHandler{BookOffersHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](boost::asio::yield_context yield) {
|
||||
auto const output = handler.process(kINPUT, Context{.yield = yield});
|
||||
ASSERT_FALSE(output);
|
||||
@@ -1280,7 +1293,7 @@ TEST_F(RPCBookOffersHandlerTest, LedgerNonExistViaHash)
|
||||
kLEDGER_HASH,
|
||||
kACCOUNT
|
||||
));
|
||||
auto const handler = AnyHandler{BookOffersHandler{backend_}};
|
||||
auto const handler = AnyHandler{BookOffersHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](boost::asio::yield_context yield) {
|
||||
auto const output = handler.process(kINPUT, Context{.yield = yield});
|
||||
ASSERT_FALSE(output);
|
||||
@@ -1355,7 +1368,7 @@ TEST_F(RPCBookOffersHandlerTest, Limit)
|
||||
}})",
|
||||
kACCOUNT
|
||||
));
|
||||
auto const handler = AnyHandler{BookOffersHandler{backend_}};
|
||||
auto const handler = AnyHandler{BookOffersHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](boost::asio::yield_context yield) {
|
||||
auto const output = handler.process(kINPUT, Context{.yield = yield});
|
||||
ASSERT_TRUE(output);
|
||||
@@ -1429,7 +1442,7 @@ TEST_F(RPCBookOffersHandlerTest, LimitMoreThanMax)
|
||||
kACCOUNT,
|
||||
BookOffersHandler::kLIMIT_MAX + 1
|
||||
));
|
||||
auto const handler = AnyHandler{BookOffersHandler{backend_}};
|
||||
auto const handler = AnyHandler{BookOffersHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
runSpawn([&](boost::asio::yield_context yield) {
|
||||
auto const output = handler.process(kINPUT, Context{.yield = yield});
|
||||
ASSERT_TRUE(output);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "rpc/common/Types.hpp"
|
||||
#include "rpc/handlers/Ledger.hpp"
|
||||
#include "util/HandlerBaseTestFixture.hpp"
|
||||
#include "util/MockAmendmentCenter.hpp"
|
||||
#include "util/NameGenerator.hpp"
|
||||
#include "util/TestObject.hpp"
|
||||
|
||||
@@ -68,6 +69,9 @@ struct RPCLedgerHandlerTest : HandlerBaseTest {
|
||||
{
|
||||
backend_->setRange(kRANGE_MIN, kRANGE_MAX);
|
||||
}
|
||||
|
||||
protected:
|
||||
StrictMockAmendmentCenterSharedPtr mockAmendmentCenterPtr_;
|
||||
};
|
||||
|
||||
struct LedgerParamTestCaseBundle {
|
||||
@@ -182,7 +186,7 @@ TEST_P(LedgerParameterTest, InvalidParams)
|
||||
{
|
||||
auto const testBundle = GetParam();
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
@@ -198,7 +202,7 @@ TEST_F(RPCLedgerHandlerTest, LedgerNotExistViaIntSequence)
|
||||
ON_CALL(*backend_, fetchLedgerBySequence(kRANGE_MAX, _)).WillByDefault(Return(std::nullopt));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(fmt::format(
|
||||
R"({{
|
||||
"ledger_index": {}
|
||||
@@ -219,7 +223,7 @@ TEST_F(RPCLedgerHandlerTest, LedgerNotExistViaStringSequence)
|
||||
ON_CALL(*backend_, fetchLedgerBySequence(kRANGE_MAX, _)).WillByDefault(Return(std::nullopt));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(fmt::format(
|
||||
R"({{
|
||||
"ledger_index": "{}"
|
||||
@@ -240,7 +244,7 @@ TEST_F(RPCLedgerHandlerTest, LedgerNotExistViaHash)
|
||||
ON_CALL(*backend_, fetchLedgerByHash(ripple::uint256{kLEDGER_HASH}, _)).WillByDefault(Return(std::nullopt));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(fmt::format(
|
||||
R"({{
|
||||
"ledger_hash": "{}"
|
||||
@@ -283,7 +287,7 @@ TEST_F(RPCLedgerHandlerTest, Default)
|
||||
ON_CALL(*backend_, fetchLedgerBySequence(kRANGE_MAX, _)).WillByDefault(Return(ledgerHeader));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse("{}");
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
@@ -300,7 +304,7 @@ TEST_F(RPCLedgerHandlerTest, ConditionallyNotSupportedFieldsDefaultValue)
|
||||
EXPECT_CALL(*backend_, fetchLedgerBySequence(kRANGE_MAX, _)).WillRepeatedly(Return(ledgerHeader));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(
|
||||
R"({
|
||||
"full": false,
|
||||
@@ -320,7 +324,7 @@ TEST_F(RPCLedgerHandlerTest, QueryViaLedgerIndex)
|
||||
ON_CALL(*backend_, fetchLedgerBySequence(15, _)).WillByDefault(Return(ledgerHeader));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(R"({"ledger_index": 15})");
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
@@ -335,7 +339,7 @@ TEST_F(RPCLedgerHandlerTest, QueryViaLedgerHash)
|
||||
ON_CALL(*backend_, fetchLedgerByHash(ripple::uint256{kINDEX1}, _)).WillByDefault(Return(ledgerHeader));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(fmt::format(R"({{"ledger_hash": "{}" }})", kINDEX1));
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
@@ -361,7 +365,7 @@ TEST_F(RPCLedgerHandlerTest, BinaryTrue)
|
||||
ON_CALL(*backend_, fetchLedgerBySequence(kRANGE_MAX, _)).WillByDefault(Return(ledgerHeader));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(
|
||||
R"({
|
||||
"binary": true
|
||||
@@ -409,7 +413,7 @@ TEST_F(RPCLedgerHandlerTest, TransactionsExpandBinary)
|
||||
ON_CALL(*backend_, fetchAllTransactionsInLedger(kRANGE_MAX, _)).WillByDefault(Return(std::vector{t1, t1}));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(
|
||||
R"({
|
||||
"binary": true,
|
||||
@@ -459,7 +463,7 @@ TEST_F(RPCLedgerHandlerTest, TransactionsExpandBinaryV2)
|
||||
EXPECT_CALL(*backend_, fetchAllTransactionsInLedger(kRANGE_MAX, _)).WillOnce(Return(std::vector{t1, t1}));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(
|
||||
R"({
|
||||
"binary": true,
|
||||
@@ -547,7 +551,7 @@ TEST_F(RPCLedgerHandlerTest, TransactionsExpandNotBinary)
|
||||
ON_CALL(*backend_, fetchAllTransactionsInLedger(kRANGE_MAX, _)).WillByDefault(Return(std::vector{t1}));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(
|
||||
R"({
|
||||
"binary": false,
|
||||
@@ -645,7 +649,7 @@ TEST_F(RPCLedgerHandlerTest, TransactionsExpandNotBinaryV2)
|
||||
EXPECT_CALL(*backend_, fetchAllTransactionsInLedger(kRANGE_MAX, _)).WillOnce(Return(std::vector{t1}));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(
|
||||
R"({
|
||||
"binary": false,
|
||||
@@ -678,7 +682,7 @@ TEST_F(RPCLedgerHandlerTest, TwoRequestInARowTransactionsExpandNotBinaryV2)
|
||||
EXPECT_CALL(*backend_, fetchAllTransactionsInLedger(kRANGE_MAX - 1, _)).WillOnce(Return(std::vector{t1}));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(
|
||||
R"({
|
||||
"binary": false,
|
||||
@@ -718,7 +722,7 @@ TEST_F(RPCLedgerHandlerTest, TransactionsNotExpand)
|
||||
.WillByDefault(Return(std::vector{ripple::uint256{kINDEX1}, ripple::uint256{kINDEX2}}));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(
|
||||
R"({
|
||||
"transactions": true
|
||||
@@ -776,7 +780,7 @@ TEST_F(RPCLedgerHandlerTest, DiffNotBinary)
|
||||
ON_CALL(*backend_, fetchLedgerDiff(kRANGE_MAX, _)).WillByDefault(Return(los));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(
|
||||
R"({
|
||||
"diff": true
|
||||
@@ -820,7 +824,7 @@ TEST_F(RPCLedgerHandlerTest, DiffBinary)
|
||||
ON_CALL(*backend_, fetchLedgerDiff(kRANGE_MAX, _)).WillByDefault(Return(los));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(
|
||||
R"({
|
||||
"diff": true,
|
||||
@@ -907,7 +911,7 @@ TEST_F(RPCLedgerHandlerTest, OwnerFundsEmtpy)
|
||||
ON_CALL(*backend_, fetchAllTransactionsInLedger(kRANGE_MAX, _)).WillByDefault(Return(std::vector{t1}));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(
|
||||
R"({
|
||||
"binary": false,
|
||||
@@ -1015,7 +1019,7 @@ TEST_F(RPCLedgerHandlerTest, OwnerFundsTrueBinaryFalse)
|
||||
ON_CALL(*backend_, fetchAllTransactionsInLedger(kRANGE_MAX, _)).WillByDefault(Return(std::vector{tx}));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(
|
||||
R"({
|
||||
"binary": false,
|
||||
@@ -1084,7 +1088,7 @@ TEST_F(RPCLedgerHandlerTest, OwnerFundsTrueBinaryTrue)
|
||||
ON_CALL(*backend_, fetchAllTransactionsInLedger(kRANGE_MAX, _)).WillByDefault(Return(std::vector{tx}));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(
|
||||
R"({
|
||||
"binary": true,
|
||||
@@ -1117,7 +1121,7 @@ TEST_F(RPCLedgerHandlerTest, OwnerFundsIssuerIsSelf)
|
||||
ON_CALL(*backend_, fetchAllTransactionsInLedger(kRANGE_MAX, _)).WillByDefault(Return(std::vector{tx}));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(
|
||||
R"({
|
||||
"binary": true,
|
||||
@@ -1186,7 +1190,7 @@ TEST_F(RPCLedgerHandlerTest, OwnerFundsNotEnoughForReserve)
|
||||
ON_CALL(*backend_, fetchAllTransactionsInLedger(kRANGE_MAX, _)).WillByDefault(Return(std::vector{tx}));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(
|
||||
R"({
|
||||
"binary": true,
|
||||
@@ -1232,7 +1236,7 @@ TEST_F(RPCLedgerHandlerTest, OwnerFundsNotXRP)
|
||||
ON_CALL(*backend_, fetchAllTransactionsInLedger(kRANGE_MAX, _)).WillByDefault(Return(std::vector{tx}));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(
|
||||
R"({
|
||||
"binary": true,
|
||||
@@ -1295,7 +1299,7 @@ TEST_F(RPCLedgerHandlerTest, OwnerFundsIgnoreFreezeLine)
|
||||
ON_CALL(*backend_, fetchAllTransactionsInLedger(kRANGE_MAX, _)).WillByDefault(Return(std::vector{tx}));
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_}};
|
||||
auto const handler = AnyHandler{LedgerHandler{backend_, mockAmendmentCenterPtr_}};
|
||||
auto const req = json::parse(
|
||||
R"({
|
||||
"binary": true,
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "rpc/common/Types.hpp"
|
||||
#include "rpc/handlers/Subscribe.hpp"
|
||||
#include "util/HandlerBaseTestFixture.hpp"
|
||||
#include "util/MockAmendmentCenter.hpp"
|
||||
#include "util/MockSubscriptionManager.hpp"
|
||||
#include "util/MockWsBase.hpp"
|
||||
#include "util/NameGenerator.hpp"
|
||||
@@ -72,6 +73,7 @@ protected:
|
||||
web::SubscriptionContextPtr session_ = std::make_shared<MockSession>();
|
||||
MockSession* mockSession_ = dynamic_cast<MockSession*>(session_.get());
|
||||
StrictMockSubscriptionManagerSharedPtr mockSubscriptionManagerPtr_;
|
||||
StrictMockAmendmentCenterSharedPtr mockAmendmentCenterPtr_;
|
||||
};
|
||||
|
||||
struct SubscribeParamTestCaseBundle {
|
||||
@@ -601,7 +603,8 @@ TEST_P(SubscribeParameterTest, InvalidParams)
|
||||
{
|
||||
auto const testBundle = GetParam();
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{backend_, mockSubscriptionManagerPtr_}};
|
||||
auto const handler =
|
||||
AnyHandler{SubscribeHandler{backend_, mockAmendmentCenterPtr_, mockSubscriptionManagerPtr_}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
@@ -614,7 +617,8 @@ TEST_P(SubscribeParameterTest, InvalidParams)
|
||||
TEST_F(RPCSubscribeHandlerTest, EmptyResponse)
|
||||
{
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{backend_, mockSubscriptionManagerPtr_}};
|
||||
auto const handler =
|
||||
AnyHandler{SubscribeHandler{backend_, mockAmendmentCenterPtr_, mockSubscriptionManagerPtr_}};
|
||||
EXPECT_CALL(*mockSession_, setApiSubversion(0));
|
||||
auto const output = handler.process(json::parse(R"({})"), Context{yield, session_});
|
||||
ASSERT_TRUE(output);
|
||||
@@ -631,7 +635,8 @@ TEST_F(RPCSubscribeHandlerTest, StreamsWithoutLedger)
|
||||
})"
|
||||
);
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{backend_, mockSubscriptionManagerPtr_}};
|
||||
auto const handler =
|
||||
AnyHandler{SubscribeHandler{backend_, mockAmendmentCenterPtr_, mockSubscriptionManagerPtr_}};
|
||||
EXPECT_CALL(*mockSubscriptionManagerPtr_, subTransactions);
|
||||
EXPECT_CALL(*mockSubscriptionManagerPtr_, subValidation);
|
||||
EXPECT_CALL(*mockSubscriptionManagerPtr_, subManifest);
|
||||
@@ -664,7 +669,8 @@ TEST_F(RPCSubscribeHandlerTest, StreamsLedger)
|
||||
})"
|
||||
);
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{backend_, mockSubscriptionManagerPtr_}};
|
||||
auto const handler =
|
||||
AnyHandler{SubscribeHandler{backend_, mockAmendmentCenterPtr_, mockSubscriptionManagerPtr_}};
|
||||
|
||||
EXPECT_CALL(*mockSubscriptionManagerPtr_, subLedger)
|
||||
.WillOnce(testing::Return(boost::json::parse(kEXPECTED_OUTPUT).as_object()));
|
||||
@@ -687,7 +693,8 @@ TEST_F(RPCSubscribeHandlerTest, Accounts)
|
||||
kACCOUNT2
|
||||
));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{backend_, mockSubscriptionManagerPtr_}};
|
||||
auto const handler =
|
||||
AnyHandler{SubscribeHandler{backend_, mockAmendmentCenterPtr_, mockSubscriptionManagerPtr_}};
|
||||
|
||||
EXPECT_CALL(*mockSubscriptionManagerPtr_, subAccount(getAccountIdWithString(kACCOUNT), session_));
|
||||
EXPECT_CALL(*mockSubscriptionManagerPtr_, subAccount(getAccountIdWithString(kACCOUNT2), session_)).Times(2);
|
||||
@@ -709,7 +716,8 @@ TEST_F(RPCSubscribeHandlerTest, AccountsProposed)
|
||||
kACCOUNT2
|
||||
));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{backend_, mockSubscriptionManagerPtr_}};
|
||||
auto const handler =
|
||||
AnyHandler{SubscribeHandler{backend_, mockAmendmentCenterPtr_, mockSubscriptionManagerPtr_}};
|
||||
|
||||
EXPECT_CALL(*mockSubscriptionManagerPtr_, subProposedAccount(getAccountIdWithString(kACCOUNT), session_));
|
||||
EXPECT_CALL(*mockSubscriptionManagerPtr_, subProposedAccount(getAccountIdWithString(kACCOUNT2), session_))
|
||||
@@ -743,7 +751,8 @@ TEST_F(RPCSubscribeHandlerTest, JustBooks)
|
||||
kACCOUNT
|
||||
));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{backend_, mockSubscriptionManagerPtr_}};
|
||||
auto const handler =
|
||||
AnyHandler{SubscribeHandler{backend_, mockAmendmentCenterPtr_, mockSubscriptionManagerPtr_}};
|
||||
EXPECT_CALL(*mockSubscriptionManagerPtr_, subBook);
|
||||
EXPECT_CALL(*mockSession_, setApiSubversion(0));
|
||||
auto const output = handler.process(input, Context{yield, session_});
|
||||
@@ -775,7 +784,8 @@ TEST_F(RPCSubscribeHandlerTest, BooksBothSet)
|
||||
kACCOUNT
|
||||
));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{backend_, mockSubscriptionManagerPtr_}};
|
||||
auto const handler =
|
||||
AnyHandler{SubscribeHandler{backend_, mockAmendmentCenterPtr_, mockSubscriptionManagerPtr_}};
|
||||
EXPECT_CALL(*mockSubscriptionManagerPtr_, subBook).Times(2);
|
||||
EXPECT_CALL(*mockSession_, setApiSubversion(0));
|
||||
auto const output = handler.process(input, Context{yield, session_});
|
||||
@@ -940,7 +950,8 @@ TEST_F(RPCSubscribeHandlerTest, BooksBothSnapshotSet)
|
||||
kACCOUNT
|
||||
);
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{backend_, mockSubscriptionManagerPtr_}};
|
||||
auto const handler =
|
||||
AnyHandler{SubscribeHandler{backend_, mockAmendmentCenterPtr_, mockSubscriptionManagerPtr_}};
|
||||
EXPECT_CALL(*mockSubscriptionManagerPtr_, subBook).Times(2);
|
||||
EXPECT_CALL(*mockSession_, setApiSubversion(0));
|
||||
auto const output = handler.process(input, Context{yield, session_});
|
||||
@@ -1083,7 +1094,8 @@ TEST_F(RPCSubscribeHandlerTest, BooksBothUnsetSnapshotSet)
|
||||
);
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{backend_, mockSubscriptionManagerPtr_}};
|
||||
auto const handler =
|
||||
AnyHandler{SubscribeHandler{backend_, mockAmendmentCenterPtr_, mockSubscriptionManagerPtr_}};
|
||||
EXPECT_CALL(*mockSubscriptionManagerPtr_, subBook);
|
||||
EXPECT_CALL(*mockSession_, setApiSubversion(0));
|
||||
auto const output = handler.process(input, Context{yield, session_});
|
||||
@@ -1102,7 +1114,8 @@ TEST_F(RPCSubscribeHandlerTest, APIVersion)
|
||||
);
|
||||
auto const apiVersion = 2;
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{backend_, mockSubscriptionManagerPtr_}};
|
||||
auto const handler =
|
||||
AnyHandler{SubscribeHandler{backend_, mockAmendmentCenterPtr_, mockSubscriptionManagerPtr_}};
|
||||
EXPECT_CALL(*mockSubscriptionManagerPtr_, subProposedTransactions);
|
||||
EXPECT_CALL(*mockSession_, setApiSubversion(apiVersion));
|
||||
auto const output =
|
||||
|
||||
Reference in New Issue
Block a user