mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-20 19:56:00 +00:00
@@ -50,7 +50,7 @@ public:
|
|||||||
bool validated = true;
|
bool validated = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: We did not implement the "strict" field (can't be implemented?)
|
// Note: clio only supports XRP Ledger addresses (i.e. `strict` is unsupported for `false`)
|
||||||
struct Input
|
struct Input
|
||||||
{
|
{
|
||||||
std::string account;
|
std::string account;
|
||||||
@@ -72,6 +72,7 @@ public:
|
|||||||
{JS(account), validation::Required{}, validation::AccountValidator},
|
{JS(account), validation::Required{}, validation::AccountValidator},
|
||||||
{JS(ledger_hash), validation::Uint256HexStringValidator},
|
{JS(ledger_hash), validation::Uint256HexStringValidator},
|
||||||
{JS(ledger_index), validation::LedgerIndexValidator},
|
{JS(ledger_index), validation::LedgerIndexValidator},
|
||||||
|
{JS(strict), validation::IfType<bool>{validation::NotSupported{false}}},
|
||||||
};
|
};
|
||||||
|
|
||||||
return rpcSpec;
|
return rpcSpec;
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public:
|
|||||||
|
|
||||||
// "queue" is not available in Reporting mode
|
// "queue" is not available in Reporting mode
|
||||||
// "ident" is deprecated, keep it for now, in line with rippled
|
// "ident" is deprecated, keep it for now, in line with rippled
|
||||||
|
// Note: clio only supports XRP Ledger addresses (i.e. `strict` is unsupported for `false`)
|
||||||
struct Input
|
struct Input
|
||||||
{
|
{
|
||||||
std::optional<std::string> account;
|
std::optional<std::string> account;
|
||||||
@@ -89,6 +90,7 @@ public:
|
|||||||
{JS(ledger_hash), validation::Uint256HexStringValidator},
|
{JS(ledger_hash), validation::Uint256HexStringValidator},
|
||||||
{JS(ledger_index), validation::LedgerIndexValidator},
|
{JS(ledger_index), validation::LedgerIndexValidator},
|
||||||
{JS(signer_lists), validation::Type<bool>{}},
|
{JS(signer_lists), validation::Type<bool>{}},
|
||||||
|
{JS(strict), validation::IfType<bool>{validation::NotSupported{false}}},
|
||||||
};
|
};
|
||||||
|
|
||||||
return rpcSpec;
|
return rpcSpec;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public:
|
|||||||
bool validated = true;
|
bool validated = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: We did not implement the "strict" field
|
// Note: clio only supports XRP Ledger addresses (i.e. `strict` is unsupported for `false`)
|
||||||
struct Input
|
struct Input
|
||||||
{
|
{
|
||||||
std::string account;
|
std::string account;
|
||||||
@@ -83,6 +83,7 @@ public:
|
|||||||
{JS(ledger_index), validation::LedgerIndexValidator},
|
{JS(ledger_index), validation::LedgerIndexValidator},
|
||||||
{JS(marker), validation::AccountMarkerValidator},
|
{JS(marker), validation::AccountMarkerValidator},
|
||||||
{JS(limit), validation::Type<uint32_t>{}, validation::Between{10, 400}},
|
{JS(limit), validation::Type<uint32_t>{}, validation::Between{10, 400}},
|
||||||
|
{JS(strict), validation::IfType<bool>{validation::NotSupported{false}}},
|
||||||
};
|
};
|
||||||
|
|
||||||
return rpcSpec;
|
return rpcSpec;
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ public:
|
|||||||
bool validated = true;
|
bool validated = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO:we did not implement the "strict" field
|
|
||||||
struct Input
|
struct Input
|
||||||
{
|
{
|
||||||
std::string account;
|
std::string account;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
bool validated = true;
|
bool validated = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO:we did not implement the "strict" field
|
// Note: clio only supports XRP Ledger addresses (i.e. `strict` is unsupported for `false`)
|
||||||
struct Input
|
struct Input
|
||||||
{
|
{
|
||||||
std::string account;
|
std::string account;
|
||||||
@@ -106,6 +106,7 @@ public:
|
|||||||
{JS(ledger_hash), validation::Uint256HexStringValidator},
|
{JS(ledger_hash), validation::Uint256HexStringValidator},
|
||||||
{JS(ledger_index), validation::LedgerIndexValidator},
|
{JS(ledger_index), validation::LedgerIndexValidator},
|
||||||
{JS(hotwallet), hotWalletValidator},
|
{JS(hotwallet), hotWalletValidator},
|
||||||
|
{JS(strict), validation::IfType<bool>{validation::NotSupported{false}}},
|
||||||
};
|
};
|
||||||
|
|
||||||
return rpcSpec;
|
return rpcSpec;
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ public:
|
|||||||
bool validated = true;
|
bool validated = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: We did not implement the "strict" field
|
|
||||||
struct Input
|
struct Input
|
||||||
{
|
{
|
||||||
std::string nftID;
|
std::string nftID;
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ public:
|
|||||||
bool validated = true;
|
bool validated = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: we did not implement the "strict" field
|
|
||||||
struct Input
|
struct Input
|
||||||
{
|
{
|
||||||
std::string transaction;
|
std::string transaction;
|
||||||
|
|||||||
@@ -40,7 +40,31 @@ class RPCAccountCurrenciesHandlerTest : public HandlerBaseTest
|
|||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(RPCAccountCurrenciesHandlerTest, AccountNotExsit)
|
TEST_F(RPCAccountCurrenciesHandlerTest, StrictSetToFalseUnsupported)
|
||||||
|
{
|
||||||
|
mockBackendPtr->updateRange(10); // min
|
||||||
|
mockBackendPtr->updateRange(30); // max
|
||||||
|
|
||||||
|
auto const static input = boost::json::parse(fmt::format(
|
||||||
|
R"({{
|
||||||
|
"account": "{}",
|
||||||
|
"strict": false
|
||||||
|
}})",
|
||||||
|
ACCOUNT));
|
||||||
|
|
||||||
|
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
|
||||||
|
|
||||||
|
runSpawn([&](auto& yield) {
|
||||||
|
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||||
|
ASSERT_FALSE(output);
|
||||||
|
|
||||||
|
auto const err = RPC::makeError(output.error());
|
||||||
|
EXPECT_EQ(err.at("error").as_string(), "notSupported");
|
||||||
|
EXPECT_EQ(err.at("error_message").as_string(), "Not supported field 'strict's value 'false'");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(RPCAccountCurrenciesHandlerTest, AccountNotExist)
|
||||||
{
|
{
|
||||||
auto const rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
auto const rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
||||||
mockBackendPtr->updateRange(10); // min
|
mockBackendPtr->updateRange(10); // min
|
||||||
@@ -290,3 +314,89 @@ TEST_F(RPCAccountCurrenciesHandlerTest, RequestViaLegderSeq)
|
|||||||
EXPECT_EQ((*output).as_object().at("ledger_index").as_uint64(), ledgerSeq);
|
EXPECT_EQ((*output).as_object().at("ledger_index").as_uint64(), ledgerSeq);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(RPCAccountCurrenciesHandlerTest, RequestViaLegderSeqWithStrictTrue)
|
||||||
|
{
|
||||||
|
auto const rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
||||||
|
mockBackendPtr->updateRange(10); // min
|
||||||
|
mockBackendPtr->updateRange(30); // max
|
||||||
|
auto const ledgerSeq = 29;
|
||||||
|
// return valid ledgerinfo
|
||||||
|
auto const ledgerinfo = CreateLedgerInfo(LEDGERHASH, ledgerSeq);
|
||||||
|
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
|
||||||
|
ON_CALL(*rawBackendPtr, fetchLedgerBySequence(ledgerSeq, _)).WillByDefault(Return(ledgerinfo));
|
||||||
|
// return valid account
|
||||||
|
auto const accountKk = ripple::keylet::account(GetAccountIDWithString(ACCOUNT)).key;
|
||||||
|
ON_CALL(*rawBackendPtr, doFetchLedgerObject(accountKk, ledgerSeq, _))
|
||||||
|
.WillByDefault(Return(Blob{'f', 'a', 'k', 'e'}));
|
||||||
|
|
||||||
|
auto const ownerDir = CreateOwnerDirLedgerObject({ripple::uint256{INDEX1}}, INDEX1);
|
||||||
|
auto const ownerDirKk = ripple::keylet::ownerDir(GetAccountIDWithString(ACCOUNT)).key;
|
||||||
|
ON_CALL(*rawBackendPtr, doFetchLedgerObject(ownerDirKk, ledgerSeq, _))
|
||||||
|
.WillByDefault(Return(ownerDir.getSerializer().peekData()));
|
||||||
|
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObject).Times(2);
|
||||||
|
std::vector<Blob> bbs;
|
||||||
|
auto const line1 =
|
||||||
|
CreateRippleStateLedgerObject(ACCOUNT, "USD", ISSUER, 100, ACCOUNT, 10, ACCOUNT2, 20, TXNID, 123, 0);
|
||||||
|
bbs.push_back(line1.getSerializer().peekData());
|
||||||
|
|
||||||
|
ON_CALL(*rawBackendPtr, doFetchLedgerObjects).WillByDefault(Return(bbs));
|
||||||
|
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObjects).Times(1);
|
||||||
|
auto const static input = boost::json::parse(fmt::format(
|
||||||
|
R"({{
|
||||||
|
"account": "{}",
|
||||||
|
"ledger_index": {},
|
||||||
|
"strict": true
|
||||||
|
}})",
|
||||||
|
ACCOUNT,
|
||||||
|
ledgerSeq));
|
||||||
|
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
|
||||||
|
runSpawn([&](auto& yield) {
|
||||||
|
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||||
|
ASSERT_TRUE(output);
|
||||||
|
EXPECT_EQ((*output).as_object().at("ledger_index").as_uint64(), ledgerSeq);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(RPCAccountCurrenciesHandlerTest, RequestViaLegderSeqWithStrictOfInvalidType)
|
||||||
|
{
|
||||||
|
auto const rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
||||||
|
mockBackendPtr->updateRange(10); // min
|
||||||
|
mockBackendPtr->updateRange(30); // max
|
||||||
|
auto const ledgerSeq = 29;
|
||||||
|
// return valid ledgerinfo
|
||||||
|
auto const ledgerinfo = CreateLedgerInfo(LEDGERHASH, ledgerSeq);
|
||||||
|
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
|
||||||
|
ON_CALL(*rawBackendPtr, fetchLedgerBySequence(ledgerSeq, _)).WillByDefault(Return(ledgerinfo));
|
||||||
|
// return valid account
|
||||||
|
auto const accountKk = ripple::keylet::account(GetAccountIDWithString(ACCOUNT)).key;
|
||||||
|
ON_CALL(*rawBackendPtr, doFetchLedgerObject(accountKk, ledgerSeq, _))
|
||||||
|
.WillByDefault(Return(Blob{'f', 'a', 'k', 'e'}));
|
||||||
|
|
||||||
|
auto const ownerDir = CreateOwnerDirLedgerObject({ripple::uint256{INDEX1}}, INDEX1);
|
||||||
|
auto const ownerDirKk = ripple::keylet::ownerDir(GetAccountIDWithString(ACCOUNT)).key;
|
||||||
|
ON_CALL(*rawBackendPtr, doFetchLedgerObject(ownerDirKk, ledgerSeq, _))
|
||||||
|
.WillByDefault(Return(ownerDir.getSerializer().peekData()));
|
||||||
|
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObject).Times(2);
|
||||||
|
std::vector<Blob> bbs;
|
||||||
|
auto const line1 =
|
||||||
|
CreateRippleStateLedgerObject(ACCOUNT, "USD", ISSUER, 100, ACCOUNT, 10, ACCOUNT2, 20, TXNID, 123, 0);
|
||||||
|
bbs.push_back(line1.getSerializer().peekData());
|
||||||
|
|
||||||
|
ON_CALL(*rawBackendPtr, doFetchLedgerObjects).WillByDefault(Return(bbs));
|
||||||
|
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObjects).Times(1);
|
||||||
|
auto const static input = boost::json::parse(fmt::format(
|
||||||
|
R"({{
|
||||||
|
"account": "{}",
|
||||||
|
"ledger_index": {},
|
||||||
|
"strict": "test"
|
||||||
|
}})",
|
||||||
|
ACCOUNT,
|
||||||
|
ledgerSeq));
|
||||||
|
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
|
||||||
|
runSpawn([&](auto& yield) {
|
||||||
|
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||||
|
ASSERT_TRUE(output);
|
||||||
|
EXPECT_EQ((*output).as_object().at("ledger_index").as_uint64(), ledgerSeq);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -91,6 +91,11 @@ generateTestValuesForParametersTest()
|
|||||||
R"({"ident":"rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun", "ledger_index":"a"})",
|
R"({"ident":"rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun", "ledger_index":"a"})",
|
||||||
"invalidParams",
|
"invalidParams",
|
||||||
"ledgerIndexMalformed"},
|
"ledgerIndexMalformed"},
|
||||||
|
AccountInfoParamTestCaseBundle{
|
||||||
|
"StrictFieldUnsupportedValue",
|
||||||
|
R"({"ident": "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun", "strict": false})",
|
||||||
|
"notSupported",
|
||||||
|
"Not supported field 'strict's value 'false'"},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,6 +373,72 @@ TEST_F(RPCAccountInfoHandlerTest, SignerListsTrue)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(RPCAccountInfoHandlerTest, StrictTrue)
|
||||||
|
{
|
||||||
|
auto const rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
||||||
|
|
||||||
|
mockBackendPtr->updateRange(10); // min
|
||||||
|
mockBackendPtr->updateRange(30); // max
|
||||||
|
|
||||||
|
auto const ledgerinfo = CreateLedgerInfo(LEDGERHASH, 30);
|
||||||
|
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
|
||||||
|
ON_CALL(*rawBackendPtr, fetchLedgerBySequence).WillByDefault(Return(ledgerinfo));
|
||||||
|
|
||||||
|
auto const account = GetAccountIDWithString(ACCOUNT);
|
||||||
|
auto const accountKk = ripple::keylet::account(account).key;
|
||||||
|
auto const accountRoot = CreateAccountRootObject(ACCOUNT, 0, 2, 200, 2, INDEX1, 2);
|
||||||
|
ON_CALL(*rawBackendPtr, doFetchLedgerObject(accountKk, 30, _))
|
||||||
|
.WillByDefault(Return(accountRoot.getSerializer().peekData()));
|
||||||
|
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObject).Times(1);
|
||||||
|
|
||||||
|
auto const static input = boost::json::parse(fmt::format(
|
||||||
|
R"({{
|
||||||
|
"account": "{}",
|
||||||
|
"strict": true
|
||||||
|
}})",
|
||||||
|
ACCOUNT));
|
||||||
|
|
||||||
|
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
|
||||||
|
|
||||||
|
runSpawn([&](auto& yield) {
|
||||||
|
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||||
|
ASSERT_TRUE(output);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(RPCAccountInfoHandlerTest, StrictInvalidTypeHasNoEffect)
|
||||||
|
{
|
||||||
|
auto const rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
||||||
|
|
||||||
|
mockBackendPtr->updateRange(10); // min
|
||||||
|
mockBackendPtr->updateRange(30); // max
|
||||||
|
|
||||||
|
auto const ledgerinfo = CreateLedgerInfo(LEDGERHASH, 30);
|
||||||
|
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
|
||||||
|
ON_CALL(*rawBackendPtr, fetchLedgerBySequence).WillByDefault(Return(ledgerinfo));
|
||||||
|
|
||||||
|
auto const account = GetAccountIDWithString(ACCOUNT);
|
||||||
|
auto const accountKk = ripple::keylet::account(account).key;
|
||||||
|
auto const accountRoot = CreateAccountRootObject(ACCOUNT, 0, 2, 200, 2, INDEX1, 2);
|
||||||
|
ON_CALL(*rawBackendPtr, doFetchLedgerObject(accountKk, 30, _))
|
||||||
|
.WillByDefault(Return(accountRoot.getSerializer().peekData()));
|
||||||
|
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObject).Times(1);
|
||||||
|
|
||||||
|
auto const static input = boost::json::parse(fmt::format(
|
||||||
|
R"({{
|
||||||
|
"account": "{}",
|
||||||
|
"strict": "test"
|
||||||
|
}})",
|
||||||
|
ACCOUNT));
|
||||||
|
|
||||||
|
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
|
||||||
|
|
||||||
|
runSpawn([&](auto& yield) {
|
||||||
|
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||||
|
ASSERT_TRUE(output);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(RPCAccountInfoHandlerTest, IdentAndSignerListsFalse)
|
TEST_F(RPCAccountInfoHandlerTest, IdentAndSignerListsFalse)
|
||||||
{
|
{
|
||||||
auto const rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
auto const rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
||||||
|
|||||||
@@ -131,6 +131,12 @@ generateTestValuesForParametersTest()
|
|||||||
"invalidParams",
|
"invalidParams",
|
||||||
"Malformed cursor",
|
"Malformed cursor",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"StrictFieldUnsupportedValue",
|
||||||
|
R"({"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "strict": false})",
|
||||||
|
"notSupported",
|
||||||
|
"Not supported field 'strict's value 'false'",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,6 +343,108 @@ TEST_F(RPCAccountOffersHandlerTest, DefaultParams)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(RPCAccountOffersHandlerTest, DefaultParamsWithStrictTrue)
|
||||||
|
{
|
||||||
|
auto constexpr ledgerSeq = 30;
|
||||||
|
auto const rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
||||||
|
|
||||||
|
mockBackendPtr->updateRange(10); // min
|
||||||
|
mockBackendPtr->updateRange(ledgerSeq); // max
|
||||||
|
|
||||||
|
auto const ledgerinfo = CreateLedgerInfo(LEDGERHASH, ledgerSeq);
|
||||||
|
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
|
||||||
|
|
||||||
|
ON_CALL(*rawBackendPtr, fetchLedgerBySequence).WillByDefault(Return(ledgerinfo));
|
||||||
|
auto const accountKk = ripple::keylet::account(GetAccountIDWithString(ACCOUNT)).key;
|
||||||
|
ON_CALL(*rawBackendPtr, doFetchLedgerObject(accountKk, ledgerSeq, _))
|
||||||
|
.WillByDefault(Return(Blob{'f', 'a', 'k', 'e'}));
|
||||||
|
|
||||||
|
auto const ownerDir = CreateOwnerDirLedgerObject({ripple::uint256{INDEX1}}, INDEX1);
|
||||||
|
auto const ownerDirKk = ripple::keylet::ownerDir(GetAccountIDWithString(ACCOUNT)).key;
|
||||||
|
ON_CALL(*rawBackendPtr, doFetchLedgerObject(ownerDirKk, ledgerSeq, _))
|
||||||
|
.WillByDefault(Return(ownerDir.getSerializer().peekData()));
|
||||||
|
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObject).Times(2);
|
||||||
|
|
||||||
|
std::vector<Blob> bbs;
|
||||||
|
auto offer = CreateOfferLedgerObject(
|
||||||
|
ACCOUNT,
|
||||||
|
10,
|
||||||
|
20,
|
||||||
|
ripple::to_string(ripple::to_currency("USD")),
|
||||||
|
ripple::to_string(ripple::xrpCurrency()),
|
||||||
|
ACCOUNT2,
|
||||||
|
toBase58(ripple::xrpAccount()),
|
||||||
|
INDEX1);
|
||||||
|
offer.setFieldU32(ripple::sfExpiration, 123);
|
||||||
|
bbs.push_back(offer.getSerializer().peekData());
|
||||||
|
|
||||||
|
ON_CALL(*rawBackendPtr, doFetchLedgerObjects).WillByDefault(Return(bbs));
|
||||||
|
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObjects).Times(1);
|
||||||
|
|
||||||
|
auto const static input = boost::json::parse(fmt::format(
|
||||||
|
R"({{
|
||||||
|
"account": "{}",
|
||||||
|
"strict": true
|
||||||
|
}})",
|
||||||
|
ACCOUNT));
|
||||||
|
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
|
||||||
|
runSpawn([&](auto& yield) {
|
||||||
|
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||||
|
ASSERT_TRUE(output);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(RPCAccountOffersHandlerTest, DefaultParamsWithInvalidTypeStrict)
|
||||||
|
{
|
||||||
|
auto constexpr ledgerSeq = 30;
|
||||||
|
auto const rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
||||||
|
|
||||||
|
mockBackendPtr->updateRange(10); // min
|
||||||
|
mockBackendPtr->updateRange(ledgerSeq); // max
|
||||||
|
|
||||||
|
auto const ledgerinfo = CreateLedgerInfo(LEDGERHASH, ledgerSeq);
|
||||||
|
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
|
||||||
|
|
||||||
|
ON_CALL(*rawBackendPtr, fetchLedgerBySequence).WillByDefault(Return(ledgerinfo));
|
||||||
|
auto const accountKk = ripple::keylet::account(GetAccountIDWithString(ACCOUNT)).key;
|
||||||
|
ON_CALL(*rawBackendPtr, doFetchLedgerObject(accountKk, ledgerSeq, _))
|
||||||
|
.WillByDefault(Return(Blob{'f', 'a', 'k', 'e'}));
|
||||||
|
|
||||||
|
auto const ownerDir = CreateOwnerDirLedgerObject({ripple::uint256{INDEX1}}, INDEX1);
|
||||||
|
auto const ownerDirKk = ripple::keylet::ownerDir(GetAccountIDWithString(ACCOUNT)).key;
|
||||||
|
ON_CALL(*rawBackendPtr, doFetchLedgerObject(ownerDirKk, ledgerSeq, _))
|
||||||
|
.WillByDefault(Return(ownerDir.getSerializer().peekData()));
|
||||||
|
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObject).Times(2);
|
||||||
|
|
||||||
|
std::vector<Blob> bbs;
|
||||||
|
auto offer = CreateOfferLedgerObject(
|
||||||
|
ACCOUNT,
|
||||||
|
10,
|
||||||
|
20,
|
||||||
|
ripple::to_string(ripple::to_currency("USD")),
|
||||||
|
ripple::to_string(ripple::xrpCurrency()),
|
||||||
|
ACCOUNT2,
|
||||||
|
toBase58(ripple::xrpAccount()),
|
||||||
|
INDEX1);
|
||||||
|
offer.setFieldU32(ripple::sfExpiration, 123);
|
||||||
|
bbs.push_back(offer.getSerializer().peekData());
|
||||||
|
|
||||||
|
ON_CALL(*rawBackendPtr, doFetchLedgerObjects).WillByDefault(Return(bbs));
|
||||||
|
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObjects).Times(1);
|
||||||
|
|
||||||
|
auto const static input = boost::json::parse(fmt::format(
|
||||||
|
R"({{
|
||||||
|
"account": "{}",
|
||||||
|
"strict": "test"
|
||||||
|
}})",
|
||||||
|
ACCOUNT));
|
||||||
|
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
|
||||||
|
runSpawn([&](auto& yield) {
|
||||||
|
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||||
|
ASSERT_TRUE(output);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(RPCAccountOffersHandlerTest, Limit)
|
TEST_F(RPCAccountOffersHandlerTest, Limit)
|
||||||
{
|
{
|
||||||
auto constexpr ledgerSeq = 30;
|
auto constexpr ledgerSeq = 30;
|
||||||
|
|||||||
@@ -170,6 +170,18 @@ generateParameterTestBundles()
|
|||||||
ACCOUNT),
|
ACCOUNT),
|
||||||
"invalidParams",
|
"invalidParams",
|
||||||
"hotwalletMalformed"},
|
"hotwalletMalformed"},
|
||||||
|
ParameterTestBundle{
|
||||||
|
"StrictFieldUnsupportedValue",
|
||||||
|
fmt::format(
|
||||||
|
R"({{
|
||||||
|
"account": "{}",
|
||||||
|
"hotwallet": "{}",
|
||||||
|
"strict": false
|
||||||
|
}})",
|
||||||
|
ACCOUNT,
|
||||||
|
ACCOUNT2),
|
||||||
|
"notSupported",
|
||||||
|
"Not supported field 'strict's value 'false'"},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -607,7 +619,84 @@ generateNormalPathTestBundles()
|
|||||||
ACCOUNT3,
|
ACCOUNT3,
|
||||||
ACCOUNT2,
|
ACCOUNT2,
|
||||||
ACCOUNT),
|
ACCOUNT),
|
||||||
fmt::format(R"("hotwallet": ["{}", "{}"])", ACCOUNT2, ACCOUNT3)}};
|
fmt::format(R"("hotwallet": ["{}", "{}"])", ACCOUNT2, ACCOUNT3)},
|
||||||
|
NormalTestBundle{
|
||||||
|
"StrictTrue",
|
||||||
|
CreateOwnerDirLedgerObject(
|
||||||
|
{ripple::uint256{INDEX2}, ripple::uint256{INDEX2}, ripple::uint256{INDEX2}}, INDEX1),
|
||||||
|
std::vector{
|
||||||
|
CreateRippleStateLedgerObject(ACCOUNT, "USD", ISSUER, -10, ACCOUNT, 100, ACCOUNT2, 200, TXNID, 123),
|
||||||
|
CreateRippleStateLedgerObject(ACCOUNT, "CNY", ISSUER, -20, ACCOUNT, 100, ACCOUNT2, 200, TXNID, 123),
|
||||||
|
CreateRippleStateLedgerObject(ACCOUNT, "EUR", ISSUER, -30, ACCOUNT, 100, ACCOUNT3, 200, TXNID, 123)
|
||||||
|
|
||||||
|
},
|
||||||
|
fmt::format(
|
||||||
|
R"({{
|
||||||
|
"balances": {{
|
||||||
|
"{}": [
|
||||||
|
{{
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": "30"
|
||||||
|
}}
|
||||||
|
],
|
||||||
|
"{}": [
|
||||||
|
{{
|
||||||
|
"currency": "USD",
|
||||||
|
"value": "10"
|
||||||
|
}},
|
||||||
|
{{
|
||||||
|
"currency": "CNY",
|
||||||
|
"value": "20"
|
||||||
|
}}
|
||||||
|
]
|
||||||
|
}},
|
||||||
|
"account": "{}",
|
||||||
|
"ledger_index": 300,
|
||||||
|
"ledger_hash": "4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A652"
|
||||||
|
}})",
|
||||||
|
ACCOUNT3,
|
||||||
|
ACCOUNT2,
|
||||||
|
ACCOUNT),
|
||||||
|
fmt::format(R"("hotwallet": ["{}", "{}"], "strict": true)", ACCOUNT2, ACCOUNT3)},
|
||||||
|
NormalTestBundle{
|
||||||
|
"StrictInvalidTypeHasNoEffect",
|
||||||
|
CreateOwnerDirLedgerObject(
|
||||||
|
{ripple::uint256{INDEX2}, ripple::uint256{INDEX2}, ripple::uint256{INDEX2}}, INDEX1),
|
||||||
|
std::vector{
|
||||||
|
CreateRippleStateLedgerObject(ACCOUNT, "USD", ISSUER, -10, ACCOUNT, 100, ACCOUNT2, 200, TXNID, 123),
|
||||||
|
CreateRippleStateLedgerObject(ACCOUNT, "CNY", ISSUER, -20, ACCOUNT, 100, ACCOUNT2, 200, TXNID, 123),
|
||||||
|
CreateRippleStateLedgerObject(ACCOUNT, "EUR", ISSUER, -30, ACCOUNT, 100, ACCOUNT3, 200, TXNID, 123)
|
||||||
|
|
||||||
|
},
|
||||||
|
fmt::format(
|
||||||
|
R"({{
|
||||||
|
"balances": {{
|
||||||
|
"{}": [
|
||||||
|
{{
|
||||||
|
"currency": "EUR",
|
||||||
|
"value": "30"
|
||||||
|
}}
|
||||||
|
],
|
||||||
|
"{}": [
|
||||||
|
{{
|
||||||
|
"currency": "USD",
|
||||||
|
"value": "10"
|
||||||
|
}},
|
||||||
|
{{
|
||||||
|
"currency": "CNY",
|
||||||
|
"value": "20"
|
||||||
|
}}
|
||||||
|
]
|
||||||
|
}},
|
||||||
|
"account": "{}",
|
||||||
|
"ledger_index": 300,
|
||||||
|
"ledger_hash": "4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A652"
|
||||||
|
}})",
|
||||||
|
ACCOUNT3,
|
||||||
|
ACCOUNT2,
|
||||||
|
ACCOUNT),
|
||||||
|
fmt::format(R"("hotwallet": ["{}", "{}"], "strict": "test")", ACCOUNT2, ACCOUNT3)},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
|||||||
Reference in New Issue
Block a user