mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-20 11:45:53 +00:00
@@ -171,15 +171,15 @@ TEST_F(RPCAccountCurrenciesHandlerTest, DefaultParameter)
|
||||
// ACCOUNT can receive USD 10 from ACCOUNT2 and send USD 20 to ACCOUNT2, now
|
||||
// the balance is 100, ACCOUNT can only send USD to ACCOUNT2
|
||||
auto const line1 = CreateRippleStateLedgerObject(
|
||||
ACCOUNT, "USD", ISSUER, 100, ACCOUNT, 10, ACCOUNT2, 20, TXNID, 123);
|
||||
ACCOUNT, "USD", ISSUER, 100, ACCOUNT, 10, ACCOUNT2, 20, TXNID, 123, 0);
|
||||
// ACCOUNT2 can receive JPY 10 from ACCOUNT and send JPY 20 to ACCOUNT, now
|
||||
// the balance is 100, ACCOUNT2 can only send JPY to ACCOUNT
|
||||
auto const line2 = CreateRippleStateLedgerObject(
|
||||
ACCOUNT, "JPY", ISSUER, 100, ACCOUNT2, 10, ACCOUNT, 20, TXNID, 123);
|
||||
ACCOUNT, "JPY", ISSUER, 100, ACCOUNT2, 10, ACCOUNT, 20, TXNID, 123, 0);
|
||||
// ACCOUNT can receive EUR 10 from ACCOUNT and send EUR 20 to ACCOUNT2, now
|
||||
// the balance is 8, ACCOUNT can receive/send EUR to/from ACCOUNT2
|
||||
auto const line3 = CreateRippleStateLedgerObject(
|
||||
ACCOUNT, "EUR", ISSUER, 8, ACCOUNT, 10, ACCOUNT2, 20, TXNID, 123);
|
||||
ACCOUNT, "EUR", ISSUER, 8, ACCOUNT, 10, ACCOUNT2, 20, TXNID, 123, 0);
|
||||
std::vector<Blob> bbs;
|
||||
bbs.push_back(line1.getSerializer().peekData());
|
||||
bbs.push_back(line2.getSerializer().peekData());
|
||||
@@ -226,7 +226,7 @@ TEST_F(RPCAccountCurrenciesHandlerTest, RequestViaLegderHash)
|
||||
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObject).Times(2);
|
||||
std::vector<Blob> bbs;
|
||||
auto const line1 = CreateRippleStateLedgerObject(
|
||||
ACCOUNT, "USD", ISSUER, 100, ACCOUNT, 10, ACCOUNT2, 20, TXNID, 123);
|
||||
ACCOUNT, "USD", ISSUER, 100, ACCOUNT, 10, ACCOUNT2, 20, TXNID, 123, 0);
|
||||
bbs.push_back(line1.getSerializer().peekData());
|
||||
|
||||
ON_CALL(*rawBackendPtr, doFetchLedgerObjects).WillByDefault(Return(bbs));
|
||||
@@ -272,7 +272,7 @@ TEST_F(RPCAccountCurrenciesHandlerTest, RequestViaLegderSeq)
|
||||
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObject).Times(2);
|
||||
std::vector<Blob> bbs;
|
||||
auto const line1 = CreateRippleStateLedgerObject(
|
||||
ACCOUNT, "USD", ISSUER, 100, ACCOUNT, 10, ACCOUNT2, 20, TXNID, 123);
|
||||
ACCOUNT, "USD", ISSUER, 100, ACCOUNT, 10, ACCOUNT2, 20, TXNID, 123, 0);
|
||||
bbs.push_back(line1.getSerializer().peekData());
|
||||
|
||||
ON_CALL(*rawBackendPtr, doFetchLedgerObjects).WillByDefault(Return(bbs));
|
||||
|
||||
1389
unittests/rpc/handlers/BookOffersTest.cpp
Normal file
1389
unittests/rpc/handlers/BookOffersTest.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -746,7 +746,15 @@ generateTestValuesForNormalPathTest()
|
||||
}})",
|
||||
INDEX1),
|
||||
ripple::uint256{INDEX1},
|
||||
CreateOfferLedgerObject(ACCOUNT, 100, 200, "USD", ACCOUNT2)},
|
||||
CreateOfferLedgerObject(
|
||||
ACCOUNT,
|
||||
100,
|
||||
200,
|
||||
"USD",
|
||||
"XRP",
|
||||
ACCOUNT2,
|
||||
ripple::toBase58(ripple::xrpAccount()),
|
||||
INDEX1)},
|
||||
NormalPathTestBundle{
|
||||
"EscrowIndex",
|
||||
fmt::format(
|
||||
@@ -879,7 +887,8 @@ generateTestValuesForNormalPathTest()
|
||||
ACCOUNT2,
|
||||
20,
|
||||
INDEX1,
|
||||
123)},
|
||||
123,
|
||||
0)},
|
||||
NormalPathTestBundle{
|
||||
"Ticket",
|
||||
fmt::format(
|
||||
@@ -905,7 +914,15 @@ generateTestValuesForNormalPathTest()
|
||||
}})",
|
||||
ACCOUNT),
|
||||
ripple::keylet::offer(account1, 2).key,
|
||||
CreateOfferLedgerObject(ACCOUNT, 100, 200, "USD", ACCOUNT2)}};
|
||||
CreateOfferLedgerObject(
|
||||
ACCOUNT,
|
||||
100,
|
||||
200,
|
||||
"USD",
|
||||
"XRP",
|
||||
ACCOUNT2,
|
||||
ripple::toBase58(ripple::xrpAccount()),
|
||||
INDEX1)}};
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
|
||||
@@ -152,6 +152,21 @@ struct SyncAsioContextTest : virtual public NoLoggerFixture
|
||||
{
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
void
|
||||
runSpawn(F&& f)
|
||||
{
|
||||
auto called = false;
|
||||
auto work = std::optional<boost::asio::io_context::work>{ctx};
|
||||
boost::asio::spawn(ctx, [&](boost::asio::yield_context yield) {
|
||||
f(yield);
|
||||
called = true;
|
||||
work.reset();
|
||||
});
|
||||
ctx.run();
|
||||
ASSERT_TRUE(called);
|
||||
}
|
||||
|
||||
protected:
|
||||
boost::asio::io_context ctx;
|
||||
};
|
||||
|
||||
@@ -101,7 +101,8 @@ CreateAccountRootObject(
|
||||
int balance,
|
||||
uint32_t ownerCount,
|
||||
std::string_view previousTxnID,
|
||||
uint32_t previousTxnSeq)
|
||||
uint32_t previousTxnSeq,
|
||||
uint32_t transferRate)
|
||||
{
|
||||
ripple::STObject accountRoot(ripple::sfAccount);
|
||||
accountRoot.setFieldU16(ripple::sfLedgerEntryType, ripple::ltACCOUNT_ROOT);
|
||||
@@ -115,6 +116,7 @@ CreateAccountRootObject(
|
||||
accountRoot.setFieldH256(
|
||||
ripple::sfPreviousTxnID, ripple::uint256{previousTxnID});
|
||||
accountRoot.setFieldU32(ripple::sfPreviousTxnLgrSeq, previousTxnSeq);
|
||||
accountRoot.setFieldU32(ripple::sfTransferRate, transferRate);
|
||||
return accountRoot;
|
||||
}
|
||||
|
||||
@@ -303,11 +305,12 @@ CreateRippleStateLedgerObject(
|
||||
std::string_view highNodeAccountId,
|
||||
int highLimit,
|
||||
std::string_view previousTxnId,
|
||||
uint32_t previousTxnSeq)
|
||||
uint32_t previousTxnSeq,
|
||||
uint32_t flag)
|
||||
{
|
||||
auto line = ripple::STObject(ripple::sfLedgerEntry);
|
||||
line.setFieldU16(ripple::sfLedgerEntryType, ripple::ltRIPPLE_STATE);
|
||||
line.setFieldU32(ripple::sfFlags, 0);
|
||||
line.setFieldU32(ripple::sfFlags, flag);
|
||||
line.setFieldAmount(
|
||||
ripple::sfBalance,
|
||||
ripple::STAmount(GetIssue(currency, issuerId), balance));
|
||||
@@ -327,22 +330,27 @@ CreateOfferLedgerObject(
|
||||
std::string_view account,
|
||||
int takerGets,
|
||||
int takerPays,
|
||||
std::string_view currency,
|
||||
std::string_view issueId)
|
||||
std::string_view getsCurrency,
|
||||
std::string_view paysCurrency,
|
||||
std::string_view getsIssueId,
|
||||
std::string_view paysIssueId,
|
||||
std::string_view dirId)
|
||||
{
|
||||
ripple::STObject offer(ripple::sfLedgerEntry);
|
||||
offer.setFieldU16(ripple::sfLedgerEntryType, ripple::ltOFFER);
|
||||
offer.setAccountID(ripple::sfAccount, GetAccountIDWithString(account));
|
||||
offer.setFieldU32(ripple::sfSequence, 0);
|
||||
offer.setFieldU32(ripple::sfFlags, 0);
|
||||
ripple::Issue issue1 = GetIssue(currency, issueId);
|
||||
ripple::Issue issue1 = GetIssue(getsCurrency, getsIssueId);
|
||||
offer.setFieldAmount(
|
||||
ripple::sfTakerGets, ripple::STAmount(issue1, takerGets));
|
||||
ripple::Issue issue2 = GetIssue(paysCurrency, paysIssueId);
|
||||
offer.setFieldAmount(
|
||||
ripple::sfTakerPays, ripple::STAmount(takerPays, false));
|
||||
ripple::sfTakerPays, ripple::STAmount(issue2, takerPays));
|
||||
offer.setFieldH256(ripple::sfBookDirectory, ripple::uint256{});
|
||||
offer.setFieldU64(ripple::sfBookNode, 0);
|
||||
offer.setFieldU64(ripple::sfOwnerNode, 0);
|
||||
offer.setFieldH256(ripple::sfBookDirectory, ripple::uint256{dirId});
|
||||
offer.setFieldH256(ripple::sfPreviousTxnID, ripple::uint256{});
|
||||
offer.setFieldU32(ripple::sfPreviousTxnLgrSeq, 0);
|
||||
return offer;
|
||||
|
||||
@@ -79,7 +79,8 @@ CreateAccountRootObject(
|
||||
int balance,
|
||||
uint32_t ownerCount,
|
||||
std::string_view previousTxnID,
|
||||
uint32_t previousTxnSeq);
|
||||
uint32_t previousTxnSeq,
|
||||
uint32_t transferRate = 0);
|
||||
|
||||
/*
|
||||
* Create a createoffer treansaction
|
||||
@@ -168,15 +169,19 @@ CreateRippleStateLedgerObject(
|
||||
std::string_view highNodeAccountId,
|
||||
int highLimit,
|
||||
std::string_view previousTxnId,
|
||||
uint32_t previousTxnSeq);
|
||||
uint32_t previousTxnSeq,
|
||||
uint32_t flag = 0);
|
||||
|
||||
ripple::STObject
|
||||
CreateOfferLedgerObject(
|
||||
std::string_view account,
|
||||
int takerGets,
|
||||
int takerPays,
|
||||
std::string_view currency,
|
||||
std::string_view issueId);
|
||||
std::string_view getsCurrency,
|
||||
std::string_view payssCurrency,
|
||||
std::string_view getsIssueId,
|
||||
std::string_view paysIssueId,
|
||||
std::string_view bookDirId);
|
||||
|
||||
ripple::STObject
|
||||
CreateTicketLedgerObject(std::string_view rootIndex, uint32_t sequence);
|
||||
|
||||
Reference in New Issue
Block a user