mirror of
https://github.com/XRPLF/rippled.git
synced 2026-10-21 19:18:22 +00:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3608433514 | ||
|
|
7939339a65 | ||
|
|
4ea2db2eda | ||
|
|
d4ffe32534 | ||
|
|
7354816f65 | ||
|
|
12cb3932f3 | ||
|
|
dc64a8daac | ||
|
|
dc524e9cc6 | ||
|
|
4060b1bcd4 | ||
|
|
bfbb440fc2 |
No files matched your search
@@ -8,6 +8,7 @@ on:
|
||||
branches:
|
||||
- "develop"
|
||||
- "release/*"
|
||||
- "staging/*"
|
||||
paths:
|
||||
- "crates/**/Cargo.toml"
|
||||
- "crates/Cargo.lock"
|
||||
|
||||
@@ -243,7 +243,7 @@ jobs:
|
||||
- should-run
|
||||
- build-test
|
||||
# Only run when committing to a PR that targets a release branch.
|
||||
if: ${{ github.repository == 'XRPLF/rippled' && needs.should-run.outputs.go == 'true' && github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release') }}
|
||||
if: ${{ github.repository == 'XRPLF/rippled' && needs.should-run.outputs.go == 'true' && github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release/') }}
|
||||
uses: ./.github/workflows/reusable-upload-recipe.yml
|
||||
secrets:
|
||||
remote_username: ${{ secrets.NEXUS_REMOTE_USERNAME }}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
# This workflow runs all workflows to build and test the code on various Linux
|
||||
# flavors, as well as on MacOS and Windows, on a scheduled basis, on merge into
|
||||
# the 'develop' or 'release*' branches, or when requested manually. Upon pushes
|
||||
# to the develop branch it also uploads the libxrpl recipe to the Conan remote.
|
||||
# the 'develop', 'release/*' or 'staging/*' branches, or when requested
|
||||
# manually. Upon pushes to the develop branch, it also uploads the libxrpl
|
||||
# recipe to the Conan remote.
|
||||
name: Trigger
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "develop"
|
||||
- "release*"
|
||||
- "release/*"
|
||||
- "staging/*"
|
||||
paths:
|
||||
# These paths are unique to `on-trigger.yml`.
|
||||
- ".github/workflows/on-trigger.yml"
|
||||
@@ -62,9 +64,9 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
# When a PR is merged into the develop branch it will be assigned a unique
|
||||
# When a PR is merged into the develop branch, it will be assigned a unique
|
||||
# group identifier, so execution will continue even if another PR is merged
|
||||
# while it is still running. In all other cases the group identifier is shared
|
||||
# while it is still running. In all other cases, the group identifier is shared
|
||||
# per branch, so that any in-progress runs are cancelled when a new commit is
|
||||
# pushed.
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' && github.sha || github.ref }}
|
||||
@@ -98,7 +100,7 @@ jobs:
|
||||
# However, we do not enable ccache for events targeting a release branch,
|
||||
# to protect against the rare case that the output produced by ccache is
|
||||
# not identical to a regular compilation.
|
||||
ccache_enabled: ${{ github.repository_owner == 'XRPLF' && !startsWith(github.ref, 'refs/heads/release') }}
|
||||
ccache_enabled: ${{ github.repository_owner == 'XRPLF' && !startsWith(github.ref, 'refs/heads/release/') }}
|
||||
os: ${{ matrix.os }}
|
||||
secrets:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
@@ -8,7 +8,8 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- "develop"
|
||||
- "release*"
|
||||
- "release/*"
|
||||
- "staging/*"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
@@ -37,6 +37,7 @@ Version 3.5.0 is not yet released.
|
||||
- `channel_verify`: The `channel_id` and `signature` fields now return an `invalidParams` error if the value is not a string. [#7582](https://github.com/XRPLF/rippled/pull/7582)
|
||||
- `account_currencies`, `account_nfts`, `account_offers`: A request with more than one problem may now report a different one of them. An invalid `ledger_hash` or `ledger_index` is reported before an invalid or missing `account`. An invalid `limit` or `marker` is reported before `lgrNotFound` or `actNotFound`, and for `account_offers` also before `actMalformed`. A request with a single problem returns the same error as before. [#8561](https://github.com/XRPLF/rippled/pull/8561)
|
||||
- `deposit_authorized`: A `credentials` entry that is all zeros (for example `"0"` or 64 `0` characters) now returns a `badCredentials` error instead of looking up a credential that can never exist.
|
||||
- `account_info`, `account_lines`, `account_channels`: A request with more than one problem may now report a different one of them. An invalid `ledger_hash` or `ledger_index` is reported before a missing or invalid `account`, or `ident` for `account_info`. For `account_lines`, a `peer` that is not a string, or an invalid `limit` or `marker`, is reported before `lgrNotFound`, `actNotFound` or a malformed `account`, and an invalid `limit` or `marker` also before a malformed `peer`. For `account_channels`, a malformed `account` is reported before `lgrNotFound`, and an invalid `destination_account`, `limit` or `marker` before `lgrNotFound` or `actNotFound`. A request with a single problem returns the same error as before. [#8573](https://github.com/XRPLF/rippled/pull/8573)
|
||||
|
||||
### Bugfixes in 3.5.0
|
||||
|
||||
|
||||
@@ -297,7 +297,10 @@ if(xrpld)
|
||||
VALUE_TYPE "::json::Value"
|
||||
VIEW_HEADER "xrpld/rpc/detail/JsonObjectView.hpp"
|
||||
HANDLERS
|
||||
account_channels
|
||||
account_currencies
|
||||
account_info
|
||||
account_lines
|
||||
account_nfts
|
||||
account_offers
|
||||
book_changes
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
"requires": [
|
||||
"zlib/1.3.2#1cb806da49011867778ffb6ac7190fcb%1782392402.122708",
|
||||
"xxhash/0.8.3#681d36a0a6111fc56e5e45ea182c19cc%1782392402.420688",
|
||||
"xrpl-rpc-spec/0.1.23#56e8946f5b3fb949a3732e1a51135ca2%1790977482.197086",
|
||||
"xrpl-rpc-spec/0.1.25#2daa763e2d86ccc4ad0a0fa4d1983e9f%1791907455.579992",
|
||||
"sqlite3/3.53.0#324ada52333108388a9a6108bfa96734%1782392403.185447",
|
||||
"soci/4.0.3#e726491a03468795453f7c83fc924a96%1782392402.679521",
|
||||
"snappy/1.1.10#968fef506ff261592ec30c574d4a7809%1782307151.633168",
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ class Xrpl(ConanFile):
|
||||
"nudb/2.0.9",
|
||||
"openssl/3.6.3",
|
||||
"soci/4.0.3",
|
||||
"xrpl-rpc-spec/0.1.23",
|
||||
"xrpl-rpc-spec/0.1.25",
|
||||
"zlib/1.3.2",
|
||||
]
|
||||
|
||||
|
||||
@@ -352,9 +352,9 @@ class Number final
|
||||
using rep = std::int64_t;
|
||||
using InternalRep = MantissaRange::rep;
|
||||
|
||||
bool negative_{false};
|
||||
InternalRep mantissa_{0};
|
||||
int exponent_{std::numeric_limits<int>::lowest()};
|
||||
bool negative_{false};
|
||||
|
||||
public:
|
||||
// The range for the exponent when normalized
|
||||
@@ -650,8 +650,12 @@ private:
|
||||
shiftExponent(int exponentDelta) const;
|
||||
};
|
||||
|
||||
// The number class currently has 3 tail padding bytes. If you are adding new
|
||||
// members, try to fit them there before expanding the size of the class.
|
||||
static_assert(sizeof(Number) == 16);
|
||||
|
||||
constexpr Number::Number(bool negative, InternalRep mantissa, int exponent, Unchecked) noexcept
|
||||
: negative_(negative), mantissa_{mantissa}, exponent_{exponent}
|
||||
: mantissa_{mantissa}, exponent_{exponent}, negative_(negative)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/Concepts.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Fees.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
#include <xrpl/protocol/Keylet.h>
|
||||
@@ -27,6 +28,8 @@
|
||||
#include <xrpl/protocol/TER.h>
|
||||
#include <xrpl/protocol/UintTypes.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
/**
|
||||
@@ -560,4 +563,54 @@ escrowUnlockApplyHelper<MPTIssue>(
|
||||
journal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Smart escrow kill switches, driven by the voted FeeSettings.
|
||||
*
|
||||
* Zeroing `bytecodeSizeLimit` stops new uploads while leaving existing escrows
|
||||
* finishable without forcing holders to wait for `CancelAfter`.
|
||||
* Zeroing `gasLimit` stops both.
|
||||
*/
|
||||
/** @{ */
|
||||
inline bool
|
||||
isBytecodeUploadDisabled(Fees const& fees)
|
||||
{
|
||||
return fees.bytecodeSizeLimit == 0 || fees.gasLimit == 0;
|
||||
}
|
||||
|
||||
inline bool
|
||||
isBytecodeExecutionDisabled(Fees const& fees)
|
||||
{
|
||||
return fees.gasLimit == 0;
|
||||
}
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* Owner count an escrow costs.
|
||||
*
|
||||
* An escrow costs one increment per started 500 bytes of bytecode, and one
|
||||
* increment if it carries no bytecode.
|
||||
*/
|
||||
template <class T>
|
||||
int32_t
|
||||
calculateAdditionalReserve(T const& finishFunction)
|
||||
{
|
||||
static auto constexpr kBytecodeReserveIncrement = 500;
|
||||
|
||||
if (!finishFunction)
|
||||
return 1;
|
||||
|
||||
auto const size = finishFunction->size();
|
||||
if (size == 0)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
// Empty Bytecode is refused at create, so no escrow carries it. Ceiling
|
||||
// division would answer 0, which would subtract less than the create added.
|
||||
UNREACHABLE("xrpl::calculateAdditionalReserve : empty Bytecode");
|
||||
return 1;
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
return static_cast<int32_t>((size + kBytecodeReserveIncrement - 1) / kBytecodeReserveIncrement);
|
||||
}
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -398,6 +398,11 @@ constexpr std::uint32_t kMaxInvestmentPeriod = std::chrono::seconds{std::chrono:
|
||||
*/
|
||||
constexpr std::uint8_t kMaxAssetCheckDepth = 5;
|
||||
|
||||
/**
|
||||
* Maximum length of a Data field in Escrow object that can be updated by WASM code.
|
||||
*/
|
||||
constexpr std::size_t kMaxWasmDataLength = 1 * 1024; // 1KB
|
||||
|
||||
/**
|
||||
* A ledger index.
|
||||
*/
|
||||
|
||||
@@ -133,7 +133,6 @@ enum TEMcodes : TERUnderlyingType {
|
||||
temBAD_MPT,
|
||||
temBAD_CIPHERTEXT,
|
||||
temINVALID_BYTECODE,
|
||||
temTEMP_DISABLED,
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -184,6 +183,8 @@ enum TEFcodes : TERUnderlyingType {
|
||||
tefBAD_PATH_COUNT,
|
||||
tefNO_BYTECODE,
|
||||
tefBYTECODE_NOT_INCLUDED,
|
||||
tefTEMP_DISABLED,
|
||||
tefEXCEEDS_LIMIT,
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/protocol/Keylet.h>
|
||||
#include <xrpl/protocol/STLedgerEntry.h>
|
||||
#include <xrpl/protocol/STTx.h>
|
||||
#include <xrpl/protocol/TER.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
class ReadView;
|
||||
|
||||
/**
|
||||
* @brief Invariants for TransactionProposal ledger entries.
|
||||
*
|
||||
* - Only transaction types implementing proposal lifecycle operations may
|
||||
* create or modify proposals, and a failed one leaves no proposal effect.
|
||||
* - A proposal is deleted only by TransactionProposalCancel or together with
|
||||
* the Ticket it is keyed to, and a deleted Ticket takes the proposal keyed
|
||||
* to it along.
|
||||
* - Collected signer arrays remain sorted, unique, and bounded.
|
||||
*/
|
||||
class ValidTransactionProposal
|
||||
{
|
||||
// The Ticket each deleted proposal was keyed to; a proposal may go with
|
||||
// its Ticket, or by Cancel, and no other way.
|
||||
std::vector<uint256> ticketsOfDeletedProposals_;
|
||||
// The proposal each deleted Ticket was keyed to, whether or not one
|
||||
// existed; none may survive its Ticket.
|
||||
std::vector<Keylet> proposalsOfDeletedTickets_;
|
||||
std::set<uint256> deletedTickets_;
|
||||
std::uint32_t created_ = 0;
|
||||
std::uint32_t modified_ = 0;
|
||||
std::uint32_t deleted_ = 0;
|
||||
bool invalidSignerArrays_ = false;
|
||||
|
||||
public:
|
||||
void
|
||||
visitEntry(bool isDelete, SLE::ConstRef before, SLE::ConstRef after);
|
||||
|
||||
[[nodiscard]] bool
|
||||
finalize(STTx const& tx, TER result, XRPAmount, ReadView const& view, beast::Journal const& j)
|
||||
const;
|
||||
};
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <xrpl/protocol/TER.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
#include <xrpl/tx/invariants/AMMInvariant.h>
|
||||
#include <xrpl/tx/invariants/CosignerInvariant.h>
|
||||
#include <xrpl/tx/invariants/DirectoryInvariant.h>
|
||||
#include <xrpl/tx/invariants/FreezeInvariant.h>
|
||||
#include <xrpl/tx/invariants/LoanBrokerInvariant.h>
|
||||
@@ -483,6 +484,7 @@ using InvariantChecks = std::tuple<
|
||||
ValidAmounts,
|
||||
ValidMPTTransfer,
|
||||
ObjectHasPseudoAccount,
|
||||
ValidTransactionProposal,
|
||||
SponsorshipOwnerCountsMatch,
|
||||
SponsorshipAccountCountMatchesField>;
|
||||
|
||||
|
||||
@@ -20,11 +20,14 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
static bool
|
||||
checkExtraFeatures(PreflightContext const& ctx);
|
||||
|
||||
static TxConsequences
|
||||
makeTxConsequences(PreflightContext const& ctx);
|
||||
|
||||
static bool
|
||||
checkExtraFeatures(PreflightContext const& ctx);
|
||||
static XRPAmount
|
||||
calculateBaseFee(ReadView const& view, STTx const& tx);
|
||||
|
||||
static NotTEC
|
||||
preflight(PreflightContext const& ctx);
|
||||
|
||||
@@ -43,6 +43,9 @@ constexpr auto kProposalTxTypes = std::to_array<TxType>({
|
||||
bool
|
||||
isValidProposalTxnType(STObject const& proposedTx)
|
||||
{
|
||||
if (!proposedTx.isFieldPresent(sfTransactionType))
|
||||
return false;
|
||||
|
||||
auto const type = proposedTx.getFieldU16(sfTransactionType);
|
||||
|
||||
if (std::ranges::find(kProposalTxTypes, type) != kProposalTxTypes.end())
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <xrpl/ledger/ApplyView.h>
|
||||
#include <xrpl/ledger/ReadView.h>
|
||||
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
|
||||
#include <xrpl/ledger/helpers/EscrowHelpers.h>
|
||||
#include <xrpl/ledger/helpers/OracleHelpers.h>
|
||||
#include <xrpl/ledger/helpers/ProposalHelpers.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
@@ -319,6 +320,8 @@ getLedgerEntryOwnerCount(SLE const& sle)
|
||||
UNREACHABLE("AccountRoots are not supported by object sponsorship.");
|
||||
return 0;
|
||||
// LCOV_EXCL_STOP
|
||||
case ltESCROW:
|
||||
return calculateAdditionalReserve(sle[~sfBytecode]);
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -137,6 +137,8 @@ transResults()
|
||||
MAKE_ERROR(tefBAD_PATH_COUNT, "Malformed: Too many paths."),
|
||||
MAKE_ERROR(tefNO_BYTECODE, "There is no WASM code to run, but a WASM-specific field was included."),
|
||||
MAKE_ERROR(tefBYTECODE_NOT_INCLUDED, "WASM code requires a field that was not included."),
|
||||
MAKE_ERROR(tefTEMP_DISABLED, "The transaction requires logic that is currently temporarily disabled."),
|
||||
MAKE_ERROR(tefEXCEEDS_LIMIT, "The transaction exceeds a limit set by fee voting."),
|
||||
|
||||
MAKE_ERROR(telLOCAL_ERROR, "Local failure."),
|
||||
MAKE_ERROR(telBAD_DOMAIN, "Domain too long."),
|
||||
@@ -209,7 +211,6 @@ transResults()
|
||||
MAKE_ERROR(temINVALID_INNER_BATCH, "Malformed: Invalid inner batch transaction."),
|
||||
MAKE_ERROR(temBAD_CIPHERTEXT, "Malformed: Invalid ciphertext."),
|
||||
MAKE_ERROR(temINVALID_BYTECODE, "Malformed: Provided byte code is invalid."),
|
||||
MAKE_ERROR(temTEMP_DISABLED, "The transaction requires logic that is currently temporarily disabled."),
|
||||
|
||||
MAKE_ERROR(terRETRY, "Retry transaction."),
|
||||
MAKE_ERROR(terFUNDS_SPENT, "DEPRECATED."),
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#include <xrpl/protocol/detail/transactions.macro>
|
||||
|
||||
#undef TRANSACTION
|
||||
#undef TRANSACTION_INCLUDE
|
||||
|
||||
#pragma pop_macro("TRANSACTION")
|
||||
|
||||
// DO NOT INCLUDE TRANSACTOR HEADER FILES HERE.
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
#include <xrpl/tx/invariants/CosignerInvariant.h>
|
||||
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/ledger/ReadView.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Keylet.h>
|
||||
#include <xrpl/protocol/LedgerFormats.h>
|
||||
#include <xrpl/protocol/Protocol.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STArray.h>
|
||||
#include <xrpl/protocol/STLedgerEntry.h>
|
||||
#include <xrpl/protocol/STObject.h>
|
||||
#include <xrpl/protocol/STTx.h>
|
||||
#include <xrpl/protocol/SeqProxy.h>
|
||||
#include <xrpl/protocol/TER.h>
|
||||
#include <xrpl/protocol/TxFormats.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
namespace {
|
||||
|
||||
bool
|
||||
validSignerArray(STArray const& signers, std::size_t limit, SField const& elementName)
|
||||
{
|
||||
if (signers.size() > limit)
|
||||
return false;
|
||||
|
||||
std::optional<AccountID> previous;
|
||||
for (auto const& signer : signers)
|
||||
{
|
||||
if (signer.getFName() != elementName || !signer.isFieldPresent(sfAccount))
|
||||
return false;
|
||||
|
||||
auto const account = signer.getAccountID(sfAccount);
|
||||
if (previous && account <= *previous)
|
||||
return false;
|
||||
previous = account;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
validNestedSigners(STObject const& signature)
|
||||
{
|
||||
return !signature.isFieldPresent(sfSigners) ||
|
||||
validSignerArray(signature.getFieldArray(sfSigners), STTx::kMaxMultiSigners, sfSigner);
|
||||
}
|
||||
|
||||
bool
|
||||
validSignerArrays(STObject const& proposedTx)
|
||||
{
|
||||
if (!validNestedSigners(proposedTx))
|
||||
return false;
|
||||
|
||||
for (auto const* field :
|
||||
std::array<SField const*, 2>{&sfCounterpartySignature, &sfSponsorSignature})
|
||||
{
|
||||
if (proposedTx.isFieldPresent(*field) &&
|
||||
!validNestedSigners(proposedTx.getFieldObject(*field)))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!proposedTx.isFieldPresent(sfBatchSigners))
|
||||
return true;
|
||||
|
||||
auto const& batchSigners = proposedTx.getFieldArray(sfBatchSigners);
|
||||
if (!validSignerArray(batchSigners, kMaxBatchSigners, sfBatchSigner))
|
||||
return false;
|
||||
|
||||
return std::ranges::all_of(
|
||||
batchSigners, [](auto const& batchSigner) { return validNestedSigners(batchSigner); });
|
||||
}
|
||||
|
||||
// The Ticket a proposal is keyed to: the one its proposed transaction spends.
|
||||
uint256
|
||||
proposalTicketKey(SLE const& proposal)
|
||||
{
|
||||
auto const& proposedTx = proposal.getFieldObject(sfProposedTransaction);
|
||||
return keylet::ticket(
|
||||
proposedTx.getAccountID(sfAccount),
|
||||
SeqProxy::rawTicket(proposedTx.getFieldU32(sfTicketSequence)))
|
||||
.key;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void
|
||||
ValidTransactionProposal::visitEntry(bool isDelete, SLE::ConstRef before, SLE::ConstRef after)
|
||||
{
|
||||
// `after` is always present (on deletion it holds the final state), so it
|
||||
// alone determines the entry type. LedgerEntryTypesMatch owns malformed
|
||||
// type transitions; skip them rather than read one side with the other's
|
||||
// schema.
|
||||
if (!after || (before && before->getType() != after->getType()))
|
||||
return;
|
||||
|
||||
auto const type = after->getType();
|
||||
|
||||
// Consuming a Ticket deletes the proposal keyed to it (XLS-0103 §4.5).
|
||||
// Remember each Ticket that went, so finalize can tell a proposal deleted
|
||||
// with its Ticket from one that simply vanished, and the proposal each
|
||||
// Ticket was keyed to, so finalize can check that none stayed behind.
|
||||
if (type == ltTICKET)
|
||||
{
|
||||
if (isDelete)
|
||||
{
|
||||
deletedTickets_.insert(after->key());
|
||||
proposalsOfDeletedTickets_.push_back(
|
||||
keylet::txProposal(
|
||||
after->getAccountID(sfAccount), after->getFieldU32(sfTicketSequence)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (type != ltTRANSACTION_PROPOSAL)
|
||||
return;
|
||||
|
||||
if (!before)
|
||||
{
|
||||
++created_;
|
||||
}
|
||||
else if (isDelete)
|
||||
{
|
||||
++deleted_;
|
||||
ticketsOfDeletedProposals_.push_back(proposalTicketKey(*before));
|
||||
}
|
||||
else
|
||||
{
|
||||
++modified_;
|
||||
}
|
||||
|
||||
// A live proposal's signer lists must stay submittable: within size
|
||||
// limits, sorted by account, and free of duplicates.
|
||||
if (!isDelete && !validSignerArrays(after->getFieldObject(sfProposedTransaction)))
|
||||
invalidSignerArrays_ = true;
|
||||
}
|
||||
|
||||
bool
|
||||
ValidTransactionProposal::finalize(
|
||||
STTx const& tx,
|
||||
TER result,
|
||||
XRPAmount,
|
||||
ReadView const& view,
|
||||
beast::Journal const& j) const
|
||||
{
|
||||
if (!view.rules().enabled(featureCosign))
|
||||
return true;
|
||||
|
||||
if (invalidSignerArrays_)
|
||||
{
|
||||
JLOG(j.fatal()) << "Invariant failed: TransactionProposal signer arrays are not canonical.";
|
||||
return false;
|
||||
}
|
||||
|
||||
// A proposal leaves the ledger in two ways (XLS-0103 §4.5): a
|
||||
// TransactionProposalCancel deletes the proposal it names, and consuming
|
||||
// the Ticket a proposal is keyed to deletes the proposal with it, whether
|
||||
// the proposed transaction executed (or failed with a claimed-fee tec) or
|
||||
// AccountDelete swept the target's Tickets.
|
||||
std::uint32_t deletedWithTicket = 0;
|
||||
for (auto const& ticketKey : ticketsOfDeletedProposals_)
|
||||
{
|
||||
if (deletedTickets_.contains(ticketKey))
|
||||
++deletedWithTicket;
|
||||
}
|
||||
|
||||
bool const succeeded = isTesSuccess(result);
|
||||
bool effectsMatch = false;
|
||||
if (tx.getTxnType() == ttTRANSACTION_PROPOSAL_CREATE)
|
||||
{
|
||||
effectsMatch = created_ == (succeeded ? 1u : 0u) && modified_ == 0 && deleted_ == 0;
|
||||
}
|
||||
else if (tx.getTxnType() == ttTRANSACTION_PROPOSAL_CANCEL)
|
||||
{
|
||||
// A Cancel deletes one proposal and nothing else. It cannot
|
||||
// spend a reserved Ticket, so no proposal goes with its Ticket here.
|
||||
effectsMatch = created_ == 0 && modified_ == 0 && deletedWithTicket == 0 &&
|
||||
deleted_ == (succeeded ? 1u : 0u);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Any other transaction deletes a proposal only together with its
|
||||
// Ticket, and modifies at most one, only as a successful
|
||||
// SponsorshipTransfer.
|
||||
// TODO: extend this when TransactionProposalSign is implemented.
|
||||
std::uint32_t const modifiable =
|
||||
tx.getTxnType() == ttSPONSORSHIP_TRANSFER && succeeded ? 1 : 0;
|
||||
effectsMatch = created_ == 0 && modified_ <= modifiable && deleted_ == deletedWithTicket;
|
||||
}
|
||||
|
||||
if (!effectsMatch)
|
||||
{
|
||||
JLOG(j.fatal())
|
||||
<< "Invariant failed: TransactionProposal changes do not match transaction result.";
|
||||
return false;
|
||||
}
|
||||
|
||||
// The other direction of the deletion rule: ticketDelete deletes the
|
||||
// proposal keyed to a Ticket along with it (XLS-0103 §4.5), so no
|
||||
// proposal may outlive its Ticket, orphaned on a key that can no longer
|
||||
// be spent.
|
||||
bool const orphaned = std::ranges::any_of(
|
||||
proposalsOfDeletedTickets_, [&view](Keylet const& keylet) { return view.exists(keylet); });
|
||||
if (orphaned)
|
||||
{
|
||||
JLOG(j.fatal())
|
||||
<< "Invariant failed: TransactionProposal outlived the Ticket it is keyed to.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -935,8 +935,12 @@ ValidClawback::finalize(
|
||||
return !mptV2Enabled;
|
||||
}
|
||||
|
||||
// IOU balances keep 16 significant digits, so a clawback
|
||||
// much smaller than the balance changes it by a rounded
|
||||
// amount, possibly zero. Compare with the same rounded
|
||||
// subtraction the balance update performs.
|
||||
if (*afterBalance > *beforeBalance ||
|
||||
(*beforeBalance - *afterBalance) != std::min(*beforeBalance, clawAmount))
|
||||
*afterBalance != *beforeBalance - std::min(*beforeBalance, clawAmount))
|
||||
{
|
||||
JLOG(j.fatal())
|
||||
<< "Invariant failed: trustline clawback balance change is invalid";
|
||||
|
||||
@@ -254,6 +254,15 @@ private:
|
||||
TAmounts<TIn, TOut> const& stepAmt,
|
||||
TOut const& ownerGives) const;
|
||||
|
||||
template <template <typename, typename> typename Offer>
|
||||
void
|
||||
tryConsumeOffer(
|
||||
PaymentSandbox& sb,
|
||||
Offer<TIn, TOut>& offer,
|
||||
TAmounts<TIn, TOut> const& ofrAmt,
|
||||
TAmounts<TIn, TOut> const& stepAmt,
|
||||
TOut const& ownerGives) const;
|
||||
|
||||
// If clobQuality is available and has a better quality then return nullopt,
|
||||
// otherwise if amm liquidity is available return AMM offer adjusted based
|
||||
// on clobQuality.
|
||||
@@ -810,10 +819,11 @@ BookStep<TIn, TOut, TDerived>::forEachOffer(
|
||||
auto const amtIn = [&](TIn const& in) { return capInMPT && *maxIn_ < in ? *maxIn_ : in; };
|
||||
try
|
||||
{
|
||||
// All arithmetic in this block runs before the offer is consumed.
|
||||
// A crafted MPTokensV2 offer can overflow while transfer rates or
|
||||
// crossing limits are applied; remove that unusable offer instead
|
||||
// of letting it persist as a tecINTERNAL source.
|
||||
// crossing limits are applied, here or in the callback's
|
||||
// limitStepIn()/limitStepOut(); remove that unusable offer instead
|
||||
// of letting it persist as a tecINTERNAL source. Overflows while
|
||||
// consuming the offer are handled by tryConsumeOffer().
|
||||
stpAmt.in = mulRatio(amtIn(ofrAmt.in), ofrInRate, QUALITY_ONE, /*roundUp*/ true);
|
||||
|
||||
// owner pays the transfer fee. An MPT gross-up that doesn't fit in
|
||||
@@ -941,16 +951,9 @@ BookStep<TIn, TOut, TDerived>::forEachOffer(
|
||||
removeOffer("Removing offer with overflowing amount calculation");
|
||||
return true;
|
||||
}
|
||||
// An overflow can only be produced by a crafted MPT offer, and MPT
|
||||
// offers require featureMPTokensV2 (enforced at OfferCreate
|
||||
// preflight). So the amendment is always enabled when we get here
|
||||
// and this legacy re-throw is unreachable in practice.
|
||||
// LCOV_EXCL_START
|
||||
XRPL_ASSERT(
|
||||
sb.rules().enabled(featureMPTokensV2),
|
||||
"xrpl::BookStep::forEachOffer : overflow implies MPTokensV2");
|
||||
// Legacy behavior: the exception escapes flow() and the
|
||||
// transaction fails with tecINTERNAL.
|
||||
throw;
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
};
|
||||
|
||||
@@ -991,6 +994,32 @@ BookStep<TIn, TOut, TDerived>::forEachOffer(
|
||||
return {offers.permToRemove(), counter.count()};
|
||||
}
|
||||
|
||||
template <class TIn, class TOut, class TDerived>
|
||||
template <template <typename, typename> typename Offer>
|
||||
void
|
||||
BookStep<TIn, TOut, TDerived>::tryConsumeOffer(
|
||||
PaymentSandbox& sb,
|
||||
Offer<TIn, TOut>& offer,
|
||||
TAmounts<TIn, TOut> const& ofrAmt,
|
||||
TAmounts<TIn, TOut> const& stepAmt,
|
||||
TOut const& ownerGives) const
|
||||
{
|
||||
try
|
||||
{
|
||||
// Under MPTokensV2, an overflow while consuming the offer fails the
|
||||
// strand instead of being handled by forEachOffer().
|
||||
consumeOffer(sb, offer, ofrAmt, stepAmt, ownerGives);
|
||||
}
|
||||
catch (std::overflow_error const&)
|
||||
{
|
||||
if (sb.rules().enabled(featureMPTokensV2))
|
||||
{
|
||||
Throw<FlowException>(tecINTERNAL, "Overflow while consuming offer");
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <class TIn, class TOut, class TDerived>
|
||||
template <template <typename, typename> typename Offer>
|
||||
void
|
||||
@@ -1192,7 +1221,7 @@ BookStep<TIn, TOut, TDerived>::revImp(
|
||||
savedOuts.insert(stpAmt.out);
|
||||
result = TAmounts<TIn, TOut>(sum(savedIns), sum(savedOuts));
|
||||
remainingOut = out - result.out;
|
||||
this->consumeOffer(sb, offer, ofrAmt, stpAmt, ownerGives);
|
||||
this->tryConsumeOffer(sb, offer, ofrAmt, stpAmt, ownerGives);
|
||||
// return true b/c even if the payment is satisfied,
|
||||
// we need to consume the offer. An offer limited by what the
|
||||
// issuer can issue is not consumed, though: its remainder is still
|
||||
@@ -1224,7 +1253,7 @@ BookStep<TIn, TOut, TDerived>::revImp(
|
||||
savedOuts.insert(remainingOut);
|
||||
result.in = sum(savedIns);
|
||||
result.out = out;
|
||||
this->consumeOffer(sb, offer, ofrAdjAmt, stpAdjAmt, ownerGivesAdj);
|
||||
this->tryConsumeOffer(sb, offer, ofrAdjAmt, stpAdjAmt, ownerGivesAdj);
|
||||
|
||||
// Explicitly check whether the offer is funded. Given that we have
|
||||
// (stpAmt.out > remainingOut), it's natural to assume the offer
|
||||
@@ -1408,7 +1437,7 @@ BookStep<TIn, TOut, TDerived>::fwdImp(
|
||||
savedOuts = std::move(savedOutsAdj);
|
||||
result = resultAdj;
|
||||
remainingIn = in - result.in;
|
||||
this->consumeOffer(sb, offer, ofrAdjAmt, stpAdjAmt, ownerGivesAdj);
|
||||
this->tryConsumeOffer(sb, offer, ofrAdjAmt, stpAdjAmt, ownerGivesAdj);
|
||||
|
||||
// When the mantissas of two iou amounts differ by less than ten, then
|
||||
// subtracting them leaves a result of zero. This can cause the check
|
||||
@@ -1512,6 +1541,18 @@ BookStep<TIn, TOut, TDerived>::check(StrandContext const& ctx) const
|
||||
return temBAD_PATH;
|
||||
}
|
||||
|
||||
// An issuer paying with its own MPT issues it into the first book. A
|
||||
// holder-sourced strand records the MPT in the first MPTEndpointStep and
|
||||
// so rejects a later book that outputs it again; do the same here. The
|
||||
// step after such a book issues the MPT a second time and the payment
|
||||
// engine cannot keep the two within MaximumAmount once StrandFlow
|
||||
// rebuilds the sandbox on a limiting step.
|
||||
if (ctx.isFirst && book_.in.holds<MPTIssue>() && book_.in.getIssuer() == ctx.strandSrc &&
|
||||
ctx.view.rules().enabled(featureMPTokensV2))
|
||||
{
|
||||
ctx.seenDirectAssets[0].insert(book_.in);
|
||||
}
|
||||
|
||||
// Do not allow two books to output the same issue. This may cause offers on
|
||||
// one step to unfund offers in another step.
|
||||
if (!ctx.seenBookOuts.insert(book_.out).second ||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/core/ServiceRegistry.h>
|
||||
#include <xrpl/ledger/PaymentSandbox.h>
|
||||
#include <xrpl/ledger/View.h>
|
||||
#include <xrpl/ledger/helpers/MPTokenHelpers.h>
|
||||
#include <xrpl/ledger/helpers/TokenHelpers.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
@@ -874,15 +875,18 @@ MPTEndpointStep<TDerived>::check(StrandContext const& ctx) const
|
||||
|
||||
// pure issue/redeem can't be frozen (issuer/holder)
|
||||
// For the first step: check global freeze of the step's own asset.
|
||||
// For the last step: check only the per-holder MPToken lock.
|
||||
// For the last step: check only the per-holder lock.
|
||||
// Global freeze of the deliver asset is not checked here
|
||||
// because MPT semantics allow issuer<->holder transfers even when globally
|
||||
// locked — only holder-to-holder DEX paths are restricted.
|
||||
// For both steps: a vault share inherits the freeze of the vault's
|
||||
// underlying asset.
|
||||
if (!(ctx.isLast && ctx.isFirst))
|
||||
{
|
||||
auto const& account = ctx.isFirst ? src_ : dst_;
|
||||
bool const frozen = (ctx.isFirst && isGlobalFrozen(ctx.view, mptIssue_)) ||
|
||||
isIndividualFrozen(ctx.view, account, mptIssue_);
|
||||
isIndividualFrozen(ctx.view, account, mptIssue_) ||
|
||||
isVaultPseudoAccountFrozen(ctx.view, account, mptIssue_, 0);
|
||||
if (frozen)
|
||||
return terLOCKED;
|
||||
}
|
||||
|
||||
@@ -110,11 +110,16 @@ EscrowCancel::doApply()
|
||||
auto const sle = ctx_.view().peek(keylet::account(account));
|
||||
STAmount const amount = escrow->getFieldAmount(sfAmount);
|
||||
|
||||
auto const reserveToSubtract = calculateAdditionalReserve((*escrow)[~sfBytecode]);
|
||||
|
||||
// The return can re-create a holding the owner deleted while the escrow
|
||||
// was pending; the removed escrow must not be counted against its reserve.
|
||||
bool const recycleReserve = ctx_.view().rules().enabled(fixCleanup3_4_0);
|
||||
if (recycleReserve)
|
||||
decreaseOwnerCountForObject(ctx_.view(), sle, escrow.mutableRawSle(), 1, ctx_.journal);
|
||||
{
|
||||
decreaseOwnerCountForObject(
|
||||
ctx_.view(), sle, escrow.mutableRawSle(), reserveToSubtract, ctx_.journal);
|
||||
}
|
||||
|
||||
// Transfer amount back to the owner
|
||||
if (isXRP(amount))
|
||||
@@ -160,7 +165,10 @@ EscrowCancel::doApply()
|
||||
}
|
||||
|
||||
if (!recycleReserve)
|
||||
decreaseOwnerCountForObject(ctx_.view(), sle, escrow.mutableRawSle(), 1, ctx_.journal);
|
||||
{
|
||||
decreaseOwnerCountForObject(
|
||||
ctx_.view(), sle, escrow.mutableRawSle(), reserveToSubtract, ctx_.journal);
|
||||
}
|
||||
|
||||
// Remove escrow from ledger
|
||||
escrow.erase();
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <xrpl/basics/chrono.h>
|
||||
#include <xrpl/beast/utility/Zero.h>
|
||||
#include <xrpl/conditions/Condition.h>
|
||||
#include <xrpl/core/ServiceRegistry.h>
|
||||
#include <xrpl/ledger/ApplyView.h>
|
||||
#include <xrpl/ledger/ReadView.h>
|
||||
#include <xrpl/ledger/View.h>
|
||||
#include <xrpl/ledger/entries/EscrowEntry.h>
|
||||
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/Concepts.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Fees.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
#include <xrpl/protocol/Keylet.h>
|
||||
@@ -130,6 +131,19 @@ escrowCreatePreflightHelper<MPTIssue>(PreflightContext const& ctx)
|
||||
return tesSUCCESS;
|
||||
}
|
||||
|
||||
XRPAmount
|
||||
EscrowCreate::calculateBaseFee(ReadView const& view, STTx const& tx)
|
||||
{
|
||||
XRPAmount txnFees{Transactor::calculateBaseFee(view, tx)};
|
||||
if (tx.isFieldPresent(sfBytecode))
|
||||
{
|
||||
// Ten base fees in all: `Transactor::calculateBaseFee` charges one,
|
||||
// this adds nine. Plus 5 drops per byte.
|
||||
txnFees += 9 * view.fees().base + 5 * tx[sfBytecode].size();
|
||||
}
|
||||
return txnFees;
|
||||
}
|
||||
|
||||
NotTEC
|
||||
EscrowCreate::preflight(PreflightContext const& ctx)
|
||||
{
|
||||
@@ -161,12 +175,19 @@ EscrowCreate::preflight(PreflightContext const& ctx)
|
||||
ctx.tx[sfCancelAfter] <= ctx.tx[sfFinishAfter])
|
||||
return temBAD_EXPIRATION;
|
||||
|
||||
if (ctx.tx.isFieldPresent(sfBytecode) && !ctx.tx.isFieldPresent(sfCancelAfter))
|
||||
return temBAD_EXPIRATION;
|
||||
|
||||
// In the absence of a FinishAfter, the escrow can be finished
|
||||
// immediately, which can be confusing. When creating an escrow,
|
||||
// we want to ensure that either a FinishAfter time is explicitly
|
||||
// specified or a completion condition is attached.
|
||||
if (!ctx.tx[~sfFinishAfter] && !ctx.tx[~sfCondition])
|
||||
if (!ctx.tx[~sfFinishAfter] && !ctx.tx[~sfCondition] && !ctx.tx[~sfBytecode])
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "Must have at least one of FinishAfter, "
|
||||
"Condition, or Bytecode.";
|
||||
return temMALFORMED;
|
||||
}
|
||||
|
||||
if (auto const cb = ctx.tx[~sfCondition])
|
||||
{
|
||||
@@ -182,6 +203,33 @@ EscrowCreate::preflight(PreflightContext const& ctx)
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx.tx.isFieldPresent(sfData))
|
||||
{
|
||||
if (!ctx.tx.isFieldPresent(sfBytecode))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "EscrowCreate with Data requires Bytecode";
|
||||
return temMALFORMED;
|
||||
}
|
||||
auto const data = ctx.tx.getFieldVL(sfData);
|
||||
if (data.size() > kMaxWasmDataLength)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "EscrowCreate.Data bad size " << data.size();
|
||||
return temMALFORMED;
|
||||
}
|
||||
}
|
||||
|
||||
// amendment was checked by checkExtraFeatures
|
||||
if (ctx.tx.isFieldPresent(sfBytecode))
|
||||
{
|
||||
auto const code = ctx.tx.getFieldVL(sfBytecode);
|
||||
// Protocol ceiling only; `preflight` has no view.
|
||||
if (code.empty() || code.size() > kMaxBytecodeSizeLimit)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "EscrowCreate.Bytecode bad size " << code.size();
|
||||
return temMALFORMED;
|
||||
}
|
||||
}
|
||||
|
||||
return tesSUCCESS;
|
||||
}
|
||||
|
||||
@@ -216,6 +264,30 @@ EscrowCreate::preclaim(PreclaimContext const& ctx)
|
||||
!isTesSuccess(ret))
|
||||
return ret;
|
||||
}
|
||||
|
||||
// The limits are voted, so they can change between ledgers. A `tef`, unlike
|
||||
// a `tem`, does not mark the transaction bad for the hold time.
|
||||
if (ctx.tx.isFieldPresent(sfBytecode))
|
||||
{
|
||||
auto const& fees = ctx.view.fees();
|
||||
if (isBytecodeUploadDisabled(fees))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "WASM runtime deactivated by fee voting";
|
||||
return tefTEMP_DISABLED;
|
||||
}
|
||||
|
||||
auto const code = ctx.tx.getFieldVL(sfBytecode);
|
||||
if (code.size() > fees.bytecodeSizeLimit)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "EscrowCreate.Bytecode over voted limit " << code.size();
|
||||
return tefEXCEEDS_LIMIT;
|
||||
}
|
||||
|
||||
// TODO(SmartEscrow): screen the module itself here - that it compiles,
|
||||
// and that it imports and exports what the engine can serve - once the
|
||||
// WASM engine lands. Until then any blob of the right size is taken.
|
||||
}
|
||||
|
||||
return tesSUCCESS;
|
||||
}
|
||||
|
||||
@@ -236,6 +308,7 @@ EscrowCreate::doApply()
|
||||
|
||||
// Check reserve and funds availability
|
||||
STAmount const amount{ctx_.tx[sfAmount]};
|
||||
auto const reserveToAdd = calculateAdditionalReserve(ctx_.tx[~sfBytecode]);
|
||||
|
||||
auto const balance = sle->getFieldAmount(sfBalance).xrp();
|
||||
// First check: whoever is on the hook for the new owner increment
|
||||
@@ -243,8 +316,8 @@ EscrowCreate::doApply()
|
||||
// validates the sponsor's reserve + remaining credit. When
|
||||
// unsponsored this hits the source branch and validates the
|
||||
// source's pre-lock balance against base + (currentOC+1)*increment.
|
||||
if (auto const ret =
|
||||
checkReserve(ctx_.getApplyViewContext(), sle, balance, {.ownerCountDelta = 1}, j_);
|
||||
if (auto const ret = checkReserve(
|
||||
ctx_.getApplyViewContext(), sle, balance, {.ownerCountDelta = reserveToAdd}, j_);
|
||||
!isTesSuccess(ret))
|
||||
return ret;
|
||||
|
||||
@@ -258,11 +331,15 @@ EscrowCreate::doApply()
|
||||
// checkReserve) because that helper diverts to the sponsor's balance
|
||||
// when a sponsor is present and would ignore the source's post-lock
|
||||
// balance entirely. ownerCountDelta differs by case:
|
||||
// - sponsored: 0 — sponsor covers the new owner increment, so the
|
||||
// source only owes reserve for its current owners.
|
||||
// - unsponsored: 1 — source owes reserve including the new increment.
|
||||
// - sponsored: 0 — sponsor covers the new owner increment, so
|
||||
// the source only owes reserve for its current owners.
|
||||
// - unsponsored: reserveToAdd — source owes reserve including the new
|
||||
// increment, which Bytecode can make larger than one unit.
|
||||
auto const sourceReserve = accountReserve(
|
||||
ctx_.view(), sle, j_, {.ownerCountDelta = getTxReserveSponsorID(ctx_.tx) ? 0 : 1});
|
||||
ctx_.view(),
|
||||
sle,
|
||||
j_,
|
||||
{.ownerCountDelta = getTxReserveSponsorID(ctx_.tx) ? 0 : reserveToAdd});
|
||||
if (balance - STAmount(amount).xrp() < sourceReserve)
|
||||
return tecUNFUNDED;
|
||||
}
|
||||
@@ -289,6 +366,8 @@ EscrowCreate::doApply()
|
||||
(*escrow)[~sfCancelAfter] = ctx_.tx[~sfCancelAfter];
|
||||
(*escrow)[~sfFinishAfter] = ctx_.tx[~sfFinishAfter];
|
||||
(*escrow)[~sfDestinationTag] = ctx_.tx[~sfDestinationTag];
|
||||
(*escrow)[~sfBytecode] = ctx_.tx[~sfBytecode];
|
||||
(*escrow)[~sfData] = ctx_.tx[~sfData];
|
||||
|
||||
if (ctx_.view().rules().enabled(fixIncludeKeyletFields))
|
||||
{
|
||||
@@ -356,7 +435,7 @@ EscrowCreate::doApply()
|
||||
}
|
||||
|
||||
// increment owner count
|
||||
increaseOwnerCount(ctx_.getApplyViewContext(), sle, 1, ctx_.journal);
|
||||
increaseOwnerCount(ctx_.getApplyViewContext(), sle, reserveToAdd, ctx_.journal);
|
||||
addSponsorToLedgerEntry(ctx_.getApplyViewContext(), escrow.mutableRawSle());
|
||||
ctx_.view().update(sle);
|
||||
return tesSUCCESS;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/Concepts.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Fees.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Rate.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
@@ -27,6 +28,8 @@
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
#include <xrpl/tx/Transactor.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <system_error>
|
||||
#include <variant>
|
||||
|
||||
@@ -79,7 +82,24 @@ EscrowFinish::preflight(PreflightContext const& ctx)
|
||||
// If you specify a condition, then you must also specify
|
||||
// a fulfillment.
|
||||
if (static_cast<bool>(cb) != static_cast<bool>(fb))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "Condition != Fulfillment";
|
||||
return temMALFORMED;
|
||||
}
|
||||
|
||||
if (auto const allowance = ctx.tx[~sfGas]; allowance)
|
||||
{
|
||||
// Protocol ceiling only; `preflight` has no view.
|
||||
if (*allowance == 0)
|
||||
{
|
||||
return temBAD_LIMIT;
|
||||
}
|
||||
if (*allowance > kMaxGasLimit)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "Gas too large: " << *allowance;
|
||||
return temBAD_LIMIT;
|
||||
}
|
||||
}
|
||||
|
||||
return tesSUCCESS;
|
||||
}
|
||||
@@ -148,7 +168,15 @@ EscrowFinish::calculateBaseFee(ReadView const& view, STTx const& tx)
|
||||
{
|
||||
extraFee += view.fees().base * (32 + (fb->size() / 16));
|
||||
}
|
||||
|
||||
if (auto const allowance = tx[~sfGas]; allowance)
|
||||
{
|
||||
// The extra fee is the allowance in drops, rounded up to the nearest
|
||||
// whole drop. Widen before multiplying: both factors are 32-bit.
|
||||
std::uint64_t const allowanceFee =
|
||||
((std::uint64_t{*allowance} * view.fees().gasPrice) + microDropsPerDrop - 1) /
|
||||
microDropsPerDrop;
|
||||
extraFee += allowanceFee;
|
||||
}
|
||||
return Transactor::calculateBaseFee(view, tx) + extraFee;
|
||||
}
|
||||
|
||||
@@ -162,25 +190,66 @@ EscrowFinish::preclaim(PreclaimContext const& ctx)
|
||||
return err;
|
||||
}
|
||||
|
||||
if (ctx.view.rules().enabled(featureTokenEscrow))
|
||||
if (ctx.view.rules().enabled(featureTokenEscrow) ||
|
||||
ctx.view.rules().enabled(featureSmartEscrow))
|
||||
{
|
||||
// this check is done in doApply before this amendment is enabled
|
||||
auto const seqProxy = SeqProxy::rawSequence(ctx.tx[sfOfferSequence]);
|
||||
EscrowEntryR const escrow(ctx.tx[sfOwner], seqProxy, ctx.view);
|
||||
if (!escrow)
|
||||
return tecNO_TARGET;
|
||||
|
||||
AccountID const dest = (*escrow)[sfDestination];
|
||||
STAmount const amount = (*escrow)[sfAmount];
|
||||
|
||||
if (!isXRP(amount))
|
||||
if (ctx.view.rules().enabled(featureSmartEscrow))
|
||||
{
|
||||
if (auto const ret = std::visit(
|
||||
[&]<typename T>(T const&) {
|
||||
return escrowUnlockPreclaimHelper<T>(ctx.view, dest, amount);
|
||||
},
|
||||
amount.asset().value());
|
||||
!isTesSuccess(ret))
|
||||
return ret;
|
||||
if (escrow->isFieldPresent(sfBytecode))
|
||||
{
|
||||
if (!ctx.tx.isFieldPresent(sfGas))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "Bytecode requires Gas";
|
||||
return tefBYTECODE_NOT_INCLUDED;
|
||||
}
|
||||
|
||||
// The limits are voted, so they can change between ledgers.
|
||||
// A `tef`, unlike a `tem`, does not mark the transaction bad
|
||||
// for the hold time.
|
||||
auto const& fees = ctx.view.fees();
|
||||
if (isBytecodeExecutionDisabled(fees))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "WASM runtime deactivated by fee voting";
|
||||
return tefTEMP_DISABLED;
|
||||
}
|
||||
|
||||
if (ctx.tx[sfGas] > fees.gasLimit)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "Gas over voted limit: " << ctx.tx[sfGas];
|
||||
return tefEXCEEDS_LIMIT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ctx.tx.isFieldPresent(sfGas))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "Bytecode not present, "
|
||||
"Gas present";
|
||||
return tefNO_BYTECODE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ctx.view.rules().enabled(featureTokenEscrow))
|
||||
{
|
||||
AccountID const dest = (*escrow)[sfDestination];
|
||||
STAmount const amount = (*escrow)[sfAmount];
|
||||
|
||||
if (!isXRP(amount))
|
||||
{
|
||||
if (auto const ret = std::visit(
|
||||
[&]<typename T>(T const&) {
|
||||
return escrowUnlockPreclaimHelper<T>(ctx.view, dest, amount);
|
||||
},
|
||||
amount.asset().value());
|
||||
!isTesSuccess(ret))
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return tesSUCCESS;
|
||||
@@ -193,7 +262,8 @@ EscrowFinish::doApply()
|
||||
EscrowEntryW escrow(ctx_.tx[sfOwner], seqProxy, ctx_.view(), j_);
|
||||
if (!escrow)
|
||||
{
|
||||
if (ctx_.view().rules().enabled(featureTokenEscrow))
|
||||
if (ctx_.view().rules().enabled(featureTokenEscrow) ||
|
||||
ctx_.view().rules().enabled(featureSmartEscrow))
|
||||
return tecINTERNAL; // LCOV_EXCL_LINE
|
||||
|
||||
return tecNO_TARGET;
|
||||
@@ -211,6 +281,20 @@ EscrowFinish::doApply()
|
||||
if ((*escrow)[~sfCancelAfter] && after(now, (*escrow)[sfCancelAfter]))
|
||||
return tecNO_PERMISSION;
|
||||
|
||||
AccountID const destID = (*escrow)[sfDestination];
|
||||
auto const sled = ctx_.view().peek(keylet::account(destID));
|
||||
if (ctx_.view().rules().enabled(featureSmartEscrow))
|
||||
{
|
||||
// NOTE: Escrow payments cannot be used to fund accounts.
|
||||
if (!sled)
|
||||
return tecNO_DST;
|
||||
|
||||
if (auto err =
|
||||
verifyDepositPreauth(ctx_.tx, ctx_.view(), accountID_, destID, sled, ctx_.journal);
|
||||
!isTesSuccess(err))
|
||||
return err;
|
||||
}
|
||||
|
||||
// Check cryptocondition fulfillment
|
||||
{
|
||||
auto const id = ctx_.tx.getTransactionID();
|
||||
@@ -264,16 +348,33 @@ EscrowFinish::doApply()
|
||||
return tecCRYPTOCONDITION_ERROR;
|
||||
}
|
||||
|
||||
// NOTE: Escrow payments cannot be used to fund accounts.
|
||||
AccountID const destID = (*escrow)[sfDestination];
|
||||
auto const sled = ctx_.view().peek(keylet::account(destID));
|
||||
if (!sled)
|
||||
return tecNO_DST;
|
||||
if (!ctx_.view().rules().enabled(featureSmartEscrow))
|
||||
{
|
||||
// NOTE: Escrow payments cannot be used to fund accounts.
|
||||
if (!sled)
|
||||
return tecNO_DST;
|
||||
|
||||
if (auto err =
|
||||
verifyDepositPreauth(ctx_.tx, ctx_.view(), accountID_, destID, sled, ctx_.journal);
|
||||
!isTesSuccess(err))
|
||||
return err;
|
||||
if (auto err =
|
||||
verifyDepositPreauth(ctx_.tx, ctx_.view(), accountID_, destID, sled, ctx_.journal);
|
||||
!isTesSuccess(err))
|
||||
return err;
|
||||
}
|
||||
|
||||
// Execute custom release function
|
||||
if ((*escrow)[~sfBytecode])
|
||||
{
|
||||
// TODO(SmartEscrow): run the escrow's contract here once the WASM
|
||||
// engine lands. That change also brings with it the reporting the run
|
||||
// produces - the gas it consumed and the code it returned, in the
|
||||
// transaction metadata - and the tecBYTECODE_REJECTED result that lets
|
||||
// a rejected escrow survive with the data the contract wrote.
|
||||
//
|
||||
// Until then an escrow carrying bytecode can be created, funded and
|
||||
// cancelled, but not finished. Reachable only under featureSmartEscrow,
|
||||
// which is Supported::No.
|
||||
JLOG(j_.debug()) << "EscrowFinish: no WASM engine to run the escrow's bytecode";
|
||||
return tecFAILED_PROCESSING;
|
||||
}
|
||||
|
||||
AccountID const account = (*escrow)[sfAccount];
|
||||
|
||||
@@ -301,13 +402,18 @@ EscrowFinish::doApply()
|
||||
}
|
||||
}
|
||||
|
||||
auto const reserveToSubtract = calculateAdditionalReserve((*escrow)[~sfBytecode]);
|
||||
|
||||
// Delivery can auto-create the destination's holding; the removed escrow
|
||||
// must not be counted against its reserve. The two share a reserve payer
|
||||
// for a self-escrow, or when one sponsor covers both.
|
||||
bool const recycleReserve =
|
||||
ctx_.view().rules().enabled(featureSponsor) || ctx_.view().rules().enabled(fixCleanup3_4_0);
|
||||
if (recycleReserve)
|
||||
decreaseOwnerCountForObject(ctx_.view(), account, escrow.mutableRawSle(), 1, ctx_.journal);
|
||||
{
|
||||
decreaseOwnerCountForObject(
|
||||
ctx_.view(), account, escrow.mutableRawSle(), reserveToSubtract, ctx_.journal);
|
||||
}
|
||||
|
||||
STAmount const amount = escrow->getFieldAmount(sfAmount);
|
||||
// Transfer amount to destination
|
||||
@@ -359,7 +465,10 @@ EscrowFinish::doApply()
|
||||
ctx_.view().update(sled);
|
||||
|
||||
if (!recycleReserve)
|
||||
decreaseOwnerCountForObject(ctx_.view(), account, escrow.mutableRawSle(), 1, ctx_.journal);
|
||||
{
|
||||
decreaseOwnerCountForObject(
|
||||
ctx_.view(), account, escrow.mutableRawSle(), reserveToSubtract, ctx_.journal);
|
||||
}
|
||||
|
||||
// Remove escrow from ledger
|
||||
escrow.erase();
|
||||
|
||||
@@ -37,7 +37,7 @@ TransactionProposalCancel::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
// Never read the zero keylet. Preflight already rejected a zero
|
||||
// ProposalID, and no real proposal can have one (every ProposalID is a
|
||||
// hash), so reaching here with zero is an internal error. (and a mathematical rarity. )
|
||||
// hash), so reaching here with zero is an internal error (and a mathematical rarity).
|
||||
if (proposalID == beast::kZero)
|
||||
return tefINTERNAL; // LCOV_EXCL_LINE
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/ledger/ReadView.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
@@ -894,8 +895,9 @@ public:
|
||||
auto const jNoCred = credentials::ledgerEntry(env, becky, carol, credType);
|
||||
BEAST_EXPECT(
|
||||
jNoCred.isObject() && jNoCred.isMember(jss::result) &&
|
||||
jNoCred[jss::result].isMember(jss::error) &&
|
||||
jNoCred[jss::result][jss::error] == "entryNotFound");
|
||||
jNoCred[jss::result][jss::error] == "entryNotFound" &&
|
||||
jNoCred[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jNoCred[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
|
||||
testcase("Credentials that aren't required");
|
||||
@@ -918,8 +920,9 @@ public:
|
||||
|
||||
BEAST_EXPECT(
|
||||
jNoCred.isObject() && jNoCred.isMember(jss::result) &&
|
||||
jNoCred[jss::result].isMember(jss::error) &&
|
||||
jNoCred[jss::result][jss::error] == "entryNotFound");
|
||||
jNoCred[jss::result][jss::error] == "entryNotFound" &&
|
||||
jNoCred[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jNoCred[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -957,8 +960,9 @@ public:
|
||||
|
||||
BEAST_EXPECT(
|
||||
jNoCred.isObject() && jNoCred.isMember(jss::result) &&
|
||||
jNoCred[jss::result].isMember(jss::error) &&
|
||||
jNoCred[jss::result][jss::error] == "entryNotFound");
|
||||
jNoCred[jss::result][jss::error] == "entryNotFound" &&
|
||||
jNoCred[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jNoCred[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
|
||||
testcase("Expired credentials");
|
||||
@@ -994,8 +998,9 @@ public:
|
||||
auto jv = credentials::ledgerEntry(env, john, carol, credType);
|
||||
BEAST_EXPECT(
|
||||
jv.isObject() && jv.isMember(jss::result) &&
|
||||
jv[jss::result].isMember(jss::error) &&
|
||||
jv[jss::result][jss::error] == "entryNotFound");
|
||||
jv[jss::result][jss::error] == "entryNotFound" &&
|
||||
jv[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jv[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1079,8 +1084,9 @@ public:
|
||||
auto const jv = credentials::ledgerEntry(env, becky, carol, credType);
|
||||
BEAST_EXPECT(
|
||||
jv.isObject() && jv.isMember(jss::result) &&
|
||||
jv[jss::result].isMember(jss::error) &&
|
||||
jv[jss::result][jss::error] == "entryNotFound");
|
||||
jv[jss::result][jss::error] == "entryNotFound" &&
|
||||
jv[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jv[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1121,8 +1127,9 @@ public:
|
||||
auto const jv = credentials::ledgerEntry(env, becky, carol, credType);
|
||||
BEAST_EXPECT(
|
||||
jv.isObject() && jv.isMember(jss::result) &&
|
||||
jv[jss::result].isMember(jss::error) &&
|
||||
jv[jss::result][jss::error] == "entryNotFound");
|
||||
jv[jss::result][jss::error] == "entryNotFound" &&
|
||||
jv[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jv[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <xrpl/ledger/OpenView.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/Batch.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
@@ -2800,6 +2801,7 @@ class Batch_test : public beast::unit_test::Suite
|
||||
auto const jrr = env.rpc("submit", strHex(slice))[jss::result];
|
||||
expect(
|
||||
jrr[jss::status] == "error" && jrr[jss::error] == "invalidTransaction" &&
|
||||
!jrr.isMember(jss::error_code) && jrr[jss::error_message].isNull() &&
|
||||
jrr[jss::error_exception] ==
|
||||
"fails local checks: Batch inner transactions are never "
|
||||
"considered validly signed.",
|
||||
@@ -5407,7 +5409,10 @@ class Batch_test : public beast::unit_test::Suite
|
||||
|
||||
// The delegated payment never applied.
|
||||
BEAST_EXPECT(env.balance(mallory) == preMallory);
|
||||
BEAST_EXPECT(env.rpc("tx", txIDs[1])[jss::result][jss::error] == "txnNotFound");
|
||||
auto const txResult = env.rpc("tx", txIDs[1])[jss::result];
|
||||
BEAST_EXPECT(txResult[jss::error] == "txnNotFound");
|
||||
BEAST_EXPECT(txResult[jss::error_code] == RpcTxnNotFound);
|
||||
BEAST_EXPECT(txResult[jss::error_message] == "Transaction not found.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5818,7 +5823,10 @@ class Batch_test : public beast::unit_test::Suite
|
||||
validateClosedLedger(env, testCases);
|
||||
|
||||
// verify jv2 is not present in the closed ledger.
|
||||
BEAST_EXPECT(env.rpc("tx", txIDs[1])[jss::result][jss::error] == "txnNotFound");
|
||||
auto const txResult = env.rpc("tx", txIDs[1])[jss::result];
|
||||
BEAST_EXPECT(txResult[jss::error] == "txnNotFound");
|
||||
BEAST_EXPECT(txResult[jss::error_code] == RpcTxnNotFound);
|
||||
BEAST_EXPECT(txResult[jss::error_message] == "Transaction not found.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <test/jtx/Account.h>
|
||||
#include <test/jtx/CaptureLogs.h>
|
||||
#include <test/jtx/Env.h>
|
||||
#include <test/jtx/TestHelpers.h>
|
||||
#include <test/jtx/amount.h>
|
||||
@@ -14,13 +15,17 @@
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
#include <xrpl/protocol/LedgerFormats.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STAmount.h>
|
||||
#include <xrpl/protocol/TER.h>
|
||||
#include <xrpl/protocol/TxFlags.h>
|
||||
#include <xrpl/protocol/UintTypes.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
@@ -803,6 +808,108 @@ class Clawback_test : public beast::unit_test::Suite
|
||||
BEAST_EXPECT(ownerCount(env, bob) == 0);
|
||||
}
|
||||
|
||||
void
|
||||
testSubResolutionAmount(FeatureBitset features)
|
||||
{
|
||||
testcase("Sub-resolution amount");
|
||||
using namespace test::jtx;
|
||||
|
||||
// IOU balances keep 16 significant digits. When alice claws back an
|
||||
// amount much smaller than bob's balance, the balance changes by the
|
||||
// rounded amount, which can be zero, less, or more than requested. The
|
||||
// clawback invariant must accept that instead of failing the
|
||||
// transaction under MPTokensV2 or logging a failure without it.
|
||||
Account const alice{"alice"};
|
||||
Account const bob{"bob"};
|
||||
|
||||
struct Case
|
||||
{
|
||||
std::uint64_t balanceMantissa;
|
||||
int balanceExponent;
|
||||
std::uint64_t clawMantissa;
|
||||
int clawExponent;
|
||||
std::uint64_t afterMantissa;
|
||||
int afterExponent;
|
||||
};
|
||||
std::array const cases{
|
||||
// 1e7 - 1e-10 rounds back to 1e7
|
||||
Case{
|
||||
.balanceMantissa = 10'000'000,
|
||||
.balanceExponent = 0,
|
||||
.clawMantissa = 1,
|
||||
.clawExponent = -10,
|
||||
.afterMantissa = 10'000'000,
|
||||
.afterExponent = 0,
|
||||
},
|
||||
// 1234567890.123456 - 0.0000005 rounds back to the balance
|
||||
Case{
|
||||
.balanceMantissa = 1'234'567'890'123'456,
|
||||
.balanceExponent = -6,
|
||||
.clawMantissa = 5,
|
||||
.clawExponent = -7,
|
||||
.afterMantissa = 1'234'567'890'123'456,
|
||||
.afterExponent = -6,
|
||||
},
|
||||
// 0.0000014 removes 0.000001
|
||||
Case{
|
||||
.balanceMantissa = 1'234'567'890'123'456,
|
||||
.balanceExponent = -6,
|
||||
.clawMantissa = 14,
|
||||
.clawExponent = -7,
|
||||
.afterMantissa = 1'234'567'890'123'455,
|
||||
.afterExponent = -6,
|
||||
},
|
||||
// 0.0000016 removes 0.000002
|
||||
Case{
|
||||
.balanceMantissa = 1'234'567'890'123'456,
|
||||
.balanceExponent = -6,
|
||||
.clawMantissa = 16,
|
||||
.clawExponent = -7,
|
||||
.afterMantissa = 1'234'567'890'123'454,
|
||||
.afterExponent = -6,
|
||||
},
|
||||
};
|
||||
|
||||
for (auto const feat : {features, features - featureMPTokensV2})
|
||||
{
|
||||
for (auto const& c : cases)
|
||||
{
|
||||
std::string logs;
|
||||
{
|
||||
Env env(*this, feat, std::make_unique<test::CaptureLogs>(&logs));
|
||||
|
||||
env.fund(XRP(1000), alice, bob);
|
||||
env.close();
|
||||
|
||||
auto const usd = alice["USD"];
|
||||
|
||||
env(fset(alice, asfAllowTrustLineClawback));
|
||||
env.close();
|
||||
|
||||
env.trust(usd(10'000'000'000), bob);
|
||||
env(pay(
|
||||
alice, bob, STAmount{usd.issue(), c.balanceMantissa, c.balanceExponent}));
|
||||
env.close();
|
||||
|
||||
env(claw(
|
||||
alice,
|
||||
STAmount{
|
||||
Issue{usd.currency, bob.id()}, c.clawMantissa, c.clawExponent}),
|
||||
Ter(tesSUCCESS));
|
||||
env.close();
|
||||
|
||||
BEAST_EXPECT(
|
||||
env.balance(bob, usd).value() ==
|
||||
STAmount(usd.issue(), c.afterMantissa, c.afterExponent));
|
||||
}
|
||||
// Without MPTokensV2 a failed invariant only logs and the
|
||||
// transaction still succeeds, so check the logs instead.
|
||||
if (!feat[featureMPTokensV2])
|
||||
BEAST_EXPECT(!logs.contains("Invariant failed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testTickets(FeatureBitset features)
|
||||
{
|
||||
@@ -872,6 +979,7 @@ class Clawback_test : public beast::unit_test::Suite
|
||||
testDeleteDefaultLine(features);
|
||||
testFrozenLine(features);
|
||||
testAmountExceedsAvailable(features);
|
||||
testSubResolutionAmount(features);
|
||||
testTickets(features);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/protocol/ConfidentialTransfer.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Protocol.h>
|
||||
@@ -259,8 +260,9 @@ class ConfidentialTransferExtended_test : public ConfidentialTransferTestBase
|
||||
|
||||
auto const credentialDeleted = [&](Env& env, Account const& subject) -> bool {
|
||||
auto const credentials = credentials::ledgerEntry(env, subject, dpIssuer, credType);
|
||||
return credentials[jss::result].isMember(jss::error) &&
|
||||
credentials[jss::result][jss::error] == "entryNotFound";
|
||||
return credentials[jss::result][jss::error] == "entryNotFound" &&
|
||||
credentials[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
credentials[jss::result][jss::error_message] == "Entry not found.";
|
||||
};
|
||||
|
||||
// TEST 4: Expired credential with matching depositPreauth entry.
|
||||
|
||||
@@ -7944,6 +7944,8 @@ class ConfidentialTransfer_test : public ConfidentialTransferTestBase
|
||||
// Signature verification fails — rejected before ZKP check
|
||||
auto const jr = env.rpc("submit", strHex(tampered.slice()));
|
||||
BEAST_EXPECT(jr[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!jr[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(jr[jss::result][jss::error_message].isNull());
|
||||
}
|
||||
|
||||
// Variant B: Re-signed with inflated ciphertext.
|
||||
@@ -8051,6 +8053,8 @@ class ConfidentialTransfer_test : public ConfidentialTransferTestBase
|
||||
|
||||
auto const jr = env.rpc("submit", strHex(tampered.slice()));
|
||||
BEAST_EXPECT(jr[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!jr[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(jr[jss::result][jss::error_message].isNull());
|
||||
}
|
||||
|
||||
// Variant B: Re-signed with all negated ciphertexts.
|
||||
@@ -8154,6 +8158,8 @@ class ConfidentialTransfer_test : public ConfidentialTransferTestBase
|
||||
|
||||
auto const jr = env.rpc("submit", strHex(tampered.slice()));
|
||||
BEAST_EXPECT(jr[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!jr[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(jr[jss::result][jss::error_message].isNull());
|
||||
}
|
||||
|
||||
// Variant B: Re-signed with combined ciphertext.
|
||||
@@ -8278,6 +8284,8 @@ class ConfidentialTransfer_test : public ConfidentialTransferTestBase
|
||||
// Signature verification fails
|
||||
auto const jr = env.rpc("submit", strHex(tampered.slice()));
|
||||
BEAST_EXPECT(jr[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!jr[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(jr[jss::result][jss::error_message].isNull());
|
||||
}
|
||||
|
||||
// Variant B: Re-signed C1 substitution.
|
||||
@@ -8368,6 +8376,8 @@ class ConfidentialTransfer_test : public ConfidentialTransferTestBase
|
||||
// signed — transaction rejected before ZKP verification.
|
||||
auto const jr = env.rpc("submit", strHex(tampered.slice()));
|
||||
BEAST_EXPECT(jr[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!jr[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(jr[jss::result][jss::error_message].isNull());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <xrpl/ledger/ApplyViewImpl.h>
|
||||
#include <xrpl/ledger/helpers/CredentialHelpers.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
@@ -124,8 +125,9 @@ struct Credentials_test : public beast::unit_test::Suite
|
||||
auto const jle = credentials::ledgerEntry(env, subject, issuer, credType);
|
||||
BEAST_EXPECT(
|
||||
jle.isObject() && jle.isMember(jss::result) &&
|
||||
jle[jss::result].isMember(jss::error) &&
|
||||
jle[jss::result][jss::error] == "entryNotFound");
|
||||
jle[jss::result][jss::error] == "entryNotFound" &&
|
||||
jle[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jle[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,8 +175,9 @@ struct Credentials_test : public beast::unit_test::Suite
|
||||
auto const jle = credentials::ledgerEntry(env, issuer, issuer, credType);
|
||||
BEAST_EXPECT(
|
||||
jle.isObject() && jle.isMember(jss::result) &&
|
||||
jle[jss::result].isMember(jss::error) &&
|
||||
jle[jss::result][jss::error] == "entryNotFound");
|
||||
jle[jss::result][jss::error] == "entryNotFound" &&
|
||||
jle[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jle[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -222,8 +225,9 @@ struct Credentials_test : public beast::unit_test::Suite
|
||||
auto const jle = credentials::ledgerEntry(env, subject, issuer, credType);
|
||||
BEAST_EXPECT(
|
||||
jle.isObject() && jle.isMember(jss::result) &&
|
||||
jle[jss::result].isMember(jss::error) &&
|
||||
jle[jss::result][jss::error] == "entryNotFound");
|
||||
jle[jss::result][jss::error] == "entryNotFound" &&
|
||||
jle[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jle[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
|
||||
// resurrection
|
||||
@@ -259,8 +263,9 @@ struct Credentials_test : public beast::unit_test::Suite
|
||||
auto const jle = credentials::ledgerEntry(env, subject, issuer, credType);
|
||||
BEAST_EXPECT(
|
||||
jle.isObject() && jle.isMember(jss::result) &&
|
||||
jle[jss::result].isMember(jss::error) &&
|
||||
jle[jss::result][jss::error] == "entryNotFound");
|
||||
jle[jss::result][jss::error] == "entryNotFound" &&
|
||||
jle[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jle[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
|
||||
// resurrection
|
||||
@@ -294,8 +299,9 @@ struct Credentials_test : public beast::unit_test::Suite
|
||||
auto const jle = credentials::ledgerEntry(env, subject, issuer, credType);
|
||||
BEAST_EXPECT(
|
||||
jle.isObject() && jle.isMember(jss::result) &&
|
||||
jle[jss::result].isMember(jss::error) &&
|
||||
jle[jss::result][jss::error] == "entryNotFound");
|
||||
jle[jss::result][jss::error] == "entryNotFound" &&
|
||||
jle[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jle[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
|
||||
// resurrection
|
||||
@@ -331,8 +337,9 @@ struct Credentials_test : public beast::unit_test::Suite
|
||||
auto const jle = credentials::ledgerEntry(env, subject, issuer, credType);
|
||||
BEAST_EXPECT(
|
||||
jle.isObject() && jle.isMember(jss::result) &&
|
||||
jle[jss::result].isMember(jss::error) &&
|
||||
jle[jss::result][jss::error] == "entryNotFound");
|
||||
jle[jss::result][jss::error] == "entryNotFound" &&
|
||||
jle[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jle[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
|
||||
// resurrection
|
||||
@@ -368,8 +375,9 @@ struct Credentials_test : public beast::unit_test::Suite
|
||||
auto const jle = credentials::ledgerEntry(env, subject, issuer, credType);
|
||||
BEAST_EXPECT(
|
||||
jle.isObject() && jle.isMember(jss::result) &&
|
||||
jle[jss::result].isMember(jss::error) &&
|
||||
jle[jss::result][jss::error] == "entryNotFound");
|
||||
jle[jss::result][jss::error] == "entryNotFound" &&
|
||||
jle[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jle[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,8 +398,9 @@ struct Credentials_test : public beast::unit_test::Suite
|
||||
auto const jle = credentials::ledgerEntry(env, subject, issuer, credType);
|
||||
BEAST_EXPECT(
|
||||
jle.isObject() && jle.isMember(jss::result) &&
|
||||
jle[jss::result].isMember(jss::error) &&
|
||||
jle[jss::result][jss::error] == "entryNotFound");
|
||||
jle[jss::result][jss::error] == "entryNotFound" &&
|
||||
jle[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jle[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,8 +419,9 @@ struct Credentials_test : public beast::unit_test::Suite
|
||||
auto const jle = credentials::ledgerEntry(env, subject, issuer, credType);
|
||||
BEAST_EXPECT(
|
||||
jle.isObject() && jle.isMember(jss::result) &&
|
||||
jle[jss::result].isMember(jss::error) &&
|
||||
jle[jss::result][jss::error] == "entryNotFound");
|
||||
jle[jss::result][jss::error] == "entryNotFound" &&
|
||||
jle[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jle[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -744,8 +754,9 @@ struct Credentials_test : public beast::unit_test::Suite
|
||||
auto const jDelCred = credentials::ledgerEntry(env, subject, issuer, credType2);
|
||||
BEAST_EXPECT(
|
||||
jDelCred.isObject() && jDelCred.isMember(jss::result) &&
|
||||
jDelCred[jss::result].isMember(jss::error) &&
|
||||
jDelCred[jss::result][jss::error] == "entryNotFound");
|
||||
jDelCred[jss::result][jss::error] == "entryNotFound" &&
|
||||
jDelCred[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jDelCred[jss::result][jss::error_message] == "Entry not found.");
|
||||
|
||||
BEAST_EXPECT(ownerCount(env, issuer) == 0);
|
||||
BEAST_EXPECT(ownerCount(env, subject) == 1);
|
||||
@@ -781,8 +792,9 @@ struct Credentials_test : public beast::unit_test::Suite
|
||||
auto const jDelCred = credentials::ledgerEntry(env, subject, issuer, credType);
|
||||
BEAST_EXPECT(
|
||||
jDelCred.isObject() && jDelCred.isMember(jss::result) &&
|
||||
jDelCred[jss::result].isMember(jss::error) &&
|
||||
jDelCred[jss::result][jss::error] == "entryNotFound");
|
||||
jDelCred[jss::result][jss::error] == "entryNotFound" &&
|
||||
jDelCred[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jDelCred[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/ledger/Dir.h>
|
||||
#include <xrpl/ledger/helpers/DelegateHelpers.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
@@ -159,6 +160,8 @@ class Delegate_test : public beast::unit_test::Suite
|
||||
env.close();
|
||||
auto const jle = delegate::entry(env, gw, alice);
|
||||
BEAST_EXPECT(jle[jss::result][jss::error] == "entryNotFound");
|
||||
BEAST_EXPECT(jle[jss::result][jss::error_code] == RpcEntryNotFound);
|
||||
BEAST_EXPECT(jle[jss::result][jss::error_message] == "Entry not found.");
|
||||
|
||||
// alice can delegate permissions to gw as well
|
||||
env(delegate::set(alice, gw, permissions));
|
||||
@@ -167,6 +170,8 @@ class Delegate_test : public beast::unit_test::Suite
|
||||
auto const response = delegate::entry(env, gw, alice);
|
||||
// alice has not been granted any permissions by gw
|
||||
BEAST_EXPECT(response[jss::result][jss::error] == "entryNotFound");
|
||||
BEAST_EXPECT(response[jss::result][jss::error_code] == RpcEntryNotFound);
|
||||
BEAST_EXPECT(response[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2780,9 +2785,11 @@ class Delegate_test : public beast::unit_test::Suite
|
||||
jv[jss::secret] = bob.name();
|
||||
auto jrr = env.rpc("json", "sign_for", to_string(jv))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message].asString().contains(
|
||||
"A Signer may not be the transaction's Account"));
|
||||
jrr[jss::error_message] ==
|
||||
"A Signer may not be the transaction's Account (" + bob.human() + ").");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
#include <xrpl/protocol/LedgerFormats.h>
|
||||
@@ -1143,8 +1144,9 @@ struct DepositPreauth_test : public beast::unit_test::Suite
|
||||
ledgerEntryDepositPreauth(env, bob, {{.issuer = issuer, .credType = credType}});
|
||||
BEAST_EXPECT(
|
||||
jDP.isObject() && jDP.isMember(jss::result) &&
|
||||
jDP[jss::result].isMember(jss::error) &&
|
||||
jDP[jss::result][jss::error] == "entryNotFound");
|
||||
jDP[jss::result][jss::error] == "entryNotFound" &&
|
||||
jDP[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jDP[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1232,8 +1234,9 @@ struct DepositPreauth_test : public beast::unit_test::Suite
|
||||
auto const jDelCred = credentials::ledgerEntry(env, alice, issuer, credType);
|
||||
BEAST_EXPECT(
|
||||
jDelCred.isObject() && jDelCred.isMember(jss::result) &&
|
||||
jDelCred[jss::result].isMember(jss::error) &&
|
||||
jDelCred[jss::result][jss::error] == "entryNotFound");
|
||||
jDelCred[jss::result][jss::error] == "entryNotFound" &&
|
||||
jDelCred[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jDelCred[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -1283,8 +1286,9 @@ struct DepositPreauth_test : public beast::unit_test::Suite
|
||||
auto const jDelCred = credentials::ledgerEntry(env, gw, issuer, credType);
|
||||
BEAST_EXPECT(
|
||||
jDelCred.isObject() && jDelCred.isMember(jss::result) &&
|
||||
jDelCred[jss::result].isMember(jss::error) &&
|
||||
jDelCred[jss::result][jss::error] == "entryNotFound");
|
||||
jDelCred[jss::result][jss::error] == "entryNotFound" &&
|
||||
jDelCred[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jDelCred[jss::result][jss::error_message] == "Entry not found.");
|
||||
|
||||
BEAST_EXPECT(ownerCount(env, issuer) == 0);
|
||||
BEAST_EXPECT(ownerCount(env, gw) == 0);
|
||||
@@ -1358,8 +1362,9 @@ struct DepositPreauth_test : public beast::unit_test::Suite
|
||||
auto const jDelCred = credentials::ledgerEntry(env, zelda, issuer, credType);
|
||||
BEAST_EXPECT(
|
||||
jDelCred.isObject() && jDelCred.isMember(jss::result) &&
|
||||
jDelCred[jss::result].isMember(jss::error) &&
|
||||
jDelCred[jss::result][jss::error] == "entryNotFound");
|
||||
jDelCred[jss::result][jss::error] == "entryNotFound" &&
|
||||
jDelCred[jss::result][jss::error_code] == RpcEntryNotFound &&
|
||||
jDelCred[jss::result][jss::error_message] == "Entry not found.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,787 @@
|
||||
#include <test/jtx/Account.h>
|
||||
#include <test/jtx/Env.h>
|
||||
#include <test/jtx/TestHelpers.h>
|
||||
#include <test/jtx/amount.h>
|
||||
#include <test/jtx/envconfig.h>
|
||||
#include <test/jtx/escrow.h>
|
||||
#include <test/jtx/fee.h>
|
||||
#include <test/jtx/ter.h>
|
||||
|
||||
#include <xrpld/core/Config.h>
|
||||
|
||||
#include <xrpl/basics/strHex.h>
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/config/Constants.h>
|
||||
#include <xrpl/core/StartUpType.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Fees.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Protocol.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/SeqProxy.h>
|
||||
#include <xrpl/protocol/TER.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace xrpl::test {
|
||||
|
||||
/**
|
||||
* Smart Escrow's `Bytecode`, `Data` and `Gas` fields.
|
||||
*
|
||||
* The WASM engine that runs an escrow's bytecode is not in this build, so the
|
||||
* `Bytecode` field is opaque here: `EscrowCreate` weighs its size and nothing
|
||||
* reads it, and `EscrowFinish` has nothing to run it with. Everything around
|
||||
* the run is testable, and is tested below - the preflight and preclaim rules,
|
||||
* the fee the bytecode costs, the owner reserve it occupies, and the refund of
|
||||
* that reserve.
|
||||
*
|
||||
* What waits on the engine: a successful finish, tecBYTECODE_REJECTED, the
|
||||
* gas and return code the run reports in the transaction metadata, and the
|
||||
* `Data` a rejected contract leaves behind.
|
||||
*/
|
||||
struct EscrowSmart_test : public beast::unit_test::Suite
|
||||
{
|
||||
// A blob of `bytes` bytes, as hex. Opens with the WASM preamble - "\0asm"
|
||||
// and version 1 - so a reader can see what the field is meant to carry,
|
||||
// but nothing in this build parses it.
|
||||
static std::string
|
||||
bytecodeOfSize(std::size_t bytes)
|
||||
{
|
||||
static std::string const kPreamble = "0061736D01000000";
|
||||
std::string hex = kPreamble;
|
||||
hex.append((bytes * 2) - kPreamble.size(), 'A');
|
||||
return hex;
|
||||
}
|
||||
|
||||
// What EscrowCreate charges for `bytecodeHex`: ten base fees, plus five
|
||||
// drops per byte.
|
||||
static XRPAmount
|
||||
createFeeFor(jtx::Env const& env, std::string const& bytecodeHex)
|
||||
{
|
||||
return env.current()->fees().base * 10 + bytecodeHex.size() / 2 * 5;
|
||||
}
|
||||
|
||||
// A validator's config that votes for `value` on the fee setting `key`.
|
||||
static std::unique_ptr<Config>
|
||||
votingFor(std::string const& key, std::uint32_t value)
|
||||
{
|
||||
auto cfg = jtx::envconfig(jtx::validator, "");
|
||||
cfg->section(Sections::kVoting).set(key, std::to_string(value));
|
||||
return cfg;
|
||||
}
|
||||
|
||||
// Close past the flag ledger, so the vote lands in FeeSettings.
|
||||
static void
|
||||
closePastFlagLedger(jtx::Env& env)
|
||||
{
|
||||
for (auto i = env.current()->seq(); i <= 257; ++i)
|
||||
env.close();
|
||||
}
|
||||
|
||||
// What EscrowFinish charges for `gas`: the gas cost rounded up to the drop.
|
||||
static XRPAmount
|
||||
finishFeeFor(jtx::Env const& env, std::uint64_t gas)
|
||||
{
|
||||
return env.current()->fees().base +
|
||||
((gas * env.current()->fees().gasPrice) + microDropsPerDrop - 1) / microDropsPerDrop;
|
||||
}
|
||||
|
||||
void
|
||||
testCreatePreflight(FeatureBitset features)
|
||||
{
|
||||
testcase("EscrowCreate preflight");
|
||||
|
||||
using namespace jtx;
|
||||
using namespace std::chrono;
|
||||
|
||||
Account const alice{"alice"};
|
||||
Account const carol{"carol"};
|
||||
|
||||
auto const bytecode = bytecodeOfSize(64);
|
||||
|
||||
{
|
||||
// featureSmartEscrow disabled
|
||||
Env env(*this, features - featureSmartEscrow);
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
XRPAmount const txnFees = env.current()->fees().base + 1000;
|
||||
auto const escrowCreate = escrow::create(alice, carol, XRP(1000));
|
||||
env(escrowCreate,
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 100s),
|
||||
Fee(txnFees),
|
||||
Ter(temDISABLED));
|
||||
env.close();
|
||||
|
||||
env(escrowCreate,
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 100s),
|
||||
escrow::Data("00112233"),
|
||||
Fee(txnFees),
|
||||
Ter(temDISABLED));
|
||||
env.close();
|
||||
|
||||
env(escrowCreate,
|
||||
escrow::Data("00112233"),
|
||||
escrow::kFinishTime(env.now() + 100s),
|
||||
Fee(txnFees),
|
||||
Ter(temDISABLED));
|
||||
env.close();
|
||||
}
|
||||
|
||||
{
|
||||
// Bytecode > max length
|
||||
Env env(*this, votingFor(Keys::kBytecodeSizeLimit, 10), features); // 10 bytes
|
||||
closePastFlagLedger(env);
|
||||
XRPAmount const txnFees = env.current()->fees().base + 1000;
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
|
||||
auto const escrowCreate = escrow::create(alice, carol, XRP(500));
|
||||
|
||||
// 11-byte string
|
||||
std::string const longBytecode = "00112233445566778899AA";
|
||||
env(escrowCreate,
|
||||
escrow::Bytecode(longBytecode),
|
||||
escrow::kCancelTime(env.now() + 100s),
|
||||
Fee(txnFees),
|
||||
Ter(tefEXCEEDS_LIMIT));
|
||||
env.close();
|
||||
}
|
||||
|
||||
{
|
||||
// gas limit set to 0
|
||||
Env env(*this, votingFor(Keys::kGasLimit, 0), features); // WASM runtime disabled
|
||||
closePastFlagLedger(env);
|
||||
XRPAmount const txnFees = env.current()->fees().base + 1000;
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
|
||||
auto const escrowCreate = escrow::create(alice, carol, XRP(500));
|
||||
|
||||
env(escrowCreate,
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 100s),
|
||||
Fee(txnFees),
|
||||
Ter(tefTEMP_DISABLED));
|
||||
env.close();
|
||||
}
|
||||
|
||||
{
|
||||
// size limit set to 0
|
||||
Env env(
|
||||
*this, votingFor(Keys::kBytecodeSizeLimit, 0), features); // WASM upload disabled
|
||||
closePastFlagLedger(env);
|
||||
XRPAmount const txnFees = env.current()->fees().base + 1000;
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
|
||||
auto const escrowCreate = escrow::create(alice, carol, XRP(500));
|
||||
|
||||
// 1-byte string
|
||||
env(escrowCreate,
|
||||
escrow::Bytecode("AA"),
|
||||
escrow::kCancelTime(env.now() + 100s),
|
||||
Fee(txnFees),
|
||||
Ter(tefTEMP_DISABLED));
|
||||
env.close();
|
||||
|
||||
env(escrowCreate,
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 100s),
|
||||
Fee(txnFees),
|
||||
Ter(tefTEMP_DISABLED));
|
||||
env.close();
|
||||
}
|
||||
|
||||
{
|
||||
// Data without Bytecode
|
||||
Env env(*this, features);
|
||||
XRPAmount const txnFees = env.current()->fees().base + 100000;
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
|
||||
auto const escrowCreate = escrow::create(alice, carol, XRP(500));
|
||||
|
||||
std::string const data(4, 'A');
|
||||
env(escrowCreate,
|
||||
escrow::Data(data),
|
||||
escrow::kFinishTime(env.now() + 100s),
|
||||
Fee(txnFees),
|
||||
Ter(temMALFORMED));
|
||||
env.close();
|
||||
}
|
||||
|
||||
{
|
||||
// Data > max length
|
||||
Env env(*this, features);
|
||||
XRPAmount const txnFees = env.current()->fees().base + 100000;
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
|
||||
auto const escrowCreate = escrow::create(alice, carol, XRP(500));
|
||||
|
||||
// string of length (kMaxWasmDataLength + 1) * 2
|
||||
std::string const longData((kMaxWasmDataLength + 1) * 2, 'B');
|
||||
env(escrowCreate,
|
||||
escrow::Data(longData),
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 100s),
|
||||
Fee(txnFees),
|
||||
Ter(temMALFORMED));
|
||||
env.close();
|
||||
}
|
||||
|
||||
// Bytecode joins FinishAfter and Condition as a way to say how the
|
||||
// escrow completes, but it always needs a CancelAfter: nothing else
|
||||
// can free the funds if the contract never accepts.
|
||||
Env env(
|
||||
*this,
|
||||
envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->startUp = StartUpType::Fresh;
|
||||
return cfg;
|
||||
}),
|
||||
features);
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
|
||||
auto const escrowCreate = escrow::create(alice, carol, XRP(500));
|
||||
XRPAmount const txnFees = createFeeFor(env, bytecode);
|
||||
|
||||
// Success situations
|
||||
{
|
||||
// Bytecode + CancelAfter
|
||||
env(escrowCreate,
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 20s),
|
||||
Fee(txnFees));
|
||||
env.close();
|
||||
}
|
||||
{
|
||||
// Bytecode + Condition + CancelAfter
|
||||
env(escrowCreate,
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 30s),
|
||||
escrow::kCondition(escrow::kCb1),
|
||||
Fee(txnFees));
|
||||
env.close();
|
||||
}
|
||||
{
|
||||
// Bytecode + FinishAfter + CancelAfter
|
||||
env(escrowCreate,
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 40s),
|
||||
escrow::kFinishTime(env.now() + 2s),
|
||||
Fee(txnFees));
|
||||
env.close();
|
||||
}
|
||||
{
|
||||
// Bytecode + Data + CancelAfter
|
||||
env(escrowCreate,
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::Data("00112233"),
|
||||
escrow::kCancelTime(env.now() + 50s),
|
||||
Fee(txnFees));
|
||||
env.close();
|
||||
}
|
||||
|
||||
// Failure situations (i.e. all other combinations)
|
||||
{
|
||||
// only Bytecode
|
||||
env(escrowCreate, escrow::Bytecode(bytecode), Fee(txnFees), Ter(temBAD_EXPIRATION));
|
||||
env.close();
|
||||
}
|
||||
{
|
||||
// Bytecode + FinishAfter
|
||||
env(escrowCreate,
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kFinishTime(env.now() + 2s),
|
||||
Fee(txnFees),
|
||||
Ter(temBAD_EXPIRATION));
|
||||
env.close();
|
||||
}
|
||||
{
|
||||
// Bytecode + Condition
|
||||
env(escrowCreate,
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCondition(escrow::kCb1),
|
||||
Fee(txnFees),
|
||||
Ter(temBAD_EXPIRATION));
|
||||
env.close();
|
||||
}
|
||||
{
|
||||
// Bytecode 0 length
|
||||
env(escrowCreate,
|
||||
escrow::Bytecode(""),
|
||||
escrow::kCancelTime(env.now() + 60s),
|
||||
Fee(txnFees),
|
||||
Ter(temMALFORMED));
|
||||
env.close();
|
||||
}
|
||||
{
|
||||
// Not enough fees
|
||||
env(escrowCreate,
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 70s),
|
||||
Fee(txnFees - 1),
|
||||
Ter(telINSUF_FEE_P));
|
||||
env.close();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testCreateFeeAndReserve(FeatureBitset features)
|
||||
{
|
||||
testcase("EscrowCreate fee and reserve");
|
||||
|
||||
using namespace jtx;
|
||||
using namespace std::chrono;
|
||||
|
||||
Account const alice{"alice"};
|
||||
Account const carol{"carol"};
|
||||
|
||||
{
|
||||
// The fee scales with the bytecode: ten base fees plus five drops
|
||||
// per byte, and a drop short of it is refused.
|
||||
Env env(*this, features);
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
env.close();
|
||||
|
||||
auto const bytecode = bytecodeOfSize(1'000);
|
||||
auto const escrowCreate = escrow::create(alice, carol, XRP(500));
|
||||
auto const fee = createFeeFor(env, bytecode);
|
||||
BEAST_EXPECT(fee == env.current()->fees().base * 10 + 5'000);
|
||||
|
||||
env(escrowCreate,
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 100s),
|
||||
Fee(fee - 1),
|
||||
Ter(telINSUF_FEE_P));
|
||||
env.close();
|
||||
|
||||
auto const seq = env.seq(alice);
|
||||
env(escrowCreate,
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::Data("00112233"),
|
||||
escrow::kCancelTime(env.now() + 100s),
|
||||
Fee(fee));
|
||||
env.close();
|
||||
|
||||
// The ledger entry carries both fields.
|
||||
auto const sle = env.le(keylet::escrow(alice, SeqProxy::rawSequence(seq)));
|
||||
if (BEAST_EXPECT(sle))
|
||||
{
|
||||
BEAST_EXPECT(sle->isFieldPresent(sfBytecode));
|
||||
BEAST_EXPECT(strHex(sle->getFieldVL(sfBytecode)) == bytecode);
|
||||
BEAST_EXPECT(strHex(sle->getFieldVL(sfData)) == "00112233");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// The reserve is one owner increment per started 500 bytes of
|
||||
// bytecode.
|
||||
Env env(*this, features);
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
env.close();
|
||||
|
||||
std::uint32_t expectedOwnerCount = 0;
|
||||
for (auto const size : {
|
||||
std::size_t{64},
|
||||
std::size_t{500},
|
||||
std::size_t{501},
|
||||
std::size_t{1'000},
|
||||
std::size_t{1'001},
|
||||
})
|
||||
{
|
||||
auto const bytecode = bytecodeOfSize(size);
|
||||
env(escrow::create(alice, carol, XRP(100)),
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 1000s),
|
||||
Fee(createFeeFor(env, bytecode)));
|
||||
env.close();
|
||||
|
||||
expectedOwnerCount += (size + 499) / 500;
|
||||
BEAST_EXPECTS(
|
||||
env.ownerCount(alice) == expectedOwnerCount,
|
||||
std::to_string(size) + " bytes: " + std::to_string(env.ownerCount(alice)));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// A bytecode escrow the owner cannot reserve is refused, where the
|
||||
// same escrow without bytecode would have been accepted.
|
||||
Env env(*this, features);
|
||||
// Base 200 XRP + 50 XRP per owner object, from the unit-test
|
||||
// config. Enough for one owner object, not for two.
|
||||
env.fund(XRP(300), alice, carol);
|
||||
env.close();
|
||||
|
||||
auto const bytecode = bytecodeOfSize(1'000);
|
||||
env(escrow::create(alice, carol, XRP(20)),
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 100s),
|
||||
Fee(createFeeFor(env, bytecode)),
|
||||
Ter(tecINSUFFICIENT_RESERVE));
|
||||
env.close();
|
||||
BEAST_EXPECT(env.ownerCount(alice) == 0);
|
||||
|
||||
// The same escrow without bytecode costs one increment and fits.
|
||||
env(escrow::create(alice, carol, XRP(20)),
|
||||
escrow::kFinishTime(env.now() + 10s),
|
||||
escrow::kCancelTime(env.now() + 100s));
|
||||
env.close();
|
||||
BEAST_EXPECT(env.ownerCount(alice) == 1);
|
||||
}
|
||||
|
||||
{
|
||||
// After the lock, an XRP escrow's owner must still hold the
|
||||
// reserve the bytecode costs, not the single increment a plain
|
||||
// escrow costs.
|
||||
Env env(*this, features);
|
||||
Account const dave{"dave"};
|
||||
Account const erin{"erin"};
|
||||
env.fund(XRP(5000), carol);
|
||||
env.close();
|
||||
|
||||
auto const bytecode = bytecodeOfSize(600); // two increments
|
||||
auto const fee = createFeeFor(env, bytecode);
|
||||
auto const amount = XRP(1'000);
|
||||
auto const fees = env.current()->fees();
|
||||
|
||||
// One increment short after the lock.
|
||||
env.fund(
|
||||
STAmount{fees.accountReserve(1, 1) + amount.value().xrp() + fee}, noripple(dave));
|
||||
// Exactly enough after the lock.
|
||||
env.fund(
|
||||
STAmount{fees.accountReserve(2, 1) + amount.value().xrp() + fee}, noripple(erin));
|
||||
env.close();
|
||||
|
||||
env(escrow::create(dave, carol, amount),
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 100s),
|
||||
Fee(fee),
|
||||
Ter(tecUNFUNDED));
|
||||
env(escrow::create(erin, carol, amount),
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 100s),
|
||||
Fee(fee));
|
||||
env.close();
|
||||
BEAST_EXPECT(env.ownerCount(dave) == 0);
|
||||
BEAST_EXPECT(env.ownerCount(erin) == 2);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testFinishPreflight(FeatureBitset features)
|
||||
{
|
||||
testcase("EscrowFinish preflight");
|
||||
|
||||
using namespace jtx;
|
||||
using namespace std::chrono;
|
||||
|
||||
Account const alice{"alice"};
|
||||
Account const carol{"carol"};
|
||||
|
||||
{
|
||||
// featureSmartEscrow disabled
|
||||
Env env(*this, features - featureSmartEscrow);
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
env(escrow::finish(carol, alice, 1),
|
||||
Fee(env.current()->fees().base + 1000),
|
||||
escrow::Gas(4),
|
||||
Ter(temDISABLED));
|
||||
env.close();
|
||||
}
|
||||
|
||||
{
|
||||
// Gas > gas limit
|
||||
Env env(*this, votingFor(Keys::kGasLimit, 1'000), features); // in gas
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
env.close();
|
||||
|
||||
// Gas above the voted limit is checked against the escrow it
|
||||
// would run, so there has to be one.
|
||||
auto const bytecode = bytecodeOfSize(64);
|
||||
auto const seq = env.seq(alice);
|
||||
env(escrow::create(alice, carol, XRP(500)),
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 100'000s),
|
||||
Fee(createFeeFor(env, bytecode)));
|
||||
closePastFlagLedger(env);
|
||||
|
||||
auto const gas = 1'001;
|
||||
env(escrow::finish(carol, alice, seq),
|
||||
Fee(finishFeeFor(env, gas)),
|
||||
escrow::Gas(gas),
|
||||
Ter(tefEXCEEDS_LIMIT));
|
||||
}
|
||||
|
||||
{
|
||||
// Gas of 0
|
||||
Env env(*this, features);
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
env.close();
|
||||
env(escrow::finish(carol, alice, 1),
|
||||
Fee(env.current()->fees().base + 1000),
|
||||
escrow::Gas(0),
|
||||
Ter(temBAD_LIMIT));
|
||||
}
|
||||
|
||||
{
|
||||
// Gas above the protocol ceiling, refused before any view is read
|
||||
Env env(*this, features);
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
env.close();
|
||||
env(escrow::finish(carol, alice, 1),
|
||||
Fee(env.current()->fees().base + 1000),
|
||||
escrow::Gas(kMaxGasLimit + 1),
|
||||
Ter(temBAD_LIMIT));
|
||||
}
|
||||
|
||||
{
|
||||
// WASM compute disabled after the escrow was created.
|
||||
Env env(*this, votingFor(Keys::kGasLimit, 0), features);
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
env.close();
|
||||
|
||||
auto const bytecode = bytecodeOfSize(64);
|
||||
auto const seq = env.seq(alice);
|
||||
env(escrow::create(alice, carol, XRP(500)),
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 100'000s),
|
||||
Fee(createFeeFor(env, bytecode)));
|
||||
closePastFlagLedger(env);
|
||||
|
||||
auto const gas = 1'000;
|
||||
env(escrow::finish(carol, alice, seq),
|
||||
escrow::Gas(gas),
|
||||
Fee(finishFeeFor(env, gas)),
|
||||
Ter(tefTEMP_DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testFinishBytecodePairing(FeatureBitset features)
|
||||
{
|
||||
testcase("EscrowFinish Bytecode and Gas must agree");
|
||||
|
||||
using namespace jtx;
|
||||
using namespace std::chrono;
|
||||
|
||||
Account const alice{"alice"};
|
||||
Account const carol{"carol"};
|
||||
|
||||
Env env(*this, features);
|
||||
|
||||
// Run past the flag ledger so that a Fee change vote occurs and
|
||||
// updates FeeSettings. (It also activates all supported amendments.)
|
||||
for (auto i = env.current()->seq(); i <= 257; ++i)
|
||||
env.close();
|
||||
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
|
||||
auto const bytecode = bytecodeOfSize(64);
|
||||
auto const seq = env.seq(alice);
|
||||
env(escrow::create(alice, carol, XRP(500)),
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 100s),
|
||||
Fee(createFeeFor(env, bytecode)));
|
||||
env.close();
|
||||
|
||||
{
|
||||
// Bytecode on the escrow, no Gas on the finish
|
||||
env(escrow::finish(carol, alice, seq), Ter(tefBYTECODE_NOT_INCLUDED));
|
||||
}
|
||||
|
||||
{
|
||||
// Gas on the finish, no Bytecode on the escrow
|
||||
auto const plainSeq = env.seq(alice);
|
||||
env(escrow::create(alice, carol, XRP(500)),
|
||||
escrow::kFinishTime(env.now() + 10s),
|
||||
escrow::kCancelTime(env.now() + 100s));
|
||||
env.close();
|
||||
|
||||
auto const gas = 100;
|
||||
env(escrow::finish(carol, alice, plainSeq),
|
||||
Fee(finishFeeFor(env, gas)),
|
||||
escrow::Gas(gas),
|
||||
Ter(tefNO_BYTECODE));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testFinishFee(FeatureBitset features)
|
||||
{
|
||||
testcase("EscrowFinish fee");
|
||||
|
||||
using namespace jtx;
|
||||
using namespace std::chrono;
|
||||
|
||||
Account const alice{"alice"};
|
||||
Account const carol{"carol"};
|
||||
|
||||
Env env(
|
||||
*this,
|
||||
envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->fees.gasPrice = 1'000'000; // 1 drop per gas
|
||||
return cfg;
|
||||
}),
|
||||
features);
|
||||
// Run past the flag ledger so that a Fee change vote occurs and
|
||||
// updates FeeSettings. (It also activates all supported amendments.)
|
||||
for (auto i = env.current()->seq(); i <= 257; ++i)
|
||||
env.close();
|
||||
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
|
||||
auto const bytecode = bytecodeOfSize(64);
|
||||
auto const seq = env.seq(alice);
|
||||
env(escrow::create(alice, carol, XRP(1000)),
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 100s),
|
||||
Fee(createFeeFor(env, bytecode)));
|
||||
env.close();
|
||||
|
||||
// A large gas allowance costs more than the allowance itself, and does
|
||||
// not wrap.
|
||||
auto const gas = 996'433;
|
||||
auto const fee = finishFeeFor(env, gas);
|
||||
BEAST_EXPECT(fee.drops() > gas);
|
||||
// At one drop per gas the cost divides evenly, so no drop is added.
|
||||
BEAST_EXPECT(fee == env.current()->fees().base + gas);
|
||||
|
||||
// Intentional low value to test overflow handling
|
||||
env(escrow::finish(carol, alice, seq),
|
||||
Fee(drops(30)),
|
||||
escrow::Gas(gas),
|
||||
Ter(telINSUF_FEE_P));
|
||||
|
||||
env(escrow::finish(carol, alice, seq), Fee(fee - 1), escrow::Gas(gas), Ter(telINSUF_FEE_P));
|
||||
|
||||
// TODO(SmartEscrow): tesSUCCESS once the WASM engine lands. Until then
|
||||
// the fee is charged and the run reports that it could not happen.
|
||||
env(escrow::finish(carol, alice, seq),
|
||||
Fee(fee),
|
||||
escrow::Gas(gas),
|
||||
Ter(tecFAILED_PROCESSING));
|
||||
|
||||
{
|
||||
// A gas cost of a fraction of a drop rounds up to a whole drop:
|
||||
// two gas at one micro-drop each costs one drop, not zero, and not
|
||||
// one drop per gas.
|
||||
Env env(*this, votingFor(Keys::kGasPrice, 1), features);
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
env.close();
|
||||
|
||||
auto const seq = env.seq(alice);
|
||||
env(escrow::create(alice, carol, XRP(1000)),
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 100'000s),
|
||||
Fee(createFeeFor(env, bytecode)));
|
||||
closePastFlagLedger(env);
|
||||
BEAST_EXPECT(env.current()->fees().gasPrice == 1);
|
||||
|
||||
auto const base = env.current()->fees().base;
|
||||
env(escrow::finish(carol, alice, seq), Fee(base), escrow::Gas(2), Ter(telINSUF_FEE_P));
|
||||
env(escrow::finish(carol, alice, seq),
|
||||
Fee(base + 1),
|
||||
escrow::Gas(2),
|
||||
Ter(tecFAILED_PROCESSING));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testFinishWithoutEngine(FeatureBitset features)
|
||||
{
|
||||
testcase("EscrowFinish has no WASM engine");
|
||||
|
||||
using namespace jtx;
|
||||
using namespace std::chrono;
|
||||
|
||||
Account const alice{"alice"};
|
||||
Account const carol{"carol"};
|
||||
|
||||
Env env(*this, features);
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
env.close();
|
||||
|
||||
auto const bytecode = bytecodeOfSize(1'000);
|
||||
auto const seq = env.seq(alice);
|
||||
env(escrow::create(alice, carol, XRP(500)),
|
||||
escrow::Bytecode(bytecode),
|
||||
escrow::kCancelTime(env.now() + 20s),
|
||||
Fee(createFeeFor(env, bytecode)));
|
||||
env.close();
|
||||
BEAST_EXPECT(env.ownerCount(alice) == 2);
|
||||
|
||||
// TODO(SmartEscrow): the contract decides this once the WASM engine
|
||||
// lands - tesSUCCESS on accept, tecBYTECODE_REJECTED on reject.
|
||||
auto const gas = 1'000;
|
||||
env(escrow::finish(carol, alice, seq),
|
||||
Fee(finishFeeFor(env, gas)),
|
||||
escrow::Gas(gas),
|
||||
Ter(tecFAILED_PROCESSING));
|
||||
env.close();
|
||||
|
||||
// The escrow and its reserve survive.
|
||||
BEAST_EXPECT(env.le(keylet::escrow(alice, SeqProxy::rawSequence(seq))));
|
||||
BEAST_EXPECT(env.ownerCount(alice) == 2);
|
||||
|
||||
// Cancelling returns the whole reserve, not just one increment.
|
||||
env.close(30s);
|
||||
env(escrow::cancel(carol, alice, seq));
|
||||
env.close();
|
||||
BEAST_EXPECT(!env.le(keylet::escrow(alice, SeqProxy::rawSequence(seq))));
|
||||
BEAST_EXPECT(env.ownerCount(alice) == 0);
|
||||
}
|
||||
|
||||
void
|
||||
testFinishReleasesReserve(FeatureBitset features)
|
||||
{
|
||||
testcase("EscrowFinish releases the reserve");
|
||||
|
||||
using namespace jtx;
|
||||
using namespace std::chrono;
|
||||
|
||||
Account const alice{"alice"};
|
||||
Account const carol{"carol"};
|
||||
|
||||
// Without featureSponsor and fixCleanup3_4_0, the reserve is released
|
||||
// after delivery rather than before.
|
||||
Env env(*this, features - featureSponsor - fixCleanup3_4_0);
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
env.close();
|
||||
|
||||
auto const seq = env.seq(alice);
|
||||
env(escrow::create(alice, carol, XRP(500)), escrow::kFinishTime(env.now() + 1s));
|
||||
env.close();
|
||||
BEAST_EXPECT(env.ownerCount(alice) == 1);
|
||||
|
||||
env(escrow::finish(carol, alice, seq));
|
||||
env.close();
|
||||
BEAST_EXPECT(!env.le(keylet::escrow(alice, SeqProxy::rawSequence(seq))));
|
||||
BEAST_EXPECT(env.ownerCount(alice) == 0);
|
||||
}
|
||||
|
||||
void
|
||||
testWithFeats(FeatureBitset features)
|
||||
{
|
||||
testCreatePreflight(features);
|
||||
testCreateFeeAndReserve(features);
|
||||
testFinishPreflight(features);
|
||||
testFinishBytecodePairing(features);
|
||||
testFinishFee(features);
|
||||
testFinishWithoutEngine(features);
|
||||
testFinishReleasesReserve(features);
|
||||
}
|
||||
|
||||
public:
|
||||
void
|
||||
run() override
|
||||
{
|
||||
using namespace test::jtx;
|
||||
FeatureBitset const all{testableAmendments()};
|
||||
testWithFeats(all);
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(EscrowSmart, app, xrpl);
|
||||
|
||||
} // namespace xrpl::test
|
||||
@@ -1524,7 +1524,7 @@ struct Escrow_test : public beast::unit_test::Suite
|
||||
Account const alice{"alice"};
|
||||
Account const bob{"bob"};
|
||||
Account const carol{"carol"};
|
||||
Account const dillon{"dillon "};
|
||||
Account const dillon{"dillon"};
|
||||
Account const zelda{"zelda"};
|
||||
|
||||
char const credType[] = "abcde";
|
||||
@@ -1682,6 +1682,8 @@ public:
|
||||
testWithFeats(all);
|
||||
testWithFeats(all - featureTokenEscrow);
|
||||
testWithFeats(all - fixCleanup3_5_0);
|
||||
testWithFeats(all - featureSmartEscrow);
|
||||
testWithFeats(all - featureTokenEscrow - featureSmartEscrow);
|
||||
testTags(all - fixIncludeKeyletFields);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1215,6 +1215,61 @@ struct FlowMPT_test : public beast::unit_test::Suite
|
||||
BEAST_EXPECT(env.balance(bob, y) == y(0));
|
||||
}
|
||||
|
||||
void
|
||||
testConsumeOfferOverflow(FeatureBitset features)
|
||||
{
|
||||
// An overflow while consuming an offer fails the strand under
|
||||
// MPTokensV2, and the transaction with tecINTERNAL otherwise. Either
|
||||
// way no balances change and the offer stays on the book.
|
||||
testcase("BookStep consumeOffer overflow");
|
||||
|
||||
using namespace jtx;
|
||||
|
||||
Account const gw("gateway");
|
||||
Account const eurGW("eur_gateway");
|
||||
Account const maker("maker");
|
||||
Account const alice("alice");
|
||||
Account const bob("bob");
|
||||
|
||||
for (auto const& testFeatures : {features, features - featureMPTokensV2})
|
||||
{
|
||||
Env env(*this, testFeatures);
|
||||
|
||||
auto const withV2 = testFeatures[featureMPTokensV2];
|
||||
|
||||
env.fund(XRP(10'000), gw, eurGW, maker, alice, bob);
|
||||
env.close();
|
||||
|
||||
auto const usd = gw["USD"];
|
||||
auto const eur = eurGW["EUR"];
|
||||
STAmount const usdMax{usd.issue(), STAmount::kMaxValue, STAmount::kMaxOffset};
|
||||
STAmount const usdIn{usd.issue(), 1, 90};
|
||||
|
||||
env.trust(usdMax, maker, alice);
|
||||
env.trust(eur(1'000), maker, bob);
|
||||
env.close();
|
||||
|
||||
env(pay(gw, maker, usdMax));
|
||||
env(pay(gw, alice, usdIn));
|
||||
env(pay(eurGW, maker, eur(100)));
|
||||
env(offer(maker, usdIn, eur(100)));
|
||||
env.close();
|
||||
|
||||
env(pay(alice, bob, eur(100)),
|
||||
Path(~eur),
|
||||
Sendmax(usdIn),
|
||||
Ter(withV2 ? TER{tecPATH_PARTIAL} : TER{tecINTERNAL}));
|
||||
env.close();
|
||||
|
||||
env.require(
|
||||
Balance(bob, eur(0)),
|
||||
Balance(maker, eur(100)),
|
||||
Balance(maker, usdMax),
|
||||
Balance(alice, usdIn));
|
||||
BEAST_EXPECT(isOffer(env, maker, usdIn, eur(100)));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testFalseDry(FeatureBitset features)
|
||||
{
|
||||
@@ -3008,6 +3063,7 @@ struct FlowMPT_test : public beast::unit_test::Suite
|
||||
testBookStepInputAboveMaximumAmount(features);
|
||||
testBookStepInputAboveMaximumAmountWithFee(features);
|
||||
testBookStepMissingIssuance(features);
|
||||
testConsumeOfferOverflow(features);
|
||||
testSelfPayment1(features);
|
||||
testSelfPayment2(features);
|
||||
testSelfFundedXRPEndpoint(false, features);
|
||||
@@ -3016,6 +3072,85 @@ struct FlowMPT_test : public beast::unit_test::Suite
|
||||
testReExecuteDirectStep(features);
|
||||
testSelfPayLowQualityOffer(features);
|
||||
testLockedMidPathHolder(features);
|
||||
testIssuerSourceMPTLoop(features);
|
||||
}
|
||||
|
||||
void
|
||||
testIssuerSourceMPTLoop(FeatureBitset features)
|
||||
{
|
||||
// An issuer paying with its own MPT may not route it back through a
|
||||
// book that outputs the same MPT. It would issue at the first book
|
||||
// and again after the second, and with the issuer's own offer in
|
||||
// the second book the engine could not keep the sum within
|
||||
// MaximumAmount. Holders already get temBAD_PATH_LOOP for this.
|
||||
testcase("Issuer-sourced payment looping through its own MPT");
|
||||
|
||||
using namespace jtx;
|
||||
|
||||
Account const gw{"gw"};
|
||||
Account const alice{"alice"};
|
||||
Account const c1{"c1"};
|
||||
Account const e1{"e1"};
|
||||
Account const dan{"dan"};
|
||||
|
||||
Env env(*this, features);
|
||||
env.fund(XRP(1'000), gw, alice, c1, e1, dan);
|
||||
env.close();
|
||||
|
||||
MPT const x =
|
||||
MPTTester({.env = env, .issuer = gw, .holders = {alice, c1, e1, dan}, .maxAmt = 100});
|
||||
auto const eur = gw["EUR"];
|
||||
auto const usd = gw["USD"];
|
||||
env(trust(e1, eur(1'000)));
|
||||
env(trust(e1, usd(1'000)));
|
||||
env(trust(dan, eur(1'000)));
|
||||
env(pay(gw, e1, eur(1'000)));
|
||||
env(pay(gw, e1, usd(1'000)));
|
||||
env(pay(gw, alice, x(10)));
|
||||
env.close();
|
||||
|
||||
// Liquidity for every path below, arranged so nothing crosses at
|
||||
// creation.
|
||||
env(offer(gw, XRP(60), x(30))); // issuer sells x for XRP
|
||||
env(offer(gw, usd(100), x(100))); // issuer sells x for usd
|
||||
env.close();
|
||||
env(offer(c1, x(100), XRP(100))); // buys x for XRP
|
||||
env(offer(e1, XRP(70), usd(70))); // sells usd for XRP
|
||||
env(offer(e1, x(100), eur(100))); // sells eur for x
|
||||
env.close();
|
||||
BEAST_EXPECT(expectOffers(env, gw, 2));
|
||||
BEAST_EXPECT(expectOffers(env, c1, 1));
|
||||
BEAST_EXPECT(expectOffers(env, e1, 2));
|
||||
|
||||
auto const flags = Txflags(tfNoRippleDirect | tfPartialPayment);
|
||||
|
||||
// x -> XRP -> x, the issuer's own offer feeds the endpoint
|
||||
env(pay(gw, dan, x(100)), Sendmax(x(100)), Path(~XRP, ~x), flags, Ter(temBAD_PATH_LOOP));
|
||||
// x -> XRP -> x -> eur, the issuer's own offer feeds a third book
|
||||
env(pay(gw, dan, eur(100)),
|
||||
Sendmax(x(100)),
|
||||
Path(~XRP, ~x, ~eur),
|
||||
flags,
|
||||
Ter(temBAD_PATH_LOOP));
|
||||
// x -> XRP -> usd -> x, a limiting book before the issuer's own offer
|
||||
env(pay(gw, dan, x(100)),
|
||||
Sendmax(x(100)),
|
||||
Path(~XRP, ~usd, ~x),
|
||||
flags,
|
||||
Ter(temBAD_PATH_LOOP));
|
||||
// Same loop from a holder is already rejected
|
||||
env(pay(alice, dan, x(10)), Sendmax(x(10)), Path(~XRP, ~x), flags, Ter(temBAD_PATH_LOOP));
|
||||
env.close();
|
||||
|
||||
BEAST_EXPECT(env.balance(gw, x) == x(-10));
|
||||
BEAST_EXPECT(env.balance(c1, x) == x(0));
|
||||
BEAST_EXPECT(env.balance(dan, x) == x(0));
|
||||
|
||||
// The issuer paying with another asset may still take its own offer
|
||||
env(pay(gw, dan, x(50)), Sendmax(usd(50)), Path(~x), flags);
|
||||
env.close();
|
||||
BEAST_EXPECT(env.balance(dan, x) == x(50));
|
||||
BEAST_EXPECT(env.balance(gw, x) == x(-60));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <xrpl/ledger/helpers/MPTokenHelpers.h>
|
||||
#include <xrpl/ledger/helpers/TokenHelpers.h>
|
||||
#include <xrpl/protocol/Asset.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/IOUAmount.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
@@ -994,8 +995,9 @@ class MPToken_test : public beast::unit_test::Suite
|
||||
test::jtx::MPT const mpT1("MPT", makeMptID(env.seq(alice) + 10, alice));
|
||||
err = !mpTokensV2 ? Ter(temMALFORMED) : Ter(tecOBJECT_NOT_FOUND);
|
||||
env(pay(alice, carol, mpT1(100)), Sendmax(mpt(100)), err);
|
||||
// "paths" is invalid in V1
|
||||
err = !mpTokensV2 ? Ter(temMALFORMED) : Ter(tesSUCCESS);
|
||||
// "paths" is invalid in V1. In V2 any path from the issuer back
|
||||
// to its own MPT is a loop, like it is for a holder.
|
||||
err = !mpTokensV2 ? Ter(temMALFORMED) : Ter(temBAD_PATH_LOOP);
|
||||
env(pay(alice, carol, mpt(100)), Path(~usd), err);
|
||||
}
|
||||
|
||||
@@ -1019,6 +1021,7 @@ class MPToken_test : public beast::unit_test::Suite
|
||||
payment[jss::build_path] = true;
|
||||
auto jrr = env.rpc("json", "submit", to_string(payment));
|
||||
BEAST_EXPECT(jrr[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::result][jss::error_message] ==
|
||||
"Field 'build_path' not allowed in this context.");
|
||||
@@ -1580,6 +1583,8 @@ class MPToken_test : public beast::unit_test::Suite
|
||||
jv[jss::tx_json][jss::Amount][jss::value] = std::to_string(kMaxMpTokenAmount + 1);
|
||||
auto const jrr = env.rpc("json", "submit", to_string(jv));
|
||||
BEAST_EXPECT(jrr[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::result][jss::error_message] == "Invalid field 'tx_json.Amount'.");
|
||||
}
|
||||
|
||||
// Pay maximum amount with the transfer fee, SendMax, and
|
||||
@@ -1944,6 +1949,8 @@ class MPToken_test : public beast::unit_test::Suite
|
||||
jtx.stx->add(s);
|
||||
auto jrr = env.rpc("submit", strHex(s.slice()));
|
||||
BEAST_EXPECT(jrr[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!jrr[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(jrr[jss::result][jss::error_message].isNull());
|
||||
|
||||
// tx is unsigned
|
||||
json::Value jv1;
|
||||
@@ -1951,9 +1958,13 @@ class MPToken_test : public beast::unit_test::Suite
|
||||
jv1[jss::tx_json] = jv;
|
||||
jrr = env.rpc("json", "submit", to_string(jv1));
|
||||
BEAST_EXPECT(jrr[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::result][jss::error_message] == "Amount can not be MPT.");
|
||||
|
||||
jrr = env.rpc("json", "sign", to_string(jv1));
|
||||
BEAST_EXPECT(jrr[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::result][jss::error_message] == "Amount can not be MPT.");
|
||||
};
|
||||
auto setMPTFields = [&](SField const& field, json::Value& jv, bool withAmount = true) {
|
||||
jv[jss::Asset] = toJson(xrpIssue());
|
||||
@@ -3197,6 +3208,9 @@ class MPToken_test : public beast::unit_test::Suite
|
||||
jv1[jss::tx_json] = jv;
|
||||
auto const jrr = env.rpc("json", "submit", to_string(jv1));
|
||||
BEAST_EXPECT(jrr[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::result][jss::error_message] == "Field 'tx_json.Amount' has invalid data.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <xrpl/config/Constants.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/KeyType.h>
|
||||
@@ -586,6 +587,7 @@ public:
|
||||
auto jrr = env.rpc("json", "sign_for", to_string(jvOne))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] ==
|
||||
"When multi-signing 'tx_json.SigningPubKey' must be empty.");
|
||||
@@ -613,6 +615,7 @@ public:
|
||||
jrr = env.rpc("json", "submit_multisigned", to_string(jvSubmit))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] == "Invalid Fee field. Fees must be greater than zero.");
|
||||
}
|
||||
@@ -639,6 +642,7 @@ public:
|
||||
jrr = env.rpc("json", "submit_multisigned", to_string(jvSubmit))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "internal");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInternal);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Internal error.");
|
||||
}
|
||||
|
||||
@@ -651,6 +655,8 @@ public:
|
||||
auto jrr = env.rpc("json", "sign_for", to_string(jv))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "masterDisabled");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcMasterDisabled);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Master key is disabled.");
|
||||
env.close();
|
||||
BEAST_EXPECT(env.seq(alice) == aliceSeq);
|
||||
}
|
||||
@@ -690,12 +696,16 @@ public:
|
||||
auto jrr = env.rpc("json", "sign_for", to_string(jv))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "srcActMalformed");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcSrcActMalformed);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'tx_json.Account'.");
|
||||
|
||||
Account const jimmy{"jimmy"};
|
||||
jv[jss::tx_json][jss::Account] = jimmy.human();
|
||||
jrr = env.rpc("json", "sign_for", to_string(jv))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "srcActNotFound");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcSrcActNotFound);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Source account not found.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -706,6 +716,7 @@ public:
|
||||
auto jrr = env.rpc("json", "submit_multisigned", to_string(jv))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "tx_json.Signers array may not be empty.");
|
||||
env.close();
|
||||
BEAST_EXPECT(env.seq(alice) == aliceSeq);
|
||||
@@ -1068,6 +1079,9 @@ public:
|
||||
STTx local = *tx.stx;
|
||||
local.setFieldVL(sfSigningPubKey, Blob()); // Empty SigningPubKey
|
||||
auto const info = submitSTTx(local);
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!info[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message].isNull());
|
||||
BEAST_EXPECT(
|
||||
info[jss::result][jss::error_exception] ==
|
||||
"fails local checks: Empty SigningPubKey.");
|
||||
@@ -1082,6 +1096,9 @@ public:
|
||||
local.setFieldVL(sfTxnSignature, badSig);
|
||||
// Signature should fail.
|
||||
auto const info = submitSTTx(local);
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!info[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message].isNull());
|
||||
BEAST_EXPECT(
|
||||
info[jss::result][jss::error_exception] ==
|
||||
"fails local checks: Invalid signature.");
|
||||
@@ -1095,6 +1112,9 @@ public:
|
||||
local.setFieldU32(sfSequence, seq + 1);
|
||||
// Signature should fail.
|
||||
auto const info = submitSTTx(local);
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!info[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message].isNull());
|
||||
BEAST_EXPECT(
|
||||
info[jss::result][jss::error_exception] ==
|
||||
"fails local checks: Invalid signature.");
|
||||
@@ -1105,6 +1125,9 @@ public:
|
||||
STTx local = *tx.stx;
|
||||
local[sfSigningPubKey] = alice.pk(); // Insert sfSigningPubKey
|
||||
auto const info = submitSTTx(local);
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!info[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message].isNull());
|
||||
BEAST_EXPECT(
|
||||
info[jss::result][jss::error_exception] ==
|
||||
"fails local checks: Cannot both single- and multi-sign.");
|
||||
@@ -1116,6 +1139,9 @@ public:
|
||||
local.sign(alice.pk(), alice.sk());
|
||||
local.setFieldVL(sfSigningPubKey, Blob()); // Empty SigningPubKey
|
||||
auto const info = submitSTTx(local);
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!info[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message].isNull());
|
||||
BEAST_EXPECT(
|
||||
info[jss::result][jss::error_exception] ==
|
||||
"fails local checks: Cannot both single- and multi-sign.");
|
||||
@@ -1131,6 +1157,9 @@ public:
|
||||
signer.setFieldVL(sfTxnSignature, badSig);
|
||||
// Signature should fail.
|
||||
auto const info = submitSTTx(local);
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!info[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message].isNull());
|
||||
BEAST_EXPECT(
|
||||
info[jss::result][jss::error_exception].asString().contains(
|
||||
"Invalid signature on account r"));
|
||||
@@ -1141,6 +1170,9 @@ public:
|
||||
STTx local = *tx.stx;
|
||||
local.peekFieldArray(sfSigners).clear(); // Empty Signers array.
|
||||
auto const info = submitSTTx(local);
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!info[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message].isNull());
|
||||
BEAST_EXPECT(
|
||||
info[jss::result][jss::error_exception] ==
|
||||
"fails local checks: Invalid Signers array size.");
|
||||
@@ -1186,6 +1218,9 @@ public:
|
||||
bogie_));
|
||||
STTx const local = *tx.stx;
|
||||
auto const info = submitSTTx(local);
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!info[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message].isNull());
|
||||
BEAST_EXPECT(
|
||||
info[jss::result][jss::error_exception] ==
|
||||
"fails local checks: Invalid Signers array size.");
|
||||
@@ -1195,6 +1230,9 @@ public:
|
||||
JTx const tx = env.jt(noop(alice), Fee(2 * baseFee), Msig(alice));
|
||||
STTx const local = *tx.stx;
|
||||
auto const info = submitSTTx(local);
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!info[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message].isNull());
|
||||
BEAST_EXPECT(
|
||||
info[jss::result][jss::error_exception] ==
|
||||
"fails local checks: Invalid multisigner.");
|
||||
@@ -1204,6 +1242,9 @@ public:
|
||||
JTx const tx = env.jt(noop(alice), Fee(2 * baseFee), Msig(bogie_, bogie_));
|
||||
STTx const local = *tx.stx;
|
||||
auto const info = submitSTTx(local);
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!info[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message].isNull());
|
||||
BEAST_EXPECT(
|
||||
info[jss::result][jss::error_exception] ==
|
||||
"fails local checks: Duplicate Signers not allowed.");
|
||||
@@ -1217,6 +1258,9 @@ public:
|
||||
std::ranges::reverse(signers);
|
||||
// Signature should fail.
|
||||
auto const info = submitSTTx(local);
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!info[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message].isNull());
|
||||
BEAST_EXPECT(
|
||||
info[jss::result][jss::error_exception] ==
|
||||
"fails local checks: Unsorted Signers array.");
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/ledger/OpenView.h>
|
||||
#include <xrpl/protocol/ApiVersion.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Protocol.h>
|
||||
@@ -4653,18 +4654,22 @@ class NFTokenBaseUtil_test : public beast::unit_test::Suite
|
||||
if (expect(
|
||||
nftOffers.isMember(jss::result), "expected \"result\"", __FILE__, line))
|
||||
{
|
||||
if (expect(
|
||||
nftOffers[jss::result].isMember(jss::error),
|
||||
"expected \"error\"",
|
||||
__FILE__,
|
||||
line))
|
||||
{
|
||||
expect(
|
||||
nftOffers[jss::result][jss::error].asString() == "objectNotFound",
|
||||
"expected \"objectNotFound\"",
|
||||
__FILE__,
|
||||
line);
|
||||
}
|
||||
json::Value const& result = nftOffers[jss::result];
|
||||
expect(
|
||||
result[jss::error].asString() == "objectNotFound",
|
||||
"expected \"objectNotFound\"",
|
||||
__FILE__,
|
||||
line);
|
||||
expect(
|
||||
result[jss::error_code] == RpcObjectNotFound,
|
||||
"expected RpcObjectNotFound",
|
||||
__FILE__,
|
||||
line);
|
||||
expect(
|
||||
result[jss::error_message] == "The requested object was not found.",
|
||||
"expected \"The requested object was not found.\"",
|
||||
__FILE__,
|
||||
line);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -4860,11 +4865,15 @@ class NFTokenBaseUtil_test : public beast::unit_test::Suite
|
||||
// Sell-side marker passed to nft_buy_offers.
|
||||
json::Value const result = queryWithMarker("nft_buy_offers", sellOfferIndex);
|
||||
BEAST_EXPECT(result[jss::error].asString() == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
{
|
||||
// Buy-side marker passed to nft_sell_offers.
|
||||
json::Value const result = queryWithMarker("nft_sell_offers", buyOfferIndex);
|
||||
BEAST_EXPECT(result[jss::error].asString() == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
// A same-side marker is still accepted. With a single offer on each
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <xrpl/ledger/helpers/DirectoryHelpers.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/Book.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
@@ -2755,6 +2756,8 @@ public:
|
||||
|
||||
jro = ledgerEntryOffer(env, bob, bobOfferSeq);
|
||||
BEAST_EXPECT(jro[jss::error] == "entryNotFound");
|
||||
BEAST_EXPECT(jro[jss::error_code] == RpcEntryNotFound);
|
||||
BEAST_EXPECT(jro[jss::error_message] == "Entry not found.");
|
||||
|
||||
env.require(Owners(alice, 1), Owners(bob, 1));
|
||||
}
|
||||
@@ -2788,6 +2791,8 @@ public:
|
||||
|
||||
auto jro = ledgerEntryOffer(env, bob, bobOfferSeq);
|
||||
BEAST_EXPECT(jro[jss::error] == "entryNotFound");
|
||||
BEAST_EXPECT(jro[jss::error_code] == RpcEntryNotFound);
|
||||
BEAST_EXPECT(jro[jss::error_message] == "Entry not found.");
|
||||
};
|
||||
testHelper3TokensMix(test);
|
||||
}
|
||||
@@ -2847,6 +2852,8 @@ public:
|
||||
// Verify the offer was consumed
|
||||
jro = ledgerEntryOffer(env, bob, bobOfferSeq);
|
||||
BEAST_EXPECT(jro[jss::error] == "entryNotFound");
|
||||
BEAST_EXPECT(jro[jss::error_code] == RpcEntryNotFound);
|
||||
BEAST_EXPECT(jro[jss::error_message] == "Entry not found.");
|
||||
|
||||
// verify balances look right after the partial payment
|
||||
// only 300 XRP should have been payed since that's all
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/ledger/helpers/DirectoryHelpers.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
@@ -1707,6 +1708,8 @@ public:
|
||||
|
||||
jro = ledgerEntryOffer(env, bob, bobOfferSeq);
|
||||
BEAST_EXPECT(jro[jss::error] == "entryNotFound");
|
||||
BEAST_EXPECT(jro[jss::error_code] == RpcEntryNotFound);
|
||||
BEAST_EXPECT(jro[jss::error_message] == "Entry not found.");
|
||||
|
||||
env.require(Owners(alice, 1), Owners(bob, 1));
|
||||
}
|
||||
@@ -1738,6 +1741,8 @@ public:
|
||||
|
||||
auto jro = ledgerEntryOffer(env, bob, bobOfferSeq);
|
||||
BEAST_EXPECT(jro[jss::error] == "entryNotFound");
|
||||
BEAST_EXPECT(jro[jss::error_code] == RpcEntryNotFound);
|
||||
BEAST_EXPECT(jro[jss::error_message] == "Entry not found.");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1798,6 +1803,8 @@ public:
|
||||
// Verify the offer was consumed
|
||||
jro = ledgerEntryOffer(env, bob, bobOfferSeq);
|
||||
BEAST_EXPECT(jro[jss::error] == "entryNotFound");
|
||||
BEAST_EXPECT(jro[jss::error_code] == RpcEntryNotFound);
|
||||
BEAST_EXPECT(jro[jss::error_message] == "Entry not found.");
|
||||
|
||||
// verify balances look right after the partial payment
|
||||
// only 300 XRP should be have been payed since that's all
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/ApiVersion.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/PathAsset.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
@@ -162,7 +163,9 @@ public:
|
||||
g.signal();
|
||||
});
|
||||
BEAST_EXPECT(g.waitFor(5s));
|
||||
BEAST_EXPECT(result.isMember(jss::error));
|
||||
BEAST_EXPECT(result[jss::error] == "srcCurMalformed");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcSrcCurMalformed);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Source currency is malformed.");
|
||||
|
||||
// Test rpc::tuning::max_auto_src_cur source currencies.
|
||||
numSrc.clear();
|
||||
@@ -189,7 +192,9 @@ public:
|
||||
g.signal();
|
||||
});
|
||||
BEAST_EXPECT(g.waitFor(5s));
|
||||
BEAST_EXPECT(result.isMember(jss::error));
|
||||
BEAST_EXPECT(result[jss::error] == "internal");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInternal);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Internal error.");
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/ApiVersion.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
@@ -318,7 +319,9 @@ public:
|
||||
g.signal();
|
||||
});
|
||||
BEAST_EXPECT(g.waitFor(5s));
|
||||
BEAST_EXPECT(result.isMember(jss::error));
|
||||
BEAST_EXPECT(result[jss::error] == "srcCurMalformed");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcSrcCurMalformed);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Source currency is malformed.");
|
||||
|
||||
// Test rpc::tuning::max_auto_src_cur source currencies.
|
||||
for (auto i = 0; i < (rpc::tuning::kMaxAutoSrcCur - 1); ++i)
|
||||
@@ -341,7 +344,9 @@ public:
|
||||
g.signal();
|
||||
});
|
||||
BEAST_EXPECT(g.waitFor(5s));
|
||||
BEAST_EXPECT(result.isMember(jss::error));
|
||||
BEAST_EXPECT(result[jss::error] == "internal");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInternal);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Internal error.");
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <xrpl/ledger/Dir.h>
|
||||
#include <xrpl/ledger/ReadView.h>
|
||||
#include <xrpl/protocol/ApiVersion.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/KeyType.h>
|
||||
@@ -1009,6 +1010,7 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
auto const jrr =
|
||||
env.rpc("json", "account_channels", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'account'.");
|
||||
};
|
||||
|
||||
@@ -1028,6 +1030,7 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
auto const jrr =
|
||||
env.rpc("json", "account_channels", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'destination_account'.");
|
||||
};
|
||||
|
||||
@@ -1038,6 +1041,55 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
testInvalidDestAccountParam(json::Value(json::ValueType::Object));
|
||||
testInvalidDestAccountParam(json::Value(json::ValueType::Array));
|
||||
}
|
||||
{
|
||||
// An empty destination_account is no destination at all.
|
||||
json::Value params;
|
||||
params[jss::account] = alice.human();
|
||||
params[jss::destination_account] = "";
|
||||
auto const jrr = env.rpc("json", "account_channels", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::channels].size() == 1);
|
||||
BEAST_EXPECT(jrr[jss::channels][0u][jss::channel_id] == chan1Str);
|
||||
BEAST_EXPECT(jrr[jss::channels][0u][jss::destination_account] == bob.human());
|
||||
}
|
||||
{
|
||||
// A malformed account is reported without the ledger fields.
|
||||
json::Value params;
|
||||
params[jss::account] = "llIIOO";
|
||||
auto const jrr = env.rpc("json", "account_channels", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Account malformed.");
|
||||
BEAST_EXPECT(!jrr.isMember(jss::ledger_index));
|
||||
BEAST_EXPECT(!jrr.isMember(jss::ledger_current_index));
|
||||
}
|
||||
{
|
||||
// A bad limit is reported before an account that is not found.
|
||||
json::Value params;
|
||||
params[jss::account] = Account("bogie").human();
|
||||
params[jss::limit] = 0;
|
||||
auto const jrr = env.rpc("json", "account_channels", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'limit'.");
|
||||
}
|
||||
{
|
||||
// A non-string marker names the field; one that does not parse does not.
|
||||
json::Value params;
|
||||
params[jss::account] = alice.human();
|
||||
params[jss::marker] = 1;
|
||||
auto const notString =
|
||||
env.rpc("json", "account_channels", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(notString[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(notString[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(notString[jss::error_message] == "Invalid field 'marker', not string.");
|
||||
|
||||
params[jss::marker] = "NOT_A_MARKER";
|
||||
auto const malformed =
|
||||
env.rpc("json", "account_channels", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(malformed[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(malformed[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(malformed[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
{
|
||||
auto const r = env.rpc("account_channels", alice.human(), bob.human());
|
||||
BEAST_EXPECT(r[jss::result][jss::channels].size() == 1);
|
||||
@@ -1181,7 +1233,34 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
{
|
||||
// degenerate case
|
||||
auto const r = testLimit(env, alice, 0);
|
||||
BEAST_EXPECT(r.isMember(jss::error_message));
|
||||
BEAST_EXPECT(r[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(r[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(r[jss::error_message] == "Invalid field 'limit'.");
|
||||
}
|
||||
|
||||
{
|
||||
// The marker's start hint may have a leading '+', and anything after a second
|
||||
// comma is ignored.
|
||||
auto const first = testLimit(env, alice, 1);
|
||||
auto const marker = first[jss::marker].asString();
|
||||
auto const comma = marker.find(',');
|
||||
BEAST_EXPECT(comma != std::string::npos);
|
||||
|
||||
auto const rest = testLimit(
|
||||
env,
|
||||
alice,
|
||||
std::nullopt,
|
||||
marker.substr(0, comma) + ",+" + marker.substr(comma + 1) + ",ignored");
|
||||
BEAST_EXPECT(rest[jss::channels].size() == bobs.size() - 1);
|
||||
|
||||
std::set<std::string> found{
|
||||
first[jss::channels][0u][jss::destination_account].asString(),
|
||||
};
|
||||
|
||||
for (auto const& c : rest[jss::channels])
|
||||
BEAST_EXPECT(found.insert(c[jss::destination_account].asString()).second);
|
||||
|
||||
BEAST_EXPECT(found == bobsB58);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1250,7 +1329,12 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
auto const rs =
|
||||
env.rpc("json", "channel_authorize", args.toStyledString())[jss::result];
|
||||
auto const error = apiVersion < 2u ? "invalidParams" : "badKeyType";
|
||||
auto const errorCode = apiVersion < 2u ? RpcInvalidParams : RpcBadKeyType;
|
||||
auto const errorMessage =
|
||||
apiVersion < 2u ? "Invalid field 'key_type'." : "Bad key type.";
|
||||
BEAST_EXPECT(rs[jss::error] == error);
|
||||
BEAST_EXPECT(rs[jss::error_code] == errorCode);
|
||||
BEAST_EXPECT(rs[jss::error_message] == errorMessage);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1339,22 +1423,40 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
auto const pkAsHex = sliceToHex(pk.slice());
|
||||
auto rv = env.rpc("channel_verify", pkAsHex, chan1Str, "1000x", sig);
|
||||
BEAST_EXPECT(rv[jss::error] == "channelAmtMalformed");
|
||||
BEAST_EXPECT(rv[jss::error_code] == RpcChannelAmtMalformed);
|
||||
BEAST_EXPECT(rv[jss::error_message] == "Payment channel amount is malformed.");
|
||||
rv = env.rpc("channel_verify", pkAsHex, chan1Str, "1000 ", sig);
|
||||
BEAST_EXPECT(rv[jss::error] == "channelAmtMalformed");
|
||||
BEAST_EXPECT(rv[jss::error_code] == RpcChannelAmtMalformed);
|
||||
BEAST_EXPECT(rv[jss::error_message] == "Payment channel amount is malformed.");
|
||||
rv = env.rpc("channel_verify", pkAsHex, chan1Str, "x1000", sig);
|
||||
BEAST_EXPECT(rv[jss::error] == "channelAmtMalformed");
|
||||
BEAST_EXPECT(rv[jss::error_code] == RpcChannelAmtMalformed);
|
||||
BEAST_EXPECT(rv[jss::error_message] == "Payment channel amount is malformed.");
|
||||
rv = env.rpc("channel_verify", pkAsHex, chan1Str, "x", sig);
|
||||
BEAST_EXPECT(rv[jss::error] == "channelAmtMalformed");
|
||||
BEAST_EXPECT(rv[jss::error_code] == RpcChannelAmtMalformed);
|
||||
BEAST_EXPECT(rv[jss::error_message] == "Payment channel amount is malformed.");
|
||||
rv = env.rpc("channel_verify", pkAsHex, chan1Str, " ", sig);
|
||||
BEAST_EXPECT(rv[jss::error] == "channelAmtMalformed");
|
||||
BEAST_EXPECT(rv[jss::error_code] == RpcChannelAmtMalformed);
|
||||
BEAST_EXPECT(rv[jss::error_message] == "Payment channel amount is malformed.");
|
||||
rv = env.rpc("channel_verify", pkAsHex, chan1Str, "1000 1000", sig);
|
||||
BEAST_EXPECT(rv[jss::error] == "channelAmtMalformed");
|
||||
BEAST_EXPECT(rv[jss::error_code] == RpcChannelAmtMalformed);
|
||||
BEAST_EXPECT(rv[jss::error_message] == "Payment channel amount is malformed.");
|
||||
rv = env.rpc("channel_verify", pkAsHex, chan1Str, "1,000", sig);
|
||||
BEAST_EXPECT(rv[jss::error] == "channelAmtMalformed");
|
||||
BEAST_EXPECT(rv[jss::error_code] == RpcChannelAmtMalformed);
|
||||
BEAST_EXPECT(rv[jss::error_message] == "Payment channel amount is malformed.");
|
||||
rv = env.rpc("channel_verify", pkAsHex, chan1Str, " 1000", sig);
|
||||
BEAST_EXPECT(rv[jss::error] == "channelAmtMalformed");
|
||||
BEAST_EXPECT(rv[jss::error_code] == RpcChannelAmtMalformed);
|
||||
BEAST_EXPECT(rv[jss::error_message] == "Payment channel amount is malformed.");
|
||||
rv = env.rpc("channel_verify", pkAsHex, chan1Str, "", sig);
|
||||
BEAST_EXPECT(rv[jss::error] == "channelAmtMalformed");
|
||||
BEAST_EXPECT(rv[jss::error_code] == RpcChannelAmtMalformed);
|
||||
BEAST_EXPECT(rv[jss::error_message] == "Payment channel amount is malformed.");
|
||||
}
|
||||
{
|
||||
// malformed channel
|
||||
@@ -1363,22 +1465,34 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
chan1StrBad.pop_back();
|
||||
auto rv = env.rpc("channel_verify", pkAsHex, chan1StrBad, "1000", sig);
|
||||
BEAST_EXPECT(rv[jss::error] == "channelMalformed");
|
||||
BEAST_EXPECT(rv[jss::error_code] == RpcChannelMalformed);
|
||||
BEAST_EXPECT(rv[jss::error_message] == "Payment channel is malformed.");
|
||||
rv = env.rpc("channel_authorize", "alice", chan1StrBad, "1000");
|
||||
BEAST_EXPECT(rv[jss::error] == "channelMalformed");
|
||||
BEAST_EXPECT(rv[jss::error_code] == RpcChannelMalformed);
|
||||
BEAST_EXPECT(rv[jss::error_message] == "Payment channel is malformed.");
|
||||
|
||||
chan1StrBad = chan1Str;
|
||||
chan1StrBad.push_back('0');
|
||||
rv = env.rpc("channel_verify", pkAsHex, chan1StrBad, "1000", sig);
|
||||
BEAST_EXPECT(rv[jss::error] == "channelMalformed");
|
||||
BEAST_EXPECT(rv[jss::error_code] == RpcChannelMalformed);
|
||||
BEAST_EXPECT(rv[jss::error_message] == "Payment channel is malformed.");
|
||||
rv = env.rpc("channel_authorize", "alice", chan1StrBad, "1000");
|
||||
BEAST_EXPECT(rv[jss::error] == "channelMalformed");
|
||||
BEAST_EXPECT(rv[jss::error_code] == RpcChannelMalformed);
|
||||
BEAST_EXPECT(rv[jss::error_message] == "Payment channel is malformed.");
|
||||
|
||||
chan1StrBad = chan1Str;
|
||||
chan1StrBad.back() = 'x';
|
||||
rv = env.rpc("channel_verify", pkAsHex, chan1StrBad, "1000", sig);
|
||||
BEAST_EXPECT(rv[jss::error] == "channelMalformed");
|
||||
BEAST_EXPECT(rv[jss::error_code] == RpcChannelMalformed);
|
||||
BEAST_EXPECT(rv[jss::error_message] == "Payment channel is malformed.");
|
||||
rv = env.rpc("channel_authorize", "alice", chan1StrBad, "1000");
|
||||
BEAST_EXPECT(rv[jss::error] == "channelMalformed");
|
||||
BEAST_EXPECT(rv[jss::error_code] == RpcChannelMalformed);
|
||||
BEAST_EXPECT(rv[jss::error_message] == "Payment channel is malformed.");
|
||||
}
|
||||
{
|
||||
// channel_id is not a string.
|
||||
@@ -1391,6 +1505,8 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
auto const ra =
|
||||
env.rpc("json", "channel_authorize", args.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(ra[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(ra[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(ra[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
{
|
||||
// channel_id is not a string.
|
||||
@@ -1403,6 +1519,8 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
auto const rv =
|
||||
env.rpc("json", "channel_verify", args.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(rv[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(rv[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(rv[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
{
|
||||
// give an ill formed base 58 public key
|
||||
@@ -1461,6 +1579,8 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
// Try to authorize using an unknown key type, except an error:
|
||||
auto const rs1 = env.rpc("channel_authorize", "charlie", "nyx", chan, "1000");
|
||||
BEAST_EXPECT(rs1[jss::error] == "badKeyType");
|
||||
BEAST_EXPECT(rs1[jss::error_code] == RpcBadKeyType);
|
||||
BEAST_EXPECT(rs1[jss::error_message] == "Bad key type.");
|
||||
|
||||
// Try to authorize using secp256k1; the authorization _should_
|
||||
// succeed but the verification should fail:
|
||||
@@ -1486,10 +1606,16 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
// send malformed amounts rpc requests
|
||||
auto rs = env.rpc("channel_authorize", "alice", chan1Str, "1000x");
|
||||
BEAST_EXPECT(rs[jss::error] == "channelAmtMalformed");
|
||||
BEAST_EXPECT(rs[jss::error_code] == RpcChannelAmtMalformed);
|
||||
BEAST_EXPECT(rs[jss::error_message] == "Payment channel amount is malformed.");
|
||||
rs = env.rpc("channel_authorize", "alice", chan1Str, "x1000");
|
||||
BEAST_EXPECT(rs[jss::error] == "channelAmtMalformed");
|
||||
BEAST_EXPECT(rs[jss::error_code] == RpcChannelAmtMalformed);
|
||||
BEAST_EXPECT(rs[jss::error_message] == "Payment channel amount is malformed.");
|
||||
rs = env.rpc("channel_authorize", "alice", chan1Str, "x");
|
||||
BEAST_EXPECT(rs[jss::error] == "channelAmtMalformed");
|
||||
BEAST_EXPECT(rs[jss::error_code] == RpcChannelAmtMalformed);
|
||||
BEAST_EXPECT(rs[jss::error_message] == "Payment channel amount is malformed.");
|
||||
{
|
||||
// Missing channel_id
|
||||
json::Value args{json::ValueType::Object};
|
||||
@@ -1498,6 +1624,8 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
args[jss::passphrase] = "passphrase_can_be_anything";
|
||||
rs = env.rpc("json", "channel_authorize", args.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(rs[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(rs[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(rs[jss::error_message] == "Missing field 'channel_id'.");
|
||||
}
|
||||
{
|
||||
// Missing amount
|
||||
@@ -1507,6 +1635,8 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
args[jss::passphrase] = "passphrase_can_be_anything";
|
||||
rs = env.rpc("json", "channel_authorize", args.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(rs[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(rs[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(rs[jss::error_message] == "Missing field 'amount'.");
|
||||
}
|
||||
{
|
||||
// Missing key_type and no secret.
|
||||
@@ -1516,6 +1646,8 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
args[jss::passphrase] = "passphrase_can_be_anything";
|
||||
rs = env.rpc("json", "channel_authorize", args.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(rs[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(rs[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(rs[jss::error_message] == "Missing field 'secret'.");
|
||||
}
|
||||
{
|
||||
// Both passphrase and seed specified.
|
||||
@@ -1527,6 +1659,11 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
args[jss::seed] = "seed can be anything";
|
||||
rs = env.rpc("json", "channel_authorize", args.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(rs[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(rs[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
rs[jss::error_message] ==
|
||||
"Exactly one of the following must be specified: passphrase, secret, seed or "
|
||||
"seed_hex");
|
||||
}
|
||||
{
|
||||
// channel_id is not exact hex.
|
||||
@@ -1537,6 +1674,8 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
args[jss::passphrase] = "passphrase_can_be_anything";
|
||||
rs = env.rpc("json", "channel_authorize", args.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(rs[jss::error] == "channelMalformed");
|
||||
BEAST_EXPECT(rs[jss::error_code] == RpcChannelMalformed);
|
||||
BEAST_EXPECT(rs[jss::error_message] == "Payment channel is malformed.");
|
||||
}
|
||||
{
|
||||
// amount is not a string
|
||||
@@ -1547,6 +1686,8 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
args[jss::passphrase] = "passphrase_can_be_anything";
|
||||
rs = env.rpc("json", "channel_authorize", args.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(rs[jss::error] == "channelAmtMalformed");
|
||||
BEAST_EXPECT(rs[jss::error_code] == RpcChannelAmtMalformed);
|
||||
BEAST_EXPECT(rs[jss::error_message] == "Payment channel amount is malformed.");
|
||||
}
|
||||
{
|
||||
// Amount is not a decimal string.
|
||||
@@ -1557,6 +1698,8 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
args[jss::passphrase] = "passphrase_can_be_anything";
|
||||
rs = env.rpc("json", "channel_authorize", args.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(rs[jss::error] == "channelAmtMalformed");
|
||||
BEAST_EXPECT(rs[jss::error_code] == RpcChannelAmtMalformed);
|
||||
BEAST_EXPECT(rs[jss::error_message] == "Payment channel amount is malformed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1807,6 +1950,8 @@ struct PayChan_test : public beast::unit_test::Suite
|
||||
)*";
|
||||
auto const r = env.rpc("json", "channel_verify", txn);
|
||||
BEAST_EXPECT(r["result"]["error"] == "publicMalformed");
|
||||
BEAST_EXPECT(r["result"]["error_code"] == RpcPublicMalformed);
|
||||
BEAST_EXPECT(r["result"]["error_message"] == "Public key is malformed.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Quality.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
@@ -42,8 +43,9 @@ class ReducedOffer_test : public beast::unit_test::Suite
|
||||
{
|
||||
json::Value ledgerOffer = ledgerEntryOffer(env, acct, offerSeq);
|
||||
return !(
|
||||
ledgerOffer.isMember(jss::error) &&
|
||||
ledgerOffer[jss::error].asString() == "entryNotFound");
|
||||
ledgerOffer[jss::error].asString() == "entryNotFound" &&
|
||||
ledgerOffer[jss::error_code] == RpcEntryNotFound &&
|
||||
ledgerOffer[jss::error_message] == "Entry not found.");
|
||||
}
|
||||
|
||||
// Common code to clean up unneeded offers.
|
||||
|
||||
@@ -302,10 +302,14 @@ class SHAMapStore_test : public beast::unit_test::Suite
|
||||
}
|
||||
|
||||
static bool
|
||||
bad(json::Value const& json, ErrorCodeI error = RpcLgrNotFound)
|
||||
bad(json::Value const& json,
|
||||
std::string const& token,
|
||||
ErrorCodeI error,
|
||||
std::string const& message)
|
||||
{
|
||||
return json.isMember(jss::result) && rpc::containsError(json[jss::result]) &&
|
||||
json[jss::result][jss::error_code] == error;
|
||||
return json.isMember(jss::result) && json[jss::result][jss::error] == token &&
|
||||
json[jss::result][jss::error_code] == error &&
|
||||
json[jss::result][jss::error_message] == message;
|
||||
}
|
||||
|
||||
std::string
|
||||
@@ -883,7 +887,7 @@ public:
|
||||
std::map<std::uint32_t, json::Value const> ledgers;
|
||||
|
||||
auto ledgerTmp = env.rpc("ledger", "0");
|
||||
BEAST_EXPECT(bad(ledgerTmp));
|
||||
BEAST_EXPECT(bad(ledgerTmp, "lgrNotFound", RpcLgrNotFound, "ledgerNotFound"));
|
||||
|
||||
ledgers.emplace(1, env.rpc("ledger", "1"));
|
||||
BEAST_EXPECT(goodLedger(env, ledgers[1], "1"));
|
||||
@@ -895,10 +899,10 @@ public:
|
||||
BEAST_EXPECT(goodLedger(env, ledgerTmp, "3"));
|
||||
|
||||
ledgerTmp = env.rpc("ledger", "4");
|
||||
BEAST_EXPECT(bad(ledgerTmp));
|
||||
BEAST_EXPECT(bad(ledgerTmp, "lgrNotFound", RpcLgrNotFound, "ledgerNotFound"));
|
||||
|
||||
ledgerTmp = env.rpc("ledger", "100");
|
||||
BEAST_EXPECT(bad(ledgerTmp));
|
||||
BEAST_EXPECT(bad(ledgerTmp, "lgrNotFound", RpcLgrNotFound, "ledgerNotFound"));
|
||||
|
||||
auto const firstSeq = waitForReady(env);
|
||||
auto lastRotated = firstSeq - 1;
|
||||
@@ -987,7 +991,7 @@ public:
|
||||
// Because advisory_delete is unset,
|
||||
// "can_delete" is disabled.
|
||||
auto const canDelete = env.rpc("can_delete");
|
||||
BEAST_EXPECT(bad(canDelete, RpcNotEnabled));
|
||||
BEAST_EXPECT(bad(canDelete, "notEnabled", RpcNotEnabled, "Not enabled in configuration."));
|
||||
|
||||
// Close ledgers without triggering a rotate
|
||||
for (; ledgerSeq < lastRotated + kDeleteInterval; ++ledgerSeq)
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
#include <xrpl/tx/apply.h>
|
||||
#include <xrpl/tx/applySteps.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
@@ -3550,6 +3551,101 @@ public:
|
||||
BEAST_EXPECT(sponsoringOwnerCount(env, sponsor2) == 0);
|
||||
}
|
||||
|
||||
{
|
||||
// Bytecode Escrow: its reserve scales with the Bytecode size, so
|
||||
// every leg of a sponsorship has to move the whole weight.
|
||||
auto env = Env{*this, testableAmendments()};
|
||||
|
||||
env.fund(XRP(1000000), alice, bob, sponsor, sponsor2);
|
||||
env.close();
|
||||
|
||||
auto const seq = env.seq(alice);
|
||||
env(escrow::create(alice, bob, XRP(100)),
|
||||
escrow::kCondition(escrow::kCb1),
|
||||
escrow::kCancelTime(env.now() + 100s));
|
||||
env.close();
|
||||
|
||||
auto const escrowKeylet = keylet::escrow(alice, SeqProxy::rawSequence(seq));
|
||||
std::size_t const bytecodeSize = 1200;
|
||||
std::uint32_t const bytecodeWeight = 3; // ceil(1200 / 500)
|
||||
|
||||
if (!cosigning)
|
||||
{
|
||||
env(sponsor::set_reserve(sponsor, 0, bytecodeWeight), sponsor::SponseeAcc(alice));
|
||||
env(sponsor::set_reserve(sponsor2, 0, bytecodeWeight), sponsor::SponseeAcc(alice));
|
||||
env.close();
|
||||
}
|
||||
|
||||
// EscrowCreate's preclaim runs the WASM preflight, so a real
|
||||
// 1200-byte contract cannot be assembled from here; the Bytecode
|
||||
// field is injected directly and the owner's OwnerCount restored
|
||||
// to the weight such a create would have charged.
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal) -> bool {
|
||||
auto const existing = view.read(escrowKeylet);
|
||||
if (!existing)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto const escrowSle = std::make_shared<SLE>(*existing);
|
||||
auto const account = std::make_shared<SLE>(*view.read(keylet::account(alice.id())));
|
||||
escrowSle->setFieldVL(sfBytecode, Blob(bytecodeSize, 0x00));
|
||||
account->setFieldU32(sfOwnerCount, bytecodeWeight);
|
||||
view.rawReplace(escrowSle);
|
||||
view.rawReplace(account);
|
||||
return true;
|
||||
});
|
||||
BEAST_EXPECT(ownerCount(env, alice) == bytecodeWeight);
|
||||
|
||||
std::optional<Sig> const sponsorSig =
|
||||
cosigning ? std::optional<Sig>(Sig(sfSponsorSignature, sponsor)) : std::nullopt;
|
||||
std::optional<Sig> const sponsor2Sig =
|
||||
cosigning ? std::optional<Sig>(Sig(sfSponsorSignature, sponsor2)) : std::nullopt;
|
||||
|
||||
// create sponsor: charges the whole bytecode weight, not 1
|
||||
if (sponsorSig)
|
||||
{
|
||||
env(sponsor::transfer(alice, tfSponsorshipCreate, escrowKeylet.key),
|
||||
sponsor::As(sponsor, spfSponsorReserve),
|
||||
*sponsorSig);
|
||||
}
|
||||
else
|
||||
{
|
||||
env(sponsor::transfer(alice, tfSponsorshipCreate, escrowKeylet.key),
|
||||
sponsor::As(sponsor, spfSponsorReserve));
|
||||
}
|
||||
|
||||
BEAST_EXPECT(sponsoredOwnerCount(env, alice) == bytecodeWeight);
|
||||
BEAST_EXPECT(sponsoringOwnerCount(env, sponsor) == bytecodeWeight);
|
||||
BEAST_EXPECT(env.le(escrowKeylet)->getAccountID(sfSponsor) == sponsor.id());
|
||||
|
||||
// transfer sponsor: moves the whole weight between the two sponsors
|
||||
if (sponsor2Sig)
|
||||
{
|
||||
env(sponsor::transfer(alice, tfSponsorshipReassign, escrowKeylet.key),
|
||||
sponsor::As(sponsor2, spfSponsorReserve),
|
||||
*sponsor2Sig);
|
||||
}
|
||||
else
|
||||
{
|
||||
env(sponsor::transfer(alice, tfSponsorshipReassign, escrowKeylet.key),
|
||||
sponsor::As(sponsor2, spfSponsorReserve));
|
||||
}
|
||||
|
||||
BEAST_EXPECT(sponsoredOwnerCount(env, alice) == bytecodeWeight);
|
||||
BEAST_EXPECT(sponsoringOwnerCount(env, sponsor) == 0);
|
||||
BEAST_EXPECT(sponsoringOwnerCount(env, sponsor2) == bytecodeWeight);
|
||||
BEAST_EXPECT(env.le(escrowKeylet)->getAccountID(sfSponsor) == sponsor2.id());
|
||||
|
||||
// end sponsor: hands the whole weight back to the owner
|
||||
env(sponsor::transfer(alice, tfSponsorshipEnd, escrowKeylet.key));
|
||||
|
||||
BEAST_EXPECT(ownerCount(env, alice) == bytecodeWeight);
|
||||
BEAST_EXPECT(sponsoredOwnerCount(env, alice) == 0);
|
||||
BEAST_EXPECT(sponsoringOwnerCount(env, sponsor) == 0);
|
||||
BEAST_EXPECT(sponsoringOwnerCount(env, sponsor2) == 0);
|
||||
BEAST_EXPECT(!env.le(escrowKeylet)->isFieldPresent(sfSponsor));
|
||||
}
|
||||
|
||||
Account const gw("gw");
|
||||
auto const usd = gw["usd"];
|
||||
{
|
||||
@@ -4405,6 +4501,89 @@ public:
|
||||
BEAST_EXPECT(!sle->isFieldPresent(sfRemainingOwnerCount));
|
||||
}
|
||||
|
||||
// An escrow carrying Bytecode costs one owner count per 500 bytes, so
|
||||
// sponsoring one must move that full weight rather than a single unit.
|
||||
void
|
||||
testBytecodeEscrowReserve()
|
||||
{
|
||||
testcase("Bytecode escrow sponsorship reserve");
|
||||
using namespace test::jtx;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
auto const alice = Account{"alice"};
|
||||
auto const bob = Account{"bob"};
|
||||
auto const sponsor = Account{"sponsor"};
|
||||
|
||||
auto env = Env{*this, testableAmendments()};
|
||||
env.fund(XRP(1000000), alice, bob, sponsor);
|
||||
env.close();
|
||||
|
||||
auto const seq = env.seq(alice);
|
||||
env(escrow::create(alice, bob, XRP(100)),
|
||||
escrow::kCondition(escrow::kCb1),
|
||||
escrow::kCancelTime(env.now() + 100s));
|
||||
env.close();
|
||||
|
||||
auto const escrowKeylet = keylet::escrow(alice, SeqProxy::rawSequence(seq));
|
||||
auto const sponsorKeylet = keylet::sponsorship(sponsor.id(), alice.id());
|
||||
std::size_t const bytecodeSize = 1200;
|
||||
std::uint32_t const bytecodeWeight = 3; // ceil(1200 / 500)
|
||||
BEAST_EXPECT(ownerCount(env, alice) == 1);
|
||||
|
||||
// Pre-fund exactly the bytecode weight
|
||||
env(sponsor::set_reserve(sponsor, 0, bytecodeWeight), sponsor::SponseeAcc(alice));
|
||||
env.close();
|
||||
if (auto const sle = env.le(sponsorKeylet); BEAST_EXPECT(sle))
|
||||
{
|
||||
BEAST_EXPECT(sle->getFieldU32(sfRemainingOwnerCount) == bytecodeWeight);
|
||||
}
|
||||
|
||||
// Synthesize a bytecode escrow. EscrowCreate's preclaim runs the WASM
|
||||
// preflight, so a real 1200-byte contract cannot be assembled from
|
||||
// here; the Bytecode field is injected directly and the owner's
|
||||
// OwnerCount restored to the weight such a create would have charged.
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal) -> bool {
|
||||
auto const existing = view.read(escrowKeylet);
|
||||
if (!existing)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto const escrowSle = std::make_shared<SLE>(*existing);
|
||||
auto const account = std::make_shared<SLE>(*view.read(keylet::account(alice.id())));
|
||||
escrowSle->setFieldVL(sfBytecode, Blob(bytecodeSize, 0x00));
|
||||
account->setFieldU32(sfOwnerCount, bytecodeWeight);
|
||||
view.rawReplace(escrowSle);
|
||||
view.rawReplace(account);
|
||||
return true;
|
||||
});
|
||||
BEAST_EXPECT(ownerCount(env, alice) == bytecodeWeight);
|
||||
|
||||
// Create must charge the full bytecode weight (3), not 1: counting the
|
||||
// escrow as a single unit would leave 2 pre-funded units unspent.
|
||||
env(sponsor::transfer(alice, tfSponsorshipCreate, escrowKeylet.key),
|
||||
sponsor::As(sponsor, spfSponsorReserve));
|
||||
|
||||
BEAST_EXPECT(sponsoredOwnerCount(env, alice) == bytecodeWeight);
|
||||
BEAST_EXPECT(sponsoringOwnerCount(env, sponsor) == bytecodeWeight);
|
||||
// All pre-funded units consumed (drained to absent).
|
||||
if (auto const sle = env.le(sponsorKeylet); BEAST_EXPECT(sle))
|
||||
{
|
||||
BEAST_EXPECT(!sle->isFieldPresent(sfRemainingOwnerCount));
|
||||
}
|
||||
|
||||
// End hands the same weight back; create bumped by the same amount, so
|
||||
// the counters return to 0 (counting 1 here would underflow).
|
||||
env(sponsor::transfer(alice, tfSponsorshipEnd, escrowKeylet.key));
|
||||
|
||||
BEAST_EXPECT(ownerCount(env, alice) == bytecodeWeight);
|
||||
BEAST_EXPECT(sponsoredOwnerCount(env, alice) == 0);
|
||||
BEAST_EXPECT(sponsoringOwnerCount(env, sponsor) == 0);
|
||||
if (auto const sle = env.le(escrowKeylet); BEAST_EXPECT(sle))
|
||||
{
|
||||
BEAST_EXPECT(!sle->isFieldPresent(sfSponsor));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testSponsoredTrustLineNoFreeReserve()
|
||||
{
|
||||
@@ -5790,6 +5969,7 @@ protected:
|
||||
testTransferSponsor(jtx::testableAmendments());
|
||||
testTransferSponsor(jtx::testableAmendments() - fixCleanup3_4_0);
|
||||
testLegacySignerListReserve();
|
||||
testBytecodeEscrowReserve();
|
||||
testSponsorFee();
|
||||
testSponsorAccount();
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Protocol.h>
|
||||
@@ -215,8 +216,9 @@ struct TransactionProposalCancel_test : public beast::unit_test::Suite
|
||||
}
|
||||
|
||||
// The target account may refuse any proposal made for it, at any point in
|
||||
// its lifecycle, without owning the object: anyone can create a proposal
|
||||
// against any account and tie up one of its tickets (On-Chain Cosigner spec §7.2).
|
||||
// its lifecycle, without owning the object: any of its signers, an
|
||||
// authorized delegate, or that delegate's signers can create one and tie
|
||||
// up one of its tickets (XLS-0103 §7.2).
|
||||
void
|
||||
testTargetCancel(FeatureBitset features)
|
||||
{
|
||||
@@ -683,6 +685,25 @@ struct TransactionProposalCancel_test : public beast::unit_test::Suite
|
||||
BEAST_EXPECT(env.le(keylet::txProposal(proposalID)));
|
||||
BEAST_EXPECT(ownerCount(env, alice) == proposal::kProposalOwnerCount);
|
||||
}
|
||||
|
||||
// Paying with a ticket changes none of that. The failed cancel still
|
||||
// consumes carol's ticket, and nothing else moves: the proposal and
|
||||
// its reserve stay as they were.
|
||||
{
|
||||
uint256 const proposalID = makeProposal(env, alice, target, bob);
|
||||
std::uint32_t const cancelTicket = proposal::createTicket(env, carol);
|
||||
auto const aliceOwnerCount = ownerCount(env, alice);
|
||||
|
||||
env(proposal::cancel(carol, proposalID),
|
||||
ticket::Use(cancelTicket),
|
||||
Ter(tecNO_PERMISSION));
|
||||
env.close();
|
||||
|
||||
BEAST_EXPECT(env.le(keylet::txProposal(proposalID)));
|
||||
BEAST_EXPECT(!env.le(keylet::ticket(carol.id(), SeqProxy::rawTicket(cancelTicket))));
|
||||
BEAST_EXPECT(ownerCount(env, alice) == aliceOwnerCount);
|
||||
BEAST_EXPECT(ownerCount(env, carol) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
// A Cancel works as an inner Batch transaction, where each inner runs its
|
||||
@@ -1012,15 +1033,25 @@ struct TransactionProposalCancel_test : public beast::unit_test::Suite
|
||||
{
|
||||
json::Value noTicket;
|
||||
noTicket[jss::account] = target.human();
|
||||
BEAST_EXPECT(ledgerEntry(noTicket)[jss::error] == "malformedRequest");
|
||||
auto const noTicketResult = ledgerEntry(noTicket);
|
||||
BEAST_EXPECT(noTicketResult[jss::error] == "malformedRequest");
|
||||
BEAST_EXPECT(noTicketResult[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(noTicketResult[jss::error_message] == "Missing field 'ticket_seq'.");
|
||||
|
||||
json::Value noAccount;
|
||||
noAccount[jss::ticket_seq] = ticketSeq;
|
||||
BEAST_EXPECT(ledgerEntry(noAccount)[jss::error] == "malformedRequest");
|
||||
auto const noAccountResult = ledgerEntry(noAccount);
|
||||
BEAST_EXPECT(noAccountResult[jss::error] == "malformedRequest");
|
||||
BEAST_EXPECT(noAccountResult[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(noAccountResult[jss::error_message] == "Missing field 'account'.");
|
||||
|
||||
json::Value badAccount = byPair;
|
||||
badAccount[jss::account] = "not an account";
|
||||
BEAST_EXPECT(ledgerEntry(badAccount)[jss::error] == "malformedAddress");
|
||||
auto const badAccountResult = ledgerEntry(badAccount);
|
||||
BEAST_EXPECT(badAccountResult[jss::error] == "malformedAddress");
|
||||
BEAST_EXPECT(badAccountResult[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
badAccountResult[jss::error_message] == "Invalid field 'account', not AccountID.");
|
||||
}
|
||||
|
||||
// Listed for the proposer, who owns it, and not for the target.
|
||||
@@ -1037,6 +1068,8 @@ struct TransactionProposalCancel_test : public beast::unit_test::Suite
|
||||
{
|
||||
auto const jrr = ledgerEntry(byPair);
|
||||
BEAST_EXPECT(jrr[jss::error] == "entryNotFound");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcEntryNotFound);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Entry not found.");
|
||||
BEAST_EXPECT(!jrr.isMember(jss::node));
|
||||
BEAST_EXPECT(jrr[jss::index] == to_string(proposalID));
|
||||
}
|
||||
|
||||
@@ -1357,6 +1357,51 @@ struct TransactionProposalCreate_test : public beast::unit_test::Suite
|
||||
env.close();
|
||||
}
|
||||
|
||||
// A proposer may pay for the Create with one of its own Tickets. The
|
||||
// Ticket's reserve goes as the proposal's arrives, so the proposer's owner
|
||||
// count moves by the difference.
|
||||
void
|
||||
testTicketedCreate(FeatureBitset features)
|
||||
{
|
||||
testcase("create paid for with the proposer's own ticket");
|
||||
|
||||
using namespace jtx;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
Env env{*this, features};
|
||||
|
||||
Account const alice{"alice"}; // the proposer
|
||||
Account const target{"target"}; // the account the proposal is for
|
||||
Account const bob{"bob"};
|
||||
env.fund(XRP(10000), alice, target, bob);
|
||||
env.close();
|
||||
proposal::authorizeProposer(env, target, alice);
|
||||
|
||||
std::uint32_t const targetTicketSeq = proposal::createTicket(env, target);
|
||||
std::uint32_t const aliceTicketSeq = proposal::createTicket(env, alice);
|
||||
std::uint32_t const aliceSeq = env.seq(alice);
|
||||
std::uint32_t const targetOwnerCount = ownerCount(env, target);
|
||||
BEAST_EXPECT(ownerCount(env, alice) == 1);
|
||||
|
||||
// The proposal's reserve lands on alice less the Ticket she paid with,
|
||||
// and her Sequence is untouched.
|
||||
env(proposal::create(
|
||||
alice,
|
||||
proposal::unsignedPayload(env, pay(target, bob, XRP(1)), targetTicketSeq),
|
||||
proposal::expiration(env, 100s)),
|
||||
ticket::Use(aliceTicketSeq),
|
||||
proposal::verify::create());
|
||||
env.close();
|
||||
|
||||
BEAST_EXPECT(proposal::entry(env, target, targetTicketSeq));
|
||||
BEAST_EXPECT(!env.le(keylet::ticket(alice.id(), SeqProxy::rawTicket(aliceTicketSeq))));
|
||||
BEAST_EXPECT(env.seq(alice) == aliceSeq);
|
||||
BEAST_EXPECT(ownerCount(env, alice) == proposal::kProposalOwnerCount);
|
||||
|
||||
// The target's Ticket, the one the proposal is keyed to, stays.
|
||||
BEAST_EXPECT(ownerCount(env, target) == targetOwnerCount);
|
||||
}
|
||||
|
||||
// The proposal's reserve can instead be sponsored: the reserve is charged
|
||||
// to the sponsor's account, and the ledger object records the sponsor, the
|
||||
// same as any other reserve-sponsorable object (TransactionProposalCreate
|
||||
@@ -1728,6 +1773,7 @@ struct TransactionProposalCreate_test : public beast::unit_test::Suite
|
||||
testOtherTransactionTypes(all);
|
||||
testAuxiliaryCoSignatureTypes(all);
|
||||
testReserve(all);
|
||||
testTicketedCreate(all);
|
||||
testSponsoredReserve(all);
|
||||
testSponsorshipTransfer(all);
|
||||
testFeeSponsored(all);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <xrpl/basics/strHex.h>
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/TER.h>
|
||||
@@ -66,6 +67,8 @@ class TrustAndBalance_test : public beast::unit_test::Suite
|
||||
// reflects this
|
||||
auto jrr = ledgerEntryState(env, gw, alice, "USD");
|
||||
BEAST_EXPECT(jrr[jss::error] == "entryNotFound");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcEntryNotFound);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Entry not found.");
|
||||
|
||||
// now create a credit limit
|
||||
env(trust(alice, gw["USD"](800)));
|
||||
@@ -100,6 +103,8 @@ class TrustAndBalance_test : public beast::unit_test::Suite
|
||||
// ensure line is deleted
|
||||
jrr = ledgerEntryState(env, gw, alice, "USD");
|
||||
BEAST_EXPECT(jrr[jss::error] == "entryNotFound");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcEntryNotFound);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Entry not found.");
|
||||
|
||||
// TODO Check in both owner books.
|
||||
|
||||
|
||||
@@ -3231,7 +3231,9 @@ public:
|
||||
|
||||
{
|
||||
auto const info = env.rpc("json", "account_info", to_string(prevLedgerWithQueue));
|
||||
BEAST_EXPECT(info.isMember(jss::result) && rpc::containsError(info[jss::result]));
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(info[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
env.close();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <test/jtx/Env.h>
|
||||
#include <test/jtx/TestHelpers.h>
|
||||
#include <test/jtx/amount.h>
|
||||
#include <test/jtx/escrow.h>
|
||||
#include <test/jtx/pay.h>
|
||||
#include <test/jtx/token.h>
|
||||
#include <test/jtx/trust.h>
|
||||
@@ -1330,6 +1331,51 @@ class InvariantsMisc_test : public InvariantsBase
|
||||
env(check::create(a1, a2, XRP(1)));
|
||||
return true;
|
||||
});
|
||||
|
||||
// An escrow's owner count scales with its Bytecode size, so
|
||||
// sponsoring one has to move that whole weight. Counting it as a
|
||||
// single unit leaves the sponsored counters short of the object's
|
||||
// real weight, which is what this check exists to catch.
|
||||
UInt256 escrowID;
|
||||
|
||||
doInvariantCheck(
|
||||
{{expectMessage}},
|
||||
[&](Account const& a1, Account const& a2, ApplyContext& ac) {
|
||||
auto const escrow = ac.view().peek(keylet::unchecked(escrowID));
|
||||
if (!escrow)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// ceil(1200 / 500) == 3 owner counts
|
||||
escrow->setFieldVL(sfBytecode, Blob(1200, 0x00));
|
||||
escrow->setAccountID(sfSponsor, a2.id());
|
||||
ac.view().update(escrow);
|
||||
|
||||
// Move the counters by a single unit, as a sponsorship
|
||||
// blind to the Bytecode weight would.
|
||||
auto const sle1 = ac.view().peek(keylet::account(a1.id()));
|
||||
auto const sle2 = ac.view().peek(keylet::account(a2.id()));
|
||||
if (!sle1 || !sle2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
sle1->setFieldU32(sfSponsoredOwnerCount, 1);
|
||||
sle2->setFieldU32(sfSponsoringOwnerCount, 1);
|
||||
ac.view().update(sle1);
|
||||
ac.view().update(sle2);
|
||||
return true;
|
||||
},
|
||||
XRPAmount{},
|
||||
STTx{ttACCOUNT_SET, [](STObject&) {}},
|
||||
{tecINVARIANT_FAILED, tefINVARIANT_FAILED},
|
||||
[&escrowID](Account const& a1, Account const& a2, Env& env) {
|
||||
using namespace std::chrono_literals;
|
||||
escrowID = keylet::escrow(a1.id(), SeqProxy::rawSequence(env.seq(a1))).key;
|
||||
env(escrow::create(a1, a2, XRP(1)),
|
||||
escrow::kCondition(escrow::kCb1),
|
||||
escrow::kCancelTime(env.now() + 100s));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -0,0 +1,549 @@
|
||||
#include <test/app/invariants/InvariantsBase.h>
|
||||
#include <test/jtx/Account.h>
|
||||
#include <test/jtx/Env.h>
|
||||
#include <test/jtx/amount.h>
|
||||
#include <test/jtx/pay.h>
|
||||
#include <test/jtx/proposal.h>
|
||||
#include <test/jtx/utility.h>
|
||||
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/beast/utility/Zero.h>
|
||||
#include <xrpl/ledger/ApplyView.h>
|
||||
#include <xrpl/ledger/helpers/ProposalHelpers.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Keylet.h>
|
||||
#include <xrpl/protocol/Protocol.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STArray.h>
|
||||
#include <xrpl/protocol/STLedgerEntry.h>
|
||||
#include <xrpl/protocol/STObject.h>
|
||||
#include <xrpl/protocol/STTx.h>
|
||||
#include <xrpl/protocol/SeqProxy.h>
|
||||
#include <xrpl/protocol/TER.h>
|
||||
#include <xrpl/protocol/TxFormats.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
#include <xrpl/tx/ApplyContext.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <source_location>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace xrpl::test {
|
||||
|
||||
class InvariantsTransactionProposal_test : public InvariantsBase
|
||||
{
|
||||
void
|
||||
testTransactionProposalInvariants()
|
||||
{
|
||||
using namespace jtx;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
// Submits a real proposal, so the entry is in the closed ledger before
|
||||
// the precheck runs and the precheck can modify it.
|
||||
std::optional<Keylet> liveProposalKeylet;
|
||||
std::optional<std::uint32_t> liveTicketSeq;
|
||||
Preclose const precloseLiveProposal =
|
||||
[&](Account const& owner, Account const& destination, Env& env) {
|
||||
auto const ticketSeq = proposal::createTicket(env, owner);
|
||||
auto const proposedTx =
|
||||
proposal::unsignedPayload(env, pay(owner, destination, XRP(1)), ticketSeq);
|
||||
liveProposalKeylet = keylet::txProposal(owner.id(), ticketSeq);
|
||||
liveTicketSeq = ticketSeq;
|
||||
env(proposal::create(owner, proposedTx, proposal::expiration(env, 100s)));
|
||||
return BEAST_EXPECT(env.le(*liveProposalKeylet));
|
||||
};
|
||||
|
||||
auto peekLiveProposal = [&](ApplyContext& ac) -> SLE::pointer {
|
||||
if (!liveProposalKeylet)
|
||||
return nullptr;
|
||||
return ac.view().peek(*liveProposalKeylet);
|
||||
};
|
||||
|
||||
// Deletes the live proposal as deleteProposal would: out of the
|
||||
// owner's directory, with the owner's reserve released.
|
||||
auto deleteLiveProposal = [&](Account const& owner, ApplyContext& ac) {
|
||||
auto const sle = peekLiveProposal(ac);
|
||||
if (!sle)
|
||||
return false;
|
||||
auto const account = ac.view().peek(keylet::account(owner.id()));
|
||||
if (!account)
|
||||
return false;
|
||||
account->at(sfOwnerCount) -=
|
||||
xrpl::proposal::proposalOwnerCount(sle->getFieldObject(sfProposedTransaction));
|
||||
ac.view().update(account);
|
||||
if (!ac.view().dirRemove(
|
||||
keylet::ownerDir(owner.id()), sle->getFieldU64(sfOwnerNode), sle->key(), false))
|
||||
return false;
|
||||
ac.view().erase(sle);
|
||||
return true;
|
||||
};
|
||||
|
||||
// Consumes one of the owner's Tickets as ticketDelete would.
|
||||
auto deleteTicket = [&](Account const& owner, std::uint32_t ticketSeq, ApplyContext& ac) {
|
||||
auto const ticket =
|
||||
ac.view().peek(keylet::ticket(owner.id(), SeqProxy::rawTicket(ticketSeq)));
|
||||
auto const account = ac.view().peek(keylet::account(owner.id()));
|
||||
if (!ticket || !account)
|
||||
return false;
|
||||
if (!ac.view().dirRemove(
|
||||
keylet::ownerDir(owner.id()),
|
||||
ticket->getFieldU64(sfOwnerNode),
|
||||
ticket->key(),
|
||||
false))
|
||||
return false;
|
||||
if (auto const ticketCount = account->getFieldU32(sfTicketCount); ticketCount > 1)
|
||||
{
|
||||
account->setFieldU32(sfTicketCount, ticketCount - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
account->makeFieldAbsent(sfTicketCount);
|
||||
}
|
||||
account->at(sfOwnerCount) -= 1;
|
||||
ac.view().update(account);
|
||||
ac.view().erase(ticket);
|
||||
return true;
|
||||
};
|
||||
|
||||
// A transaction outside the whitelist may not modify a proposal at
|
||||
// all; the invariant rejects it on the count, whatever field changed.
|
||||
testcase("TransactionProposal modified outside the whitelist");
|
||||
doInvariantCheck(
|
||||
{{"TransactionProposal changes do not match transaction result"}},
|
||||
[&](Account const&, Account const&, ApplyContext& ac) {
|
||||
auto const sle = peekLiveProposal(ac);
|
||||
if (!sle)
|
||||
return false;
|
||||
auto proposedTx = sle->getFieldObject(sfProposedTransaction);
|
||||
proposedTx.setFieldU32(
|
||||
sfTicketSequence, proposedTx.getFieldU32(sfTicketSequence) + 1);
|
||||
sle->setFieldObject(sfProposedTransaction, proposedTx);
|
||||
ac.view().update(sle);
|
||||
return true;
|
||||
},
|
||||
XRPAmount{},
|
||||
STTx{ttACCOUNT_SET, [](STObject&) {}},
|
||||
{tecINVARIANT_FAILED, tefINVARIANT_FAILED},
|
||||
precloseLiveProposal);
|
||||
|
||||
// Only stages the payload and the key it would live under; nothing
|
||||
// reaches the ledger, so a precheck that inserts the entry by hand
|
||||
// presents the invariant with a creation.
|
||||
std::optional<STObject> stagedPayload;
|
||||
std::optional<Keylet> stagedProposalKeylet;
|
||||
Preclose const precloseStagedPayload =
|
||||
[&](Account const& owner, Account const& destination, Env& env) {
|
||||
auto const ticketSeq = proposal::createTicket(env, owner);
|
||||
auto const proposedJson =
|
||||
proposal::unsignedPayload(env, pay(owner, destination, XRP(1)), ticketSeq);
|
||||
stagedPayload.emplace(parse(proposedJson));
|
||||
stagedProposalKeylet = keylet::txProposal(owner.id(), ticketSeq);
|
||||
return true;
|
||||
};
|
||||
|
||||
// Inserts the staged proposal as doApply would, with the owner's
|
||||
// reserve charged.
|
||||
auto insertStagedProposal = [&](Account const& owner, ApplyContext& ac) {
|
||||
if (!stagedPayload || !stagedProposalKeylet)
|
||||
return false;
|
||||
|
||||
auto const sle = std::make_shared<SLE>(*stagedProposalKeylet);
|
||||
sle->setAccountID(sfOwner, owner.id());
|
||||
sle->setFieldObject(sfProposedTransaction, *stagedPayload);
|
||||
sle->setFieldU32(sfExpiration, 1);
|
||||
sle->setFieldU64(sfOwnerNode, 0);
|
||||
ac.view().insert(sle);
|
||||
|
||||
auto const account = ac.view().peek(keylet::account(owner.id()));
|
||||
if (!account)
|
||||
return false;
|
||||
account->at(sfOwnerCount) += xrpl::proposal::proposalOwnerCount(*stagedPayload);
|
||||
ac.view().update(account);
|
||||
return true;
|
||||
};
|
||||
|
||||
testcase("TransactionProposal effect whitelist");
|
||||
doInvariantCheck(
|
||||
{{"TransactionProposal changes do not match transaction result"}},
|
||||
[&](Account const& owner, Account const&, ApplyContext& ac) {
|
||||
return insertStagedProposal(owner, ac);
|
||||
},
|
||||
XRPAmount{},
|
||||
STTx{ttACCOUNT_SET, [](STObject&) {}},
|
||||
{tecINVARIANT_FAILED, tefINVARIANT_FAILED},
|
||||
precloseStagedPayload);
|
||||
|
||||
// The harness runs no transactor, so a failed result has to be fed in
|
||||
// directly. A failed create must leave no trace.
|
||||
testcase("TransactionProposal failed create still inserts");
|
||||
doInvariantCheck(
|
||||
{{"TransactionProposal changes do not match transaction result"}},
|
||||
[&](Account const& owner, Account const&, ApplyContext& ac) {
|
||||
return insertStagedProposal(owner, ac);
|
||||
},
|
||||
XRPAmount{},
|
||||
STTx{ttTRANSACTION_PROPOSAL_CREATE, [](STObject&) {}},
|
||||
{tecINVARIANT_FAILED, tefINVARIANT_FAILED},
|
||||
precloseStagedPayload,
|
||||
TxAccount::None,
|
||||
std::source_location::current(),
|
||||
tecNO_PERMISSION);
|
||||
|
||||
// Reassigns the live proposal's reserve to a sponsor as a
|
||||
// SponsorshipTransfer would. The sponsored and sponsoring counts move
|
||||
// with it so that SponsorshipOwnerCountsMatch stays quiet.
|
||||
auto const reassignLiveProposal =
|
||||
[&](Account const& owner, Account const& sponsor, ApplyContext& ac) {
|
||||
auto const sle = peekLiveProposal(ac);
|
||||
if (!sle)
|
||||
return false;
|
||||
auto const reserve =
|
||||
xrpl::proposal::proposalOwnerCount(sle->getFieldObject(sfProposedTransaction));
|
||||
sle->setAccountID(sfSponsor, sponsor.id());
|
||||
ac.view().update(sle);
|
||||
|
||||
auto const account = ac.view().peek(keylet::account(owner.id()));
|
||||
auto const sponsorRoot = ac.view().peek(keylet::account(sponsor.id()));
|
||||
if (!account || !sponsorRoot)
|
||||
return false;
|
||||
account->at(sfSponsoredOwnerCount) += reserve;
|
||||
ac.view().update(account);
|
||||
sponsorRoot->at(sfSponsoringOwnerCount) += reserve;
|
||||
ac.view().update(sponsorRoot);
|
||||
return true;
|
||||
};
|
||||
|
||||
// A failed transfer must not have reassigned anything. The counters are
|
||||
// kept consistent so only the result mismatch is left to catch.
|
||||
testcase("TransactionProposal failed sponsorship transfer still reassigns");
|
||||
doInvariantCheck(
|
||||
{{"TransactionProposal changes do not match transaction result"}},
|
||||
reassignLiveProposal,
|
||||
XRPAmount{},
|
||||
STTx{ttSPONSORSHIP_TRANSFER, [](STObject&) {}},
|
||||
{tecINVARIANT_FAILED, tefINVARIANT_FAILED},
|
||||
precloseLiveProposal,
|
||||
TxAccount::None,
|
||||
std::source_location::current(),
|
||||
tecNO_PERMISSION);
|
||||
|
||||
// A proposal leaves the ledger only through TransactionProposalCancel
|
||||
// or together with the Ticket it is keyed to. The harness runs no
|
||||
// transactor, so each deletion below is staged by hand, releasing the
|
||||
// reserve as a real one would, to leave the deletion itself as the
|
||||
// only possible violation.
|
||||
testcase("TransactionProposal deletion outside the whitelist");
|
||||
doInvariantCheck(
|
||||
{{"TransactionProposal changes do not match transaction result"}},
|
||||
[&](Account const& owner, Account const&, ApplyContext& ac) {
|
||||
return deleteLiveProposal(owner, ac);
|
||||
},
|
||||
XRPAmount{},
|
||||
STTx{ttACCOUNT_SET, [](STObject&) {}},
|
||||
{tecINVARIANT_FAILED, tefINVARIANT_FAILED},
|
||||
precloseLiveProposal);
|
||||
|
||||
// The owner holds a second Ticket, one no proposal is keyed to.
|
||||
std::optional<std::uint32_t> spareTicketSeq;
|
||||
Preclose const precloseLiveProposalAndSpareTicket =
|
||||
[&](Account const& owner, Account const& destination, Env& env) {
|
||||
spareTicketSeq = proposal::createTicket(env, owner);
|
||||
return precloseLiveProposal(owner, destination, env);
|
||||
};
|
||||
|
||||
// Consuming some other Ticket of the owner's is no reason for the
|
||||
// proposal to go.
|
||||
testcase("TransactionProposal deleted with an unrelated ticket");
|
||||
doInvariantCheck(
|
||||
{{"TransactionProposal changes do not match transaction result"}},
|
||||
[&](Account const& owner, Account const&, ApplyContext& ac) {
|
||||
return spareTicketSeq && deleteTicket(owner, *spareTicketSeq, ac) &&
|
||||
deleteLiveProposal(owner, ac);
|
||||
},
|
||||
XRPAmount{},
|
||||
STTx{ttACCOUNT_SET, [](STObject&) {}},
|
||||
{tecINVARIANT_FAILED, tefINVARIANT_FAILED},
|
||||
precloseLiveProposalAndSpareTicket);
|
||||
|
||||
// And a deleted Ticket takes the proposal keyed to it along: here the
|
||||
// Ticket went and the proposal stayed behind.
|
||||
testcase("TransactionProposal outlives its ticket");
|
||||
doInvariantCheck(
|
||||
{{"TransactionProposal outlived the Ticket it is keyed to"}},
|
||||
[&](Account const& owner, Account const&, ApplyContext& ac) {
|
||||
return liveTicketSeq && deleteTicket(owner, *liveTicketSeq, ac);
|
||||
},
|
||||
XRPAmount{},
|
||||
STTx{ttACCOUNT_SET, [](STObject&) {}},
|
||||
{tecINVARIANT_FAILED, tefINVARIANT_FAILED},
|
||||
precloseLiveProposal);
|
||||
|
||||
// A Cancel names the live proposal and may pay with the owner's spare
|
||||
// Ticket. Both exist only once the preclose has run, so the Env is
|
||||
// built here rather than by the harness.
|
||||
struct CancelOptions
|
||||
{
|
||||
// The Cancel pays with A1's spare Ticket.
|
||||
bool paySpareTicket = false;
|
||||
TER initialResult = tesSUCCESS;
|
||||
};
|
||||
auto const checkCancel = [&](std::vector<std::string> const& expectLogs,
|
||||
Precheck const& precheck,
|
||||
std::initializer_list<TER> ters,
|
||||
Preclose const& preclose,
|
||||
CancelOptions const& options = CancelOptions(),
|
||||
std::source_location const& loc =
|
||||
std::source_location::current()) {
|
||||
Account const a1{"A1"};
|
||||
Account const a2{"A2"};
|
||||
Env env = makeEnv(testableAmendments());
|
||||
env.fund(XRP(1000), a1, a2);
|
||||
if (!BEAST_EXPECT(preclose(a1, a2, env)) || !BEAST_EXPECT(liveProposalKeylet))
|
||||
return;
|
||||
env.close();
|
||||
|
||||
STTx const tx{ttTRANSACTION_PROPOSAL_CANCEL, [&](STObject& obj) {
|
||||
obj.setAccountID(sfAccount, a1.id());
|
||||
obj.setFieldH256(sfProposalID, liveProposalKeylet->key);
|
||||
if (options.paySpareTicket && spareTicketSeq)
|
||||
{
|
||||
obj.setFieldU32(sfSequence, 0);
|
||||
obj.setFieldU32(sfTicketSequence, *spareTicketSeq);
|
||||
}
|
||||
}};
|
||||
doInvariantCheck(
|
||||
std::move(env),
|
||||
a1,
|
||||
a2,
|
||||
expectLogs,
|
||||
precheck,
|
||||
XRPAmount{},
|
||||
tx,
|
||||
ters,
|
||||
loc,
|
||||
options.initialResult);
|
||||
};
|
||||
|
||||
auto const cancelDeletesLiveProposal =
|
||||
[&](Account const& owner, Account const&, ApplyContext& ac) {
|
||||
return deleteLiveProposal(owner, ac);
|
||||
};
|
||||
|
||||
// A Cancel that did not succeed deleted nothing.
|
||||
testcase("TransactionProposal failed cancel still deletes");
|
||||
{
|
||||
CancelOptions options;
|
||||
options.initialResult = tecNO_PERMISSION;
|
||||
checkCancel(
|
||||
{{"TransactionProposal changes do not match transaction result"}},
|
||||
cancelDeletesLiveProposal,
|
||||
{tecINVARIANT_FAILED, tefINVARIANT_FAILED},
|
||||
precloseLiveProposal,
|
||||
options);
|
||||
}
|
||||
|
||||
// A Cancel cannot spend a reserved Ticket, so the proposal it deletes
|
||||
// never goes with its Ticket.
|
||||
testcase("TransactionProposal cancel consumes the reserved ticket");
|
||||
checkCancel(
|
||||
{{"TransactionProposal changes do not match transaction result"}},
|
||||
[&](Account const& owner, Account const&, ApplyContext& ac) {
|
||||
return liveTicketSeq && deleteTicket(owner, *liveTicketSeq, ac) &&
|
||||
deleteLiveProposal(owner, ac);
|
||||
},
|
||||
{tecINVARIANT_FAILED, tefINVARIANT_FAILED},
|
||||
precloseLiveProposal);
|
||||
|
||||
// Distinct AccountIDs in ascending order, so an array built from them
|
||||
// violates only the bound on its length.
|
||||
auto ascendingAccounts = [](std::size_t count) {
|
||||
std::vector<AccountID> accounts;
|
||||
accounts.reserve(count);
|
||||
for (std::size_t i = 0; i < count; ++i)
|
||||
{
|
||||
AccountID account{beast::kZero};
|
||||
account.data()[0] = static_cast<std::uint8_t>(i + 1);
|
||||
accounts.push_back(account);
|
||||
}
|
||||
return accounts;
|
||||
};
|
||||
|
||||
auto signerArray = [](std::vector<AccountID> const& accounts) {
|
||||
STArray signers{sfSigners};
|
||||
for (auto const& account : accounts)
|
||||
{
|
||||
STObject signer{sfSigner};
|
||||
signer.setAccountID(sfAccount, account);
|
||||
signers.pushBack(signer);
|
||||
}
|
||||
return signers;
|
||||
};
|
||||
|
||||
// No transaction type on this amendment branch collects signatures yet,
|
||||
// so every rejection below has to be provoked by editing the stored
|
||||
// payload directly.
|
||||
auto const testBrokenSignerArray = [&](std::string const& name, auto const& breakPayload) {
|
||||
testcase("TransactionProposal canonical signer arrays: " + name);
|
||||
doInvariantCheck(
|
||||
{{"TransactionProposal signer arrays are not canonical"}},
|
||||
[&](Account const&, Account const& signerAccount, ApplyContext& ac) {
|
||||
auto const sle = peekLiveProposal(ac);
|
||||
if (!sle)
|
||||
return false;
|
||||
auto proposedTx = sle->getFieldObject(sfProposedTransaction);
|
||||
breakPayload(proposedTx, signerAccount);
|
||||
sle->setFieldObject(sfProposedTransaction, proposedTx);
|
||||
ac.view().update(sle);
|
||||
return true;
|
||||
},
|
||||
XRPAmount{},
|
||||
STTx{ttACCOUNT_SET, [](STObject&) {}},
|
||||
{tecINVARIANT_FAILED, tefINVARIANT_FAILED},
|
||||
precloseLiveProposal);
|
||||
};
|
||||
|
||||
testBrokenSignerArray("duplicate entries", [&](STObject& tx, Account const& signer) {
|
||||
tx.setFieldArray(sfSigners, signerArray({signer.id(), signer.id()}));
|
||||
});
|
||||
|
||||
testBrokenSignerArray("descending order", [&](STObject& tx, Account const&) {
|
||||
auto accounts = ascendingAccounts(2);
|
||||
std::ranges::reverse(accounts);
|
||||
tx.setFieldArray(sfSigners, signerArray(accounts));
|
||||
});
|
||||
|
||||
testBrokenSignerArray("past the multi-sign limit", [&](STObject& tx, Account const&) {
|
||||
tx.setFieldArray(sfSigners, signerArray(ascendingAccounts(STTx::kMaxMultiSigners + 1)));
|
||||
});
|
||||
|
||||
testBrokenSignerArray("entry without an Account", [](STObject& tx, Account const&) {
|
||||
STArray signers{sfSigners};
|
||||
signers.pushBack(STObject{sfSigner});
|
||||
tx.setFieldArray(sfSigners, signers);
|
||||
});
|
||||
|
||||
for (auto const* field :
|
||||
std::array<SField const*, 2>{&sfCounterpartySignature, &sfSponsorSignature})
|
||||
{
|
||||
testBrokenSignerArray(
|
||||
"duplicates under " + field->getName(), [&](STObject& tx, Account const& signer) {
|
||||
STObject signature{*field};
|
||||
signature.setFieldArray(sfSigners, signerArray({signer.id(), signer.id()}));
|
||||
tx.setFieldObject(*field, signature);
|
||||
});
|
||||
}
|
||||
|
||||
testBrokenSignerArray("past the batch-signer limit", [&](STObject& tx, Account const&) {
|
||||
STArray batchSigners{sfBatchSigners};
|
||||
for (auto const& account : ascendingAccounts(kMaxBatchSigners + 1))
|
||||
{
|
||||
STObject batchSigner{sfBatchSigner};
|
||||
batchSigner.setAccountID(sfAccount, account);
|
||||
batchSigners.pushBack(batchSigner);
|
||||
}
|
||||
tx.setFieldArray(sfBatchSigners, batchSigners);
|
||||
});
|
||||
|
||||
testBrokenSignerArray(
|
||||
"duplicates under a BatchSigner", [&](STObject& tx, Account const& signer) {
|
||||
STObject batchSigner{sfBatchSigner};
|
||||
batchSigner.setAccountID(sfAccount, signer.id());
|
||||
batchSigner.setFieldArray(sfSigners, signerArray({signer.id(), signer.id()}));
|
||||
|
||||
STArray batchSigners{sfBatchSigners};
|
||||
batchSigners.pushBack(batchSigner);
|
||||
tx.setFieldArray(sfBatchSigners, batchSigners);
|
||||
});
|
||||
|
||||
// Negative controls. These share the setup of the failure cases above,
|
||||
// so they confirm each of those failures came from the defect it names
|
||||
// rather than from the hand-built ledger state.
|
||||
std::initializer_list<TER> const passTers = {tesSUCCESS, tesSUCCESS};
|
||||
|
||||
testcase("TransactionProposal well-formed create");
|
||||
doInvariantCheck(
|
||||
{},
|
||||
[&](Account const& owner, Account const&, ApplyContext& ac) {
|
||||
return insertStagedProposal(owner, ac);
|
||||
},
|
||||
XRPAmount{},
|
||||
STTx{ttTRANSACTION_PROPOSAL_CREATE, [](STObject&) {}},
|
||||
passTers,
|
||||
precloseStagedPayload);
|
||||
|
||||
testcase("TransactionProposal left untouched");
|
||||
doInvariantCheck(
|
||||
{},
|
||||
[&](Account const&, Account const&, ApplyContext& ac) {
|
||||
return liveProposalKeylet && ac.view().read(*liveProposalKeylet) != nullptr;
|
||||
},
|
||||
XRPAmount{},
|
||||
STTx{ttACCOUNT_SET, [](STObject&) {}},
|
||||
passTers,
|
||||
precloseLiveProposal);
|
||||
|
||||
// A Cancel deletes the proposal it names.
|
||||
testcase("TransactionProposal cancelled");
|
||||
checkCancel({}, cancelDeletesLiveProposal, passTers, precloseLiveProposal);
|
||||
|
||||
// The Ticket a Cancel pays with is not the one its proposal is keyed
|
||||
// to, so the proposal did not go with its Ticket.
|
||||
testcase("TransactionProposal cancel paid with the canceller's own ticket");
|
||||
{
|
||||
CancelOptions options;
|
||||
options.paySpareTicket = true;
|
||||
checkCancel(
|
||||
{},
|
||||
[&](Account const& owner, Account const&, ApplyContext& ac) {
|
||||
return spareTicketSeq && deleteTicket(owner, *spareTicketSeq, ac) &&
|
||||
deleteLiveProposal(owner, ac);
|
||||
},
|
||||
passTers,
|
||||
precloseLiveProposalAndSpareTicket,
|
||||
options);
|
||||
}
|
||||
|
||||
// A SponsorshipTransfer reassigns the Sponsor.
|
||||
testcase("TransactionProposal sponsor reassigned");
|
||||
doInvariantCheck(
|
||||
{},
|
||||
reassignLiveProposal,
|
||||
XRPAmount{},
|
||||
STTx{ttSPONSORSHIP_TRANSFER, [](STObject&) {}},
|
||||
passTers,
|
||||
precloseLiveProposal);
|
||||
|
||||
// The proposed transaction executing spends the proposal's Ticket and
|
||||
// takes the proposal with it.
|
||||
testcase("TransactionProposal deleted with its ticket");
|
||||
doInvariantCheck(
|
||||
{},
|
||||
[&](Account const& owner, Account const&, ApplyContext& ac) {
|
||||
return liveTicketSeq && deleteTicket(owner, *liveTicketSeq, ac) &&
|
||||
deleteLiveProposal(owner, ac);
|
||||
},
|
||||
XRPAmount{},
|
||||
STTx{ttACCOUNT_SET, [](STObject&) {}},
|
||||
passTers,
|
||||
precloseLiveProposal);
|
||||
}
|
||||
|
||||
void
|
||||
run() override
|
||||
{
|
||||
testTransactionProposalInvariants();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(InvariantsTransactionProposal, app, xrpl);
|
||||
|
||||
} // namespace xrpl::test
|
||||
@@ -1154,6 +1154,8 @@ class LoanBroker_test : public beast::unit_test::Suite
|
||||
auto const jrr = env.rpc("submit", strHex(s.slice()))[jss::result];
|
||||
// fails in doSubmit() on STTx construction
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!jrr.isMember(jss::error_code));
|
||||
BEAST_EXPECT(jrr[jss::error_message].isNull());
|
||||
BEAST_EXPECT(jrr[jss::error_exception] == "invalid native account");
|
||||
}
|
||||
|
||||
|
||||
@@ -190,6 +190,8 @@ private:
|
||||
BEAST_EXPECT(jr.isMember(jss::result));
|
||||
auto const jResult = jr[jss::result];
|
||||
BEAST_EXPECT(jResult[jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!jResult.isMember(jss::error_code));
|
||||
BEAST_EXPECT(jResult[jss::error_message].isNull());
|
||||
BEAST_EXPECT(
|
||||
jResult[jss::error_exception] ==
|
||||
"fails local checks: Transaction has bad signature.");
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <xrpl/beast/xor_shift_engine.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/KeyType.h>
|
||||
@@ -126,12 +127,9 @@ private:
|
||||
return params;
|
||||
}();
|
||||
auto const jSignBorrower = env.rpc("json", "sign", to_string(borrowerSignParams));
|
||||
BEAST_EXPECT(
|
||||
jSignBorrower.isMember(jss::result) &&
|
||||
jSignBorrower[jss::result].isMember(jss::error) &&
|
||||
jSignBorrower[jss::result][jss::error] == "invalidParams" &&
|
||||
jSignBorrower[jss::result].isMember(jss::error_message) &&
|
||||
jSignBorrower[jss::result][jss::error_message] == target);
|
||||
BEAST_EXPECT(jSignBorrower[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jSignBorrower[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jSignBorrower[jss::result][jss::error_message] == target);
|
||||
}
|
||||
}
|
||||
{
|
||||
|
||||
@@ -196,7 +196,8 @@ private:
|
||||
jvResult[jss::tx_blob] = strHex(local.getSerializer().slice());
|
||||
auto res = env.rpc("json", "submit", to_string(jvResult))["result"];
|
||||
BEAST_EXPECT(
|
||||
res[jss::error] == "invalidTransaction" &&
|
||||
res[jss::error] == "invalidTransaction" && !res.isMember(jss::error_code) &&
|
||||
res[jss::error_message].isNull() &&
|
||||
res[jss::error_exception] ==
|
||||
"fails local checks: Counterparty: Invalid signature.");
|
||||
});
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <test/jtx/ter.h>
|
||||
#include <test/jtx/ticket.h>
|
||||
#include <test/jtx/trust.h>
|
||||
#include <test/jtx/txflags.h>
|
||||
#include <test/jtx/vault.h>
|
||||
|
||||
#include <xrpl/basics/Number.h>
|
||||
@@ -1609,26 +1610,263 @@ private:
|
||||
env.close();
|
||||
|
||||
// Direct vault share payment inherits the underlying lock via
|
||||
// sfReferenceHolding.
|
||||
// sfReferenceHolding. Caught in the strand check, like a global
|
||||
// or individual share lock.
|
||||
BEAST_EXPECT(shareBalance(alice) == 499);
|
||||
BEAST_EXPECT(shareBalance(bob) == 501);
|
||||
env(pay(alice, bob, shares(1)), Ter{tecLOCKED});
|
||||
env(pay(alice, bob, shares(1)), Ter{tecPATH_DRY});
|
||||
env.close();
|
||||
BEAST_EXPECT(shareBalance(alice) == 499);
|
||||
BEAST_EXPECT(shareBalance(bob) == 501);
|
||||
|
||||
// The same inherited lock must also block DEX payment paths that
|
||||
// would consume an offer selling vault shares.
|
||||
// would consume an offer selling vault shares. bob, the
|
||||
// destination, inherits the lock and is caught in the strand
|
||||
// check.
|
||||
env(pay(carol, bob, shares(1)),
|
||||
Sendmax(XRP(1)),
|
||||
Path(BookSpec{shares.raw()}),
|
||||
Ter{tecPATH_PARTIAL});
|
||||
Ter{tecPATH_DRY});
|
||||
env.close();
|
||||
BEAST_EXPECT(shareBalance(alice) == 499);
|
||||
BEAST_EXPECT(shareBalance(bob) == 501);
|
||||
BEAST_EXPECT(expectOffers(env, alice, 1));
|
||||
}
|
||||
|
||||
// A holder individually frozen on the underlying can neither sell
|
||||
// nor buy vault shares through an unfrozen holder's offer. The
|
||||
// inherited freeze is caught when the strand is built, before the
|
||||
// offer is consumed.
|
||||
auto const testShareDEXEndpointFrozen =
|
||||
[&](Env& env,
|
||||
PrettyAsset const& asset,
|
||||
Account const& owner,
|
||||
Account const& alice,
|
||||
Account const& bob,
|
||||
Account const& carol,
|
||||
std::function<void(bool)> const& setAliceFrozen) {
|
||||
Vault const vault{env};
|
||||
auto [tx, keylet] = vault.create({.owner = owner, .asset = asset});
|
||||
env(tx);
|
||||
env.close();
|
||||
|
||||
env(vault.deposit({.depositor = alice, .id = keylet.key, .amount = asset(500)}));
|
||||
env(vault.deposit({.depositor = bob, .id = keylet.key, .amount = asset(500)}));
|
||||
env.close();
|
||||
|
||||
PrettyAsset const shares = MPTIssue(env.le(keylet)->at(sfShareMPTID));
|
||||
auto const shareMptID = shares.raw().get<MPTIssue>().getMptID();
|
||||
auto const shareBalance = [&](Account const& account) {
|
||||
auto const sle = env.le(keylet::mptoken(shareMptID, account));
|
||||
return sle ? sle->at(sfMPTAmount) : 0;
|
||||
};
|
||||
|
||||
// bob bids XRP for shares and asks more XRP for shares, so that
|
||||
// his offers don't cross
|
||||
env(offer(bob, shares(1), XRP(1)));
|
||||
env(offer(bob, XRP(2), shares(1)));
|
||||
env.close();
|
||||
|
||||
setAliceFrozen(true);
|
||||
|
||||
auto const aliceShares = shareBalance(alice);
|
||||
auto const bobShares = shareBalance(bob);
|
||||
auto const expectUnchanged = [&] {
|
||||
BEAST_EXPECT(shareBalance(alice) == aliceShares);
|
||||
BEAST_EXPECT(shareBalance(bob) == bobShares);
|
||||
BEAST_EXPECT(expectOffers(env, bob, 2));
|
||||
};
|
||||
|
||||
// alice sells shares: the first step's source is frozen
|
||||
env(pay(alice, carol, XRP(1)),
|
||||
Sendmax(shares(1)),
|
||||
Path(~XRP),
|
||||
Txflags(tfNoRippleDirect),
|
||||
Ter{tecPATH_DRY});
|
||||
env.close();
|
||||
expectUnchanged();
|
||||
|
||||
// carol buys shares for alice: the last step's destination is
|
||||
// frozen
|
||||
env(pay(carol, alice, shares(1)),
|
||||
Sendmax(XRP(2)),
|
||||
Path(BookSpec{shares.raw()}),
|
||||
Txflags(tfNoRippleDirect),
|
||||
Ter{tecPATH_DRY});
|
||||
env.close();
|
||||
expectUnchanged();
|
||||
|
||||
// Both succeed once alice is unfrozen
|
||||
setAliceFrozen(false);
|
||||
|
||||
env(pay(alice, carol, XRP(1)),
|
||||
Sendmax(shares(1)),
|
||||
Path(~XRP),
|
||||
Txflags(tfNoRippleDirect));
|
||||
env.close();
|
||||
BEAST_EXPECT(shareBalance(bob) == bobShares + 1);
|
||||
|
||||
env(pay(carol, alice, shares(1)),
|
||||
Sendmax(XRP(2)),
|
||||
Path(BookSpec{shares.raw()}),
|
||||
Txflags(tfNoRippleDirect));
|
||||
env.close();
|
||||
BEAST_EXPECT(shareBalance(alice) == aliceShares);
|
||||
BEAST_EXPECT(shareBalance(bob) == bobShares);
|
||||
BEAST_EXPECT(expectOffers(env, bob, 0));
|
||||
};
|
||||
|
||||
// Vault shares as the intermediate asset between two books. Only the
|
||||
// offer owners hold the shares in transit. An owner individually
|
||||
// frozen on the underlying can neither give nor receive the shares.
|
||||
auto const testShareDEXMiddleFrozen = [&](Env& env,
|
||||
PrettyAsset const& asset,
|
||||
Account const& owner,
|
||||
Account const& alice,
|
||||
Account const& bob,
|
||||
Account const& carol,
|
||||
std::function<void(bool)> const& setAliceFrozen) {
|
||||
Vault const vault{env};
|
||||
auto [tx, keylet] = vault.create({.owner = owner, .asset = asset});
|
||||
env(tx);
|
||||
env.close();
|
||||
|
||||
env(vault.deposit({.depositor = alice, .id = keylet.key, .amount = asset(500)}));
|
||||
env(vault.deposit({.depositor = bob, .id = keylet.key, .amount = asset(500)}));
|
||||
env.close();
|
||||
|
||||
PrettyAsset const shares = MPTIssue(env.le(keylet)->at(sfShareMPTID));
|
||||
auto const shareMptID = shares.raw().get<MPTIssue>().getMptID();
|
||||
auto const shareBalance = [&](Account const& account) {
|
||||
auto const sle = env.le(keylet::mptoken(shareMptID, account));
|
||||
return sle ? sle->at(sfMPTAmount) : 0;
|
||||
};
|
||||
|
||||
// alice gives the shares: XRP -> shares (alice) -> asset (bob)
|
||||
{
|
||||
env(offer(alice, XRP(1), shares(1)));
|
||||
env(offer(bob, shares(1), asset(1)));
|
||||
env.close();
|
||||
|
||||
setAliceFrozen(true);
|
||||
|
||||
auto const aliceShares = shareBalance(alice);
|
||||
auto const bobShares = shareBalance(bob);
|
||||
env(pay(carol, owner, asset(1)),
|
||||
Sendmax(XRP(1)),
|
||||
Path(BookSpec{shares.raw()}, BookSpec{asset.raw()}),
|
||||
Txflags(tfNoRippleDirect),
|
||||
Ter{tecPATH_PARTIAL});
|
||||
env.close();
|
||||
BEAST_EXPECT(shareBalance(alice) == aliceShares);
|
||||
BEAST_EXPECT(shareBalance(bob) == bobShares);
|
||||
|
||||
setAliceFrozen(false);
|
||||
|
||||
env(pay(carol, owner, asset(1)),
|
||||
Sendmax(XRP(1)),
|
||||
Path(BookSpec{shares.raw()}, BookSpec{asset.raw()}),
|
||||
Txflags(tfNoRippleDirect));
|
||||
env.close();
|
||||
BEAST_EXPECT(shareBalance(alice) == aliceShares - 1);
|
||||
BEAST_EXPECT(shareBalance(bob) == bobShares + 1);
|
||||
BEAST_EXPECT(expectOffers(env, alice, 0));
|
||||
BEAST_EXPECT(expectOffers(env, bob, 0));
|
||||
}
|
||||
|
||||
// alice receives the shares: asset -> shares (bob) -> XRP (alice)
|
||||
{
|
||||
env(offer(bob, asset(1), shares(1)));
|
||||
env(offer(alice, shares(1), XRP(1)));
|
||||
env.close();
|
||||
|
||||
setAliceFrozen(true);
|
||||
|
||||
auto const aliceShares = shareBalance(alice);
|
||||
auto const bobShares = shareBalance(bob);
|
||||
env(pay(owner, carol, XRP(1)),
|
||||
Sendmax(asset(1)),
|
||||
Path(BookSpec{shares.raw()}, ~XRP),
|
||||
Txflags(tfNoRippleDirect),
|
||||
Ter{tecPATH_PARTIAL});
|
||||
env.close();
|
||||
BEAST_EXPECT(shareBalance(alice) == aliceShares);
|
||||
BEAST_EXPECT(shareBalance(bob) == bobShares);
|
||||
|
||||
setAliceFrozen(false);
|
||||
|
||||
env(pay(owner, carol, XRP(1)),
|
||||
Sendmax(asset(1)),
|
||||
Path(BookSpec{shares.raw()}, ~XRP),
|
||||
Txflags(tfNoRippleDirect));
|
||||
env.close();
|
||||
BEAST_EXPECT(shareBalance(alice) == aliceShares + 1);
|
||||
BEAST_EXPECT(shareBalance(bob) == bobShares - 1);
|
||||
BEAST_EXPECT(expectOffers(env, alice, 0));
|
||||
BEAST_EXPECT(expectOffers(env, bob, 0));
|
||||
}
|
||||
};
|
||||
|
||||
{
|
||||
testcase("MPT individually locked: vault share DEX inherits underlying lock");
|
||||
|
||||
Env env{*this, testableAmendments()};
|
||||
Account const issuer{"issuer"};
|
||||
Account const owner{"owner"};
|
||||
Account const alice{"alice"};
|
||||
Account const bob{"bob"};
|
||||
Account const carol{"carol"};
|
||||
env.fund(XRP(10'000), issuer, owner, alice, bob, carol);
|
||||
env.close();
|
||||
|
||||
MPTTester asset{{
|
||||
.env = env,
|
||||
.issuer = issuer,
|
||||
.holders = {owner, alice, bob},
|
||||
.flags = tfMPTCanTransfer | tfMPTCanTrade | tfMPTCanLock,
|
||||
}};
|
||||
env(pay(issuer, owner, asset(1'000)));
|
||||
env(pay(issuer, alice, asset(2'000)));
|
||||
env(pay(issuer, bob, asset(2'000)));
|
||||
env.close();
|
||||
|
||||
auto const setAliceFrozen = [&](bool frozen) {
|
||||
asset.set({.holder = alice, .flags = frozen ? tfMPTLock : tfMPTUnlock});
|
||||
env.close();
|
||||
};
|
||||
testShareDEXEndpointFrozen(env, asset, owner, alice, bob, carol, setAliceFrozen);
|
||||
testShareDEXMiddleFrozen(env, asset, owner, alice, bob, carol, setAliceFrozen);
|
||||
}
|
||||
|
||||
{
|
||||
testcase("IOU individually frozen: vault share DEX inherits underlying freeze");
|
||||
|
||||
Env env{*this, testableAmendments()};
|
||||
Account const issuer{"issuer"};
|
||||
Account const owner{"owner"};
|
||||
Account const alice{"alice"};
|
||||
Account const bob{"bob"};
|
||||
Account const carol{"carol"};
|
||||
env.fund(XRP(10'000), issuer, owner, alice, bob, carol);
|
||||
env.close();
|
||||
|
||||
// Deliver the IOU from a book to a holder
|
||||
env(fset(issuer, asfDefaultRipple));
|
||||
PrettyAsset const asset = issuer["IOU"];
|
||||
env.trust(asset(10'000), owner, alice, bob);
|
||||
env(pay(issuer, owner, asset(1'000)));
|
||||
env(pay(issuer, alice, asset(2'000)));
|
||||
env(pay(issuer, bob, asset(2'000)));
|
||||
env.close();
|
||||
|
||||
auto const setAliceFrozen = [&](bool frozen) {
|
||||
env(trust(issuer, asset(0), alice, frozen ? tfSetFreeze : tfClearFreeze));
|
||||
env.close();
|
||||
};
|
||||
testShareDEXEndpointFrozen(env, asset, owner, alice, bob, carol, setAliceFrozen);
|
||||
testShareDEXMiddleFrozen(env, asset, owner, alice, bob, carol, setAliceFrozen);
|
||||
}
|
||||
|
||||
{
|
||||
testcase("MPT CanTrade governance: share inherits underlying on DEX and AMM");
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ private:
|
||||
jvParams[jss::ledger_index] = jss::validated;
|
||||
jvParams[jss::vault] = to_string(UInt256(42));
|
||||
auto jvVault = env.rpc("json", "ledger_entry", to_string(jvParams));
|
||||
BEAST_EXPECT(jvVault[jss::result][jss::error].asString() == "entryNotFound");
|
||||
checkError(jvVault[jss::result], "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -182,7 +182,7 @@ private:
|
||||
jvParams[jss::vault][jss::owner] = issuer.human();
|
||||
jvParams[jss::vault][jss::seq] = 1'000'000;
|
||||
auto jvVault = env.rpc("json", "ledger_entry", to_string(jvParams));
|
||||
BEAST_EXPECT(jvVault[jss::result][jss::error].asString() == "entryNotFound");
|
||||
checkError(jvVault[jss::result], "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -191,7 +191,11 @@ private:
|
||||
jvParams[jss::ledger_index] = jss::validated;
|
||||
jvParams[jss::vault] = 42;
|
||||
auto jvVault = env.rpc("json", "ledger_entry", to_string(jvParams));
|
||||
BEAST_EXPECT(jvVault[jss::result][jss::error].asString() == "malformedRequest");
|
||||
checkError(
|
||||
jvVault[jss::result],
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'vault', not hex string or object.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -201,7 +205,11 @@ private:
|
||||
jvParams[jss::vault][jss::owner] = 42;
|
||||
jvParams[jss::vault][jss::seq] = sequence;
|
||||
auto jvVault = env.rpc("json", "ledger_entry", to_string(jvParams));
|
||||
BEAST_EXPECT(jvVault[jss::result][jss::error].asString() == "malformedOwner");
|
||||
checkError(
|
||||
jvVault[jss::result],
|
||||
"malformedOwner",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'owner', not AccountID.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -211,7 +219,11 @@ private:
|
||||
jvParams[jss::vault][jss::owner] = issuer.human();
|
||||
jvParams[jss::vault][jss::seq] = "foo";
|
||||
auto jvVault = env.rpc("json", "ledger_entry", to_string(jvParams));
|
||||
BEAST_EXPECT(jvVault[jss::result][jss::error].asString() == "malformedRequest");
|
||||
checkError(
|
||||
jvVault[jss::result],
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'seq', not number.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -221,7 +233,11 @@ private:
|
||||
jvParams[jss::vault][jss::owner] = issuer.human();
|
||||
jvParams[jss::vault][jss::seq] = -1;
|
||||
auto jvVault = env.rpc("json", "ledger_entry", to_string(jvParams));
|
||||
BEAST_EXPECT(jvVault[jss::result][jss::error].asString() == "malformedRequest");
|
||||
checkError(
|
||||
jvVault[jss::result],
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'seq', not number.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -231,7 +247,11 @@ private:
|
||||
jvParams[jss::vault][jss::owner] = issuer.human();
|
||||
jvParams[jss::vault][jss::seq] = 1e20;
|
||||
auto jvVault = env.rpc("json", "ledger_entry", to_string(jvParams));
|
||||
BEAST_EXPECT(jvVault[jss::result][jss::error].asString() == "malformedRequest");
|
||||
checkError(
|
||||
jvVault[jss::result],
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'seq', not number.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -241,7 +261,11 @@ private:
|
||||
jvParams[jss::vault][jss::owner] = issuer.human();
|
||||
jvParams[jss::vault][jss::seq] = true;
|
||||
auto jvVault = env.rpc("json", "ledger_entry", to_string(jvParams));
|
||||
BEAST_EXPECT(jvVault[jss::result][jss::error].asString() == "malformedRequest");
|
||||
checkError(
|
||||
jvVault[jss::result],
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'seq', not number.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -500,8 +524,8 @@ private:
|
||||
|
||||
{
|
||||
testcase("RPC vault_info command line invalid index");
|
||||
json::Value jv = env.rpc("vault_info", "foobar", "validated");
|
||||
BEAST_EXPECT(jv[jss::error].asString() == "invalidParams");
|
||||
json::Value const jv = env.rpc("vault_info", "foobar", "validated");
|
||||
checkError(jv, "invalidParams", RpcInvalidParams, "Invalid parameters.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -519,7 +543,7 @@ private:
|
||||
{
|
||||
testcase("RPC vault_info command line invalid ledger");
|
||||
json::Value jv = env.rpc("vault_info", strHex(keylet.key), "0");
|
||||
BEAST_EXPECT(jv[jss::result][jss::error].asString() == "lgrNotFound");
|
||||
checkError(jv[jss::result], "lgrNotFound", RpcLgrNotFound, "ledgerNotFound");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
|
||||
#include <test/jtx/Account.h>
|
||||
#include <test/jtx/Env.h>
|
||||
#include <test/jtx/JTx.h>
|
||||
#include <test/jtx/TestHelpers.h>
|
||||
|
||||
#include <xrpl/basics/Slice.h>
|
||||
#include <xrpl/basics/strHex.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/Rate.h>
|
||||
@@ -11,7 +14,10 @@
|
||||
#include <xrpl/protocol/STAmount.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
/**
|
||||
* Escrow operations.
|
||||
@@ -95,4 +101,55 @@ auto const kCondition = JTxFieldWrapper<BlobField>(sfCondition);
|
||||
|
||||
auto const kFulfillment = JTxFieldWrapper<BlobField>(sfFulfillment);
|
||||
|
||||
/**
|
||||
* Set a hex-encoded blob field on a JTx
|
||||
*/
|
||||
template <SF_VL const& Field>
|
||||
struct HexBlobField
|
||||
{
|
||||
private:
|
||||
std::string value_;
|
||||
|
||||
public:
|
||||
explicit HexBlobField(std::string hex) : value_(std::move(hex))
|
||||
{
|
||||
}
|
||||
|
||||
explicit HexBlobField(Slice const& blob) : value_(strHex(blob))
|
||||
{
|
||||
}
|
||||
|
||||
template <size_t N>
|
||||
explicit HexBlobField(std::array<std::uint8_t, N> const& blob) : HexBlobField(makeSlice(blob))
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env&, JTx& jt) const
|
||||
{
|
||||
// clang-tidy reads a reference template parameter as parenthesized.
|
||||
jt.jv[Field.jsonName] = value_; // NOLINT(readability-redundant-parentheses)
|
||||
}
|
||||
};
|
||||
|
||||
using Bytecode = HexBlobField<sfBytecode>;
|
||||
using Data = HexBlobField<sfData>;
|
||||
|
||||
struct Gas
|
||||
{
|
||||
private:
|
||||
std::uint32_t value_;
|
||||
|
||||
public:
|
||||
explicit Gas(std::uint32_t const value) : value_(value)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env&, JTx& jt) const
|
||||
{
|
||||
jt.jv[sfGas.jsonName] = value_;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace xrpl::test::jtx::escrow
|
||||
@@ -238,6 +238,13 @@ verify::Create::operator()(Env& env, JTx& jt) const
|
||||
// Every entry the transaction could touch, read whole, so what follows can
|
||||
// say that nothing moved rather than that the fields we named did not.
|
||||
auto const& view = *env.current();
|
||||
|
||||
// A proposer paying with one of its own Tickets consumes it whenever the
|
||||
// transaction is applied: on success, and on a claimed-fee tec.
|
||||
std::optional<std::uint32_t> ownTicketSeq;
|
||||
if (jt.jv.isMember(sfTicketSequence.jsonName))
|
||||
ownTicketSeq = jt.jv[sfTicketSequence.jsonName].asUInt();
|
||||
|
||||
auto const proposalKeylet = keylet::txProposal(target, ticketSeq);
|
||||
auto const ownerCountBefore = env.ownerCount(proposer);
|
||||
auto const sponsoredOwnerCountBefore = env.sponsoredOwnerCount(proposer);
|
||||
@@ -254,11 +261,15 @@ verify::Create::operator()(Env& env, JTx& jt) const
|
||||
auto const& view = *applied.current();
|
||||
|
||||
auto const created = isTesSuccess(applied.ter());
|
||||
bool const ticketConsumed = ownTicketSeq && (created || isTecClaim(applied.ter()));
|
||||
std::uint32_t const ticketReturned = ticketConsumed ? 1 : 0;
|
||||
|
||||
// The proposer owns the proposal even when another account covers its
|
||||
// reserve. A proposed Batch costs more owner-count increments.
|
||||
// reserve. A proposed Batch costs more owner-count increments. A
|
||||
// Ticket the proposer paid with gives one back.
|
||||
test.expect(
|
||||
applied.ownerCount(proposer) == ownerCountBefore + (created ? cost : 0),
|
||||
applied.ownerCount(proposer) ==
|
||||
ownerCountBefore + (created ? cost : 0) - ticketReturned,
|
||||
"proposal reserve");
|
||||
test.expect(
|
||||
applied.sponsoredOwnerCount(proposer) ==
|
||||
@@ -291,6 +302,14 @@ verify::Create::operator()(Env& env, JTx& jt) const
|
||||
|
||||
auto const sleProposal = view.read(proposalKeylet);
|
||||
|
||||
// The Ticket the proposer paid with has left its directory.
|
||||
auto expectedDir = proposerDirBefore;
|
||||
if (ticketConsumed)
|
||||
{
|
||||
expectedDir.erase(
|
||||
keylet::ticket(proposer.id(), SeqProxy::rawTicket(*ownTicketSeq)).key);
|
||||
}
|
||||
|
||||
if (!created)
|
||||
{
|
||||
// A create that did not succeed leaves the proposal as it found
|
||||
@@ -300,7 +319,7 @@ verify::Create::operator()(Env& env, JTx& jt) const
|
||||
// Nor did the directory gain a listing for an entry that does not
|
||||
// exist.
|
||||
test.expect(
|
||||
ownerDirKeys(view, proposer.id()) == proposerDirBefore, "proposal owner directory");
|
||||
ownerDirKeys(view, proposer.id()) == expectedDir, "proposal owner directory");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -353,7 +372,6 @@ verify::Create::operator()(Env& env, JTx& jt) const
|
||||
|
||||
// The proposal is listed in the proposer's directory on the page its
|
||||
// OwnerNode names, and nothing else listed moved.
|
||||
auto expectedDir = proposerDirBefore;
|
||||
expectedDir.emplace(sleProposal->key(), sleProposal->getFieldU64(sfOwnerNode));
|
||||
test.expect(ownerDirKeys(view, proposer.id()) == expectedDir, "proposal owner directory");
|
||||
});
|
||||
|
||||
@@ -77,7 +77,9 @@ public:
|
||||
* @brief Check the ledger effects a TransactionProposalCreate must have,
|
||||
* whatever its outcome: on tesSUCCESS a new proposal holding what was
|
||||
* submitted, listed in the proposer's directory and paid for by its reserve;
|
||||
* otherwise nothing moved. Nothing of the target's moves either way.
|
||||
* otherwise nothing moved. Nothing of the target's moves either way. A Ticket
|
||||
* the proposer pays with is expected to be consumed; attach ticket::Use()
|
||||
* before this condition so it sees the TicketSequence.
|
||||
*
|
||||
* @code
|
||||
* env(proposal::create(alice, payload, expiration), proposal::verify::create());
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
#include <xrpl/protocol/MPTIssue.h>
|
||||
@@ -180,6 +181,7 @@ public:
|
||||
auto const result = env.rpc("json", "sign", to_string(req))[jss::result];
|
||||
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Field 'tx_json.Asset' has invalid data.");
|
||||
}
|
||||
|
||||
@@ -253,6 +255,7 @@ public:
|
||||
auto const result = env.rpc("json", "sign", to_string(req))[jss::result];
|
||||
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Field 'tx_json.Asset' has invalid data.");
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
#include <xrpl/protocol/TxFlags.h>
|
||||
@@ -56,12 +57,16 @@ public:
|
||||
Account const gw("gw");
|
||||
auto const usd = gw["USD"];
|
||||
auto const jv = ammAlice.ammRpcInfo({}, {}, usd, usd);
|
||||
BEAST_EXPECT(jv[jss::error] == "actNotFound");
|
||||
BEAST_EXPECT(jv[jss::error_code] == RpcActNotFound);
|
||||
BEAST_EXPECT(jv[jss::error_message] == "Account not found.");
|
||||
});
|
||||
|
||||
// Invalid LP account id
|
||||
testAMM([&](AMM& ammAlice, Env&) {
|
||||
auto const jv = ammAlice.ammRpcInfo(bogie.id());
|
||||
BEAST_EXPECT(jv[jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(jv[jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(jv[jss::error_message] == "Account malformed.");
|
||||
});
|
||||
|
||||
@@ -69,6 +74,8 @@ public:
|
||||
testAMM([&](AMM& ammAlice, Env&) {
|
||||
auto const jv =
|
||||
ammAlice.ammRpcInfo(json::Value{42}, std::nullopt, XRP, USD, std::nullopt, true, 3);
|
||||
BEAST_EXPECT(jv[jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(jv[jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(jv[jss::error_message] == "Account malformed.");
|
||||
});
|
||||
|
||||
@@ -82,6 +89,8 @@ public:
|
||||
json::Value{42},
|
||||
false,
|
||||
3);
|
||||
BEAST_EXPECT(jv[jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(jv[jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(jv[jss::error_message] == "Account malformed.");
|
||||
});
|
||||
|
||||
@@ -106,6 +115,8 @@ public:
|
||||
iss2,
|
||||
accountId(ammAlice, acct),
|
||||
ignoreParams);
|
||||
BEAST_EXPECT(jv[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jv[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jv[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
});
|
||||
@@ -121,6 +132,8 @@ public:
|
||||
iss2,
|
||||
accountId(ammAlice, acct),
|
||||
ignoreParams);
|
||||
BEAST_EXPECT(jv[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jv[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jv[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
});
|
||||
@@ -137,6 +150,8 @@ public:
|
||||
accountId(ammAlice, acct),
|
||||
ignoreParams,
|
||||
3);
|
||||
BEAST_EXPECT(jv[jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(jv[jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(jv[jss::error_message] == "Account malformed.");
|
||||
}
|
||||
});
|
||||
@@ -145,6 +160,8 @@ public:
|
||||
testAMM([&](AMM& ammAlice, Env&) {
|
||||
auto const jv = ammAlice.ammRpcInfo(
|
||||
std::nullopt, std::nullopt, std::nullopt, std::nullopt, bogie.id());
|
||||
BEAST_EXPECT(jv[jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(jv[jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(jv[jss::error_message] == "Account malformed.");
|
||||
});
|
||||
|
||||
@@ -169,6 +186,8 @@ public:
|
||||
iss2,
|
||||
accountId(ammAlice, acct),
|
||||
ignoreParams);
|
||||
BEAST_EXPECT(jv[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jv[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jv[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
});
|
||||
@@ -185,6 +204,13 @@ public:
|
||||
accountId(ammAlice, acct),
|
||||
ignoreParams,
|
||||
3);
|
||||
BEAST_EXPECT(
|
||||
jv[jss::error] ==
|
||||
(acct == TestAccount::Bogie ? std::string("actMalformed")
|
||||
: std::string("invalidParams")));
|
||||
BEAST_EXPECT(
|
||||
jv[jss::error_code] ==
|
||||
(acct == TestAccount::Bogie ? RpcActMalformed : RpcInvalidParams));
|
||||
BEAST_EXPECT(
|
||||
jv[jss::error_message] ==
|
||||
(acct == TestAccount::Bogie ? std::string("Account malformed.")
|
||||
@@ -383,7 +409,9 @@ public:
|
||||
testAMM([&](AMM& amm, Env&) {
|
||||
auto const resp = amm.ammRpcInfo(
|
||||
std::nullopt, jss::validated.cStr(), std::nullopt, std::nullopt, gw_);
|
||||
BEAST_EXPECT(resp.isMember("error") && resp["error"] == "actNotFound");
|
||||
BEAST_EXPECT(resp[jss::error] == "actNotFound");
|
||||
BEAST_EXPECT(resp[jss::error_code] == RpcActNotFound);
|
||||
BEAST_EXPECT(resp[jss::error_message] == "Account not found.");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <format>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
@@ -34,6 +35,8 @@ public:
|
||||
{
|
||||
// account_info with no account.
|
||||
auto const info = env.rpc("json", "account_info", "{ }");
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(info[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message] == "Missing field 'account'.");
|
||||
}
|
||||
{
|
||||
@@ -43,8 +46,11 @@ public:
|
||||
"account_info",
|
||||
"{\"account\": "
|
||||
"\"n94JNrQYkDrpt62bbSR7nVEhdyAvcJXRAsjEkFYyqRkh9SUTYEqV\"}");
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(info[jss::result][jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message] == "Account malformed.");
|
||||
BEAST_EXPECT(info[jss::result].isMember(jss::ledger_current_index));
|
||||
BEAST_EXPECT(info[jss::result][jss::validated] == false);
|
||||
}
|
||||
{
|
||||
// account_info with an account that's not in the ledger.
|
||||
@@ -52,12 +58,17 @@ public:
|
||||
json::Value params;
|
||||
params[jss::account] = bogie.human();
|
||||
auto const info = env.rpc("json", "account_info", to_string(params));
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "actNotFound");
|
||||
BEAST_EXPECT(info[jss::result][jss::error_code] == RpcActNotFound);
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message] == "Account not found.");
|
||||
BEAST_EXPECT(info[jss::result][jss::account] == bogie.human());
|
||||
BEAST_EXPECT(info[jss::result].isMember(jss::ledger_current_index));
|
||||
BEAST_EXPECT(info[jss::result][jss::validated] == false);
|
||||
}
|
||||
{
|
||||
// Cannot use a seed as account
|
||||
auto const info = env.rpc("json", "account_info", R"({"account": "foo"})");
|
||||
auto const info = env.rpc("json", "account_info", R"JSON({"account": "foo"})JSON");
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(info[jss::result][jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message] == "Account malformed.");
|
||||
}
|
||||
@@ -69,6 +80,7 @@ public:
|
||||
params[jss::account] = param;
|
||||
auto jrr = env.rpc("json", "account_info", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'account'.");
|
||||
};
|
||||
|
||||
@@ -87,6 +99,7 @@ public:
|
||||
params[jss::ident] = param;
|
||||
auto jrr = env.rpc("json", "account_info", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'ident'.");
|
||||
};
|
||||
|
||||
@@ -97,6 +110,41 @@ public:
|
||||
testInvalidIdentParam(json::Value(json::ValueType::Object));
|
||||
testInvalidIdentParam(json::Value(json::ValueType::Array));
|
||||
}
|
||||
{
|
||||
// `ident` is ignored when `account` is present
|
||||
json::Value params;
|
||||
params[jss::account] = env.master.human();
|
||||
params[jss::ident] = 1;
|
||||
auto const info = env.rpc("json", "account_info", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(!info.isMember(jss::error));
|
||||
BEAST_EXPECT(info.isMember(jss::account_data));
|
||||
BEAST_EXPECT(info[jss::account_data][sfAccount.jsonName] == env.master.human());
|
||||
}
|
||||
{
|
||||
// an invalid ledger is reported before a missing account
|
||||
json::Value params;
|
||||
params[jss::ledger_hash] = 1;
|
||||
auto const info = env.rpc("json", "account_info", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(info[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(info[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
info[jss::error_message] == "Invalid field 'ledger_hash', not hex string.");
|
||||
}
|
||||
{
|
||||
// `queue` is read as a bool, so any non-empty string requests it, and the queue
|
||||
// can't be requested from a closed ledger
|
||||
env.close();
|
||||
json::Value params;
|
||||
params[jss::account] = env.master.human();
|
||||
params[jss::ledger_index] = "closed";
|
||||
params[jss::queue] = "false";
|
||||
auto const info = env.rpc("json", "account_info", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(info[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(info[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(info[jss::error_message] == "Invalid parameters.");
|
||||
BEAST_EXPECT(info.isMember(jss::ledger_index));
|
||||
BEAST_EXPECT(!info.isMember(jss::account_data));
|
||||
}
|
||||
}
|
||||
|
||||
// Test the "signer_lists" argument in account_info.
|
||||
@@ -234,8 +282,9 @@ public:
|
||||
withSigners[jss::account] = alice.human();
|
||||
withSigners[jss::signer_lists] = true;
|
||||
|
||||
auto const withSignersAsString = std::string("{ ") + R"("api_version": 2, "account": ")" +
|
||||
alice.human() + "\", " + "\"signer_lists\": asdfggh }";
|
||||
auto const withSignersAsString = std::format(
|
||||
R"JSON({{"api_version": 2, "account": "{}", "signer_lists": "yes"}})JSON",
|
||||
alice.human());
|
||||
|
||||
// Alice has no SignerList yet.
|
||||
{
|
||||
@@ -285,9 +334,15 @@ public:
|
||||
}
|
||||
{
|
||||
// account_info with "signer_lists" as not bool should error out
|
||||
auto const info = env.rpc("json", "account_info", withSignersAsString);
|
||||
auto const info = env.rpc("json", "account_info", withSignersAsString)[jss::result];
|
||||
BEAST_EXPECT(info[jss::status] == "error");
|
||||
BEAST_EXPECT(info[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(info[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(info[jss::error_message] == "Invalid parameters.");
|
||||
BEAST_EXPECT(info.isMember(jss::account_data));
|
||||
BEAST_EXPECT(info[jss::account_data][sfAccount.jsonName] == alice.human());
|
||||
BEAST_EXPECT(info.isMember(jss::ledger_current_index));
|
||||
BEAST_EXPECT(!info.isMember(jss::signer_lists));
|
||||
}
|
||||
|
||||
// Give alice a big signer list
|
||||
|
||||
@@ -48,9 +48,15 @@ public:
|
||||
|
||||
using namespace test::jtx;
|
||||
Env env(*this);
|
||||
|
||||
static constexpr std::size_t kLinesPerGateway = 26;
|
||||
static constexpr std::size_t kAllLines = 2 * kLinesPerGateway;
|
||||
|
||||
{
|
||||
// account_lines with no account.
|
||||
auto const lines = env.rpc("json", "account_lines", "{ }");
|
||||
BEAST_EXPECT(lines[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(lines[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::result][jss::error_message] ==
|
||||
rpc::missingFieldError(jss::account)[jss::error_message]);
|
||||
@@ -60,9 +66,35 @@ public:
|
||||
json::Value params;
|
||||
params[jss::account] = "n9MJkEKHDhy5eTLuHUQeAAjo382frHNbFK4C8hcwN4nwM2SrLdBj";
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(params));
|
||||
BEAST_EXPECT(lines[jss::result][jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(lines[jss::result][jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::result][jss::error_message] ==
|
||||
rpc::makeError(RpcActMalformed)[jss::error_message]);
|
||||
BEAST_EXPECT(lines[jss::result].isMember(jss::ledger_current_index));
|
||||
BEAST_EXPECT(lines[jss::result][jss::validated] == false);
|
||||
}
|
||||
{
|
||||
// An invalid ledger is reported before a missing account.
|
||||
json::Value params;
|
||||
params[jss::ledger_hash] = 1;
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(lines[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(lines[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::error_message] == "Invalid field 'ledger_hash', not hex string.");
|
||||
}
|
||||
{
|
||||
// A bad limit is reported before an account that is not found.
|
||||
json::Value params;
|
||||
params[jss::account] = Account{"bogie"}.human();
|
||||
params[jss::limit] = -1;
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(lines[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(lines[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::error_message] ==
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer"));
|
||||
}
|
||||
{
|
||||
// test account non-string
|
||||
@@ -71,6 +103,7 @@ public:
|
||||
params[jss::account] = param;
|
||||
auto jrr = env.rpc("json", "account_lines", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'account'.");
|
||||
};
|
||||
|
||||
@@ -87,6 +120,8 @@ public:
|
||||
json::Value params;
|
||||
params[jss::account] = alice.human();
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(params));
|
||||
BEAST_EXPECT(lines[jss::result][jss::error] == "actNotFound");
|
||||
BEAST_EXPECT(lines[jss::result][jss::error_code] == RpcActNotFound);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::result][jss::error_message] ==
|
||||
rpc::makeError(RpcActNotFound)[jss::error_message]);
|
||||
@@ -104,6 +139,7 @@ public:
|
||||
params[jss::peer] = param;
|
||||
auto jrr = env.rpc("json", "account_lines", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'peer'.");
|
||||
};
|
||||
|
||||
@@ -128,6 +164,8 @@ public:
|
||||
params[jss::account] = alice.human();
|
||||
params[jss::ledger_index] = "nonsense";
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(params));
|
||||
BEAST_EXPECT(lines[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(lines[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::result][jss::error_message] ==
|
||||
"Invalid field 'ledger_index', not string or number.");
|
||||
@@ -138,6 +176,8 @@ public:
|
||||
params[jss::account] = alice.human();
|
||||
params[jss::ledger_index] = 50000;
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(params));
|
||||
BEAST_EXPECT(lines[jss::result][jss::error] == "lgrNotFound");
|
||||
BEAST_EXPECT(lines[jss::result][jss::error_code] == RpcLgrNotFound);
|
||||
BEAST_EXPECT(lines[jss::result][jss::error_message] == "ledgerNotFound");
|
||||
}
|
||||
// Create trust lines to share with alice.
|
||||
@@ -191,7 +231,7 @@ public:
|
||||
|
||||
// A re-usable test for historic ledgers.
|
||||
auto const testAccountLinesHistory =
|
||||
[this, &env](Account const& account, LedgerHeader const& info, int count) {
|
||||
[this, &env](Account const& account, LedgerHeader const& info, std::size_t count) {
|
||||
// Get account_lines by ledger index.
|
||||
json::Value paramsSeq;
|
||||
paramsSeq[jss::account] = account.human();
|
||||
@@ -213,10 +253,10 @@ public:
|
||||
testAccountLinesHistory(alice, ledger3Info, 0);
|
||||
|
||||
// Alice should have 26 trust lines in ledger 4.
|
||||
testAccountLinesHistory(alice, ledger4Info, 26);
|
||||
testAccountLinesHistory(alice, ledger4Info, kLinesPerGateway);
|
||||
|
||||
// Alice should have 52 trust lines in ledger 58.
|
||||
testAccountLinesHistory(alice, ledger58Info, 52);
|
||||
testAccountLinesHistory(alice, ledger58Info, kAllLines);
|
||||
|
||||
{
|
||||
// Invalid to specify both index and hash
|
||||
@@ -226,6 +266,7 @@ public:
|
||||
params[jss::ledger_index] = ledger58Info.seq;
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(lines[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(lines[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::error_message] ==
|
||||
"Exactly one of 'ledger_hash' or 'ledger_index' can be "
|
||||
@@ -238,6 +279,7 @@ public:
|
||||
params[jss::ledger_index] = json::ValueType::Object;
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(lines[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(lines[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::error_message] == "Invalid field 'ledger_index', not string or number.");
|
||||
}
|
||||
@@ -247,7 +289,7 @@ public:
|
||||
params[jss::account] = alice.human();
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(params));
|
||||
BEAST_EXPECT(lines[jss::result][jss::lines].isArray());
|
||||
BEAST_EXPECT(lines[jss::result][jss::lines].size() == 52);
|
||||
BEAST_EXPECT(lines[jss::result][jss::lines].size() == kAllLines);
|
||||
}
|
||||
{
|
||||
// alice should have 26 trust lines with gw1.
|
||||
@@ -256,7 +298,7 @@ public:
|
||||
params[jss::peer] = gw1.human();
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(params));
|
||||
BEAST_EXPECT(lines[jss::result][jss::lines].isArray());
|
||||
BEAST_EXPECT(lines[jss::result][jss::lines].size() == 26);
|
||||
BEAST_EXPECT(lines[jss::result][jss::lines].size() == kLinesPerGateway);
|
||||
|
||||
// Check no ripple is not set for trustlines between alice and gw1
|
||||
auto const& line = lines[jss::result][jss::lines][0u];
|
||||
@@ -268,9 +310,39 @@ public:
|
||||
params[jss::account] = alice.human();
|
||||
params[jss::peer] = "n9MJkEKHDhy5eTLuHUQeAAjo382frHNbFK4C8hcwN4nwM2SrLdBj";
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(params));
|
||||
BEAST_EXPECT(lines[jss::result][jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(lines[jss::result][jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::result][jss::error_message] ==
|
||||
rpc::makeError(RpcActMalformed)[jss::error_message]);
|
||||
BEAST_EXPECT(lines[jss::result].isMember(jss::ledger_current_index));
|
||||
BEAST_EXPECT(lines[jss::result][jss::validated] == false);
|
||||
}
|
||||
{
|
||||
// An empty peer is no peer at all.
|
||||
json::Value params;
|
||||
params[jss::account] = alice.human();
|
||||
params[jss::peer] = "";
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(params));
|
||||
params.removeMember(jss::peer);
|
||||
auto const all = env.rpc("json", "account_lines", to_string(params));
|
||||
BEAST_EXPECT(lines[jss::result][jss::lines].isArray());
|
||||
BEAST_EXPECT(lines[jss::result][jss::lines].size() == kAllLines);
|
||||
BEAST_EXPECT(lines[jss::result][jss::lines] == all[jss::result][jss::lines]);
|
||||
}
|
||||
{
|
||||
// ignore_default is read as a bool, so any non-empty string sets it.
|
||||
json::Value params;
|
||||
params[jss::account] = gw1.human();
|
||||
auto const all = env.rpc("json", "account_lines", to_string(params));
|
||||
params[jss::ignore_default] = true;
|
||||
auto const asBool = env.rpc("json", "account_lines", to_string(params));
|
||||
params[jss::ignore_default] = "false";
|
||||
auto const asString = env.rpc("json", "account_lines", to_string(params));
|
||||
BEAST_EXPECT(all[jss::result][jss::lines].size() == kLinesPerGateway);
|
||||
BEAST_EXPECT(asBool[jss::result][jss::lines].size() == 0);
|
||||
BEAST_EXPECT(!asString[jss::result].isMember(jss::error));
|
||||
BEAST_EXPECT(asString[jss::result][jss::lines] == asBool[jss::result][jss::lines]);
|
||||
}
|
||||
{
|
||||
// A negative limit should fail.
|
||||
@@ -278,6 +350,8 @@ public:
|
||||
params[jss::account] = alice.human();
|
||||
params[jss::limit] = -1;
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(params));
|
||||
BEAST_EXPECT(lines[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(lines[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::result][jss::error_message] ==
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer"));
|
||||
@@ -298,7 +372,7 @@ public:
|
||||
paramsB[jss::marker] = marker;
|
||||
auto const linesB = env.rpc("json", "account_lines", to_string(paramsB));
|
||||
BEAST_EXPECT(linesB[jss::result][jss::lines].isArray());
|
||||
BEAST_EXPECT(linesB[jss::result][jss::lines].size() == 51);
|
||||
BEAST_EXPECT(linesB[jss::result][jss::lines].size() == kAllLines - 1);
|
||||
|
||||
// Go again from where the marker left off, but set a limit of 3.
|
||||
json::Value paramsC;
|
||||
@@ -315,6 +389,8 @@ public:
|
||||
paramsD[jss::account] = alice.human();
|
||||
paramsD[jss::marker] = marker;
|
||||
auto const linesD = env.rpc("json", "account_lines", to_string(paramsD));
|
||||
BEAST_EXPECT(linesD[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(linesD[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
linesD[jss::result][jss::error_message] ==
|
||||
rpc::makeError(RpcInvalidParams)[jss::error_message]);
|
||||
@@ -325,10 +401,46 @@ public:
|
||||
params[jss::account] = alice.human();
|
||||
params[jss::marker] = true;
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(params));
|
||||
BEAST_EXPECT(lines[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(lines[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::result][jss::error_message] ==
|
||||
rpc::expectedFieldMessage(jss::marker, "string"));
|
||||
}
|
||||
{
|
||||
// A marker that does not parse is reported without naming the field.
|
||||
json::Value params;
|
||||
params[jss::account] = alice.human();
|
||||
params[jss::marker] = "NOT_A_MARKER";
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(params));
|
||||
BEAST_EXPECT(lines[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(lines[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::result][jss::error_message] ==
|
||||
rpc::makeError(RpcInvalidParams)[jss::error_message]);
|
||||
}
|
||||
{
|
||||
// The marker's start hint may have a leading '+', and anything after a second
|
||||
// comma is ignored.
|
||||
json::Value params;
|
||||
params[jss::account] = alice.human();
|
||||
params[jss::limit] = 1;
|
||||
auto const first = env.rpc("json", "account_lines", to_string(params));
|
||||
auto const marker = first[jss::result][jss::marker].asString();
|
||||
auto const comma = marker.find(',');
|
||||
BEAST_EXPECT(comma != std::string::npos);
|
||||
|
||||
json::Value next;
|
||||
next[jss::account] = alice.human();
|
||||
next[jss::marker] = marker;
|
||||
auto const plain = env.rpc("json", "account_lines", to_string(next));
|
||||
next[jss::marker] =
|
||||
marker.substr(0, comma) + ",+" + marker.substr(comma + 1) + ",ignored";
|
||||
auto const lines = env.rpc("json", "account_lines", to_string(next));
|
||||
BEAST_EXPECT(lines[jss::result][jss::lines].isArray());
|
||||
BEAST_EXPECT(lines[jss::result][jss::lines].size() == kAllLines - 1);
|
||||
BEAST_EXPECT(lines[jss::result][jss::lines] == plain[jss::result][jss::lines]);
|
||||
}
|
||||
{
|
||||
// Check that the flags we expect from alice to gw2 are present.
|
||||
json::Value params;
|
||||
@@ -446,7 +558,11 @@ public:
|
||||
beckyLinesParams[jss::account] = becky.human();
|
||||
beckyLinesParams[jss::marker] = aliceMarker;
|
||||
auto const beckyLines = env.rpc("json", "account_lines", to_string(beckyLinesParams));
|
||||
BEAST_EXPECT(beckyLines[jss::result].isMember(jss::error_message));
|
||||
BEAST_EXPECT(beckyLines[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(beckyLines[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
beckyLines[jss::result][jss::error_message] ==
|
||||
rpc::makeError(RpcInvalidParams)[jss::error_message]);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -514,6 +630,8 @@ public:
|
||||
linesEndParams[jss::account] = alice.human();
|
||||
linesEndParams[jss::marker] = linesBeg[jss::result][jss::marker];
|
||||
auto const linesEnd = env.rpc("json", "account_lines", to_string(linesEndParams));
|
||||
BEAST_EXPECT(linesEnd[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(linesEnd[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
linesEnd[jss::result][jss::error_message] ==
|
||||
rpc::makeError(RpcInvalidParams)[jss::error_message]);
|
||||
@@ -811,6 +929,8 @@ public:
|
||||
request[jss::ripplerpc] = "2.0";
|
||||
request[jss::id] = 5;
|
||||
auto const lines = env.rpc("json2", to_string(request));
|
||||
BEAST_EXPECT(lines[jss::error][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(lines[jss::error][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::error][jss::message] ==
|
||||
rpc::missingFieldError(jss::account)[jss::error_message]);
|
||||
@@ -829,6 +949,8 @@ public:
|
||||
request[jss::id] = 5;
|
||||
request[jss::params] = params;
|
||||
auto const lines = env.rpc("json2", to_string(request));
|
||||
BEAST_EXPECT(lines[jss::error][jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(lines[jss::error][jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::error][jss::message] ==
|
||||
rpc::makeError(RpcActMalformed)[jss::error_message]);
|
||||
@@ -848,6 +970,8 @@ public:
|
||||
request[jss::id] = 5;
|
||||
request[jss::params] = params;
|
||||
auto const lines = env.rpc("json2", to_string(request));
|
||||
BEAST_EXPECT(lines[jss::error][jss::error] == "actNotFound");
|
||||
BEAST_EXPECT(lines[jss::error][jss::error_code] == RpcActNotFound);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::error][jss::message] ==
|
||||
rpc::makeError(RpcActNotFound)[jss::error_message]);
|
||||
@@ -876,6 +1000,7 @@ public:
|
||||
|
||||
auto const lines = env.rpc("json2", to_string(request));
|
||||
BEAST_EXPECT(lines[jss::error][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(lines[jss::error][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(lines[jss::error][jss::message] == "Invalid field 'peer'.");
|
||||
BEAST_EXPECT(lines.isMember(jss::jsonrpc) && lines[jss::jsonrpc] == "2.0");
|
||||
BEAST_EXPECT(lines.isMember(jss::ripplerpc) && lines[jss::ripplerpc] == "2.0");
|
||||
@@ -918,6 +1043,8 @@ public:
|
||||
request[jss::id] = 5;
|
||||
request[jss::params] = params;
|
||||
auto const lines = env.rpc("json2", to_string(request));
|
||||
BEAST_EXPECT(lines[jss::error][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(lines[jss::error][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::error][jss::message] ==
|
||||
"Invalid field 'ledger_index', not string or number.");
|
||||
@@ -937,6 +1064,8 @@ public:
|
||||
request[jss::id] = 5;
|
||||
request[jss::params] = params;
|
||||
auto const lines = env.rpc("json2", to_string(request));
|
||||
BEAST_EXPECT(lines[jss::error][jss::error] == "lgrNotFound");
|
||||
BEAST_EXPECT(lines[jss::error][jss::error_code] == RpcLgrNotFound);
|
||||
BEAST_EXPECT(lines[jss::error][jss::message] == "ledgerNotFound");
|
||||
BEAST_EXPECT(lines.isMember(jss::jsonrpc) && lines[jss::jsonrpc] == "2.0");
|
||||
BEAST_EXPECT(lines.isMember(jss::ripplerpc) && lines[jss::ripplerpc] == "2.0");
|
||||
@@ -1055,6 +1184,7 @@ public:
|
||||
request[jss::params] = params;
|
||||
auto const lines = env.rpc("json2", to_string(request));
|
||||
BEAST_EXPECT(lines[jss::error][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(lines[jss::error][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::error][jss::message] ==
|
||||
"Exactly one of 'ledger_hash' or 'ledger_index' can be "
|
||||
@@ -1110,6 +1240,8 @@ public:
|
||||
request[jss::id] = 5;
|
||||
request[jss::params] = params;
|
||||
auto const lines = env.rpc("json2", to_string(request));
|
||||
BEAST_EXPECT(lines[jss::error][jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(lines[jss::error][jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::error][jss::message] ==
|
||||
rpc::makeError(RpcActMalformed)[jss::error_message]);
|
||||
@@ -1129,6 +1261,8 @@ public:
|
||||
request[jss::id] = 5;
|
||||
request[jss::params] = params;
|
||||
auto const lines = env.rpc("json2", to_string(request));
|
||||
BEAST_EXPECT(lines[jss::error][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(lines[jss::error][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::error][jss::message] ==
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer"));
|
||||
@@ -1202,6 +1336,8 @@ public:
|
||||
requestD[jss::id] = 5;
|
||||
requestD[jss::params] = paramsD;
|
||||
auto const linesD = env.rpc("json2", to_string(requestD));
|
||||
BEAST_EXPECT(linesD[jss::error][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(linesD[jss::error][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
linesD[jss::error][jss::message] ==
|
||||
rpc::makeError(RpcInvalidParams)[jss::error_message]);
|
||||
@@ -1221,6 +1357,8 @@ public:
|
||||
request[jss::id] = 5;
|
||||
request[jss::params] = params;
|
||||
auto const lines = env.rpc("json2", to_string(request));
|
||||
BEAST_EXPECT(lines[jss::error][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(lines[jss::error][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::error][jss::message] ==
|
||||
rpc::expectedFieldMessage(jss::marker, "string"));
|
||||
@@ -1378,6 +1516,8 @@ public:
|
||||
linesEndRequest[jss::id] = 5;
|
||||
linesEndRequest[jss::params] = linesEndParams;
|
||||
auto const linesEnd = env.rpc("json2", to_string(linesEndRequest));
|
||||
BEAST_EXPECT(linesEnd[jss::error][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(linesEnd[jss::error][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
linesEnd[jss::error][jss::message] ==
|
||||
rpc::makeError(RpcInvalidParams)[jss::error_message]);
|
||||
|
||||
@@ -140,6 +140,8 @@ public:
|
||||
{
|
||||
json::Value const params;
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Missing field 'account'.");
|
||||
}
|
||||
// test account non-string
|
||||
@@ -149,6 +151,7 @@ public:
|
||||
params[jss::account] = param;
|
||||
auto jrr = env.rpc("json", "account_objects", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'account'.");
|
||||
};
|
||||
|
||||
@@ -164,6 +167,8 @@ public:
|
||||
json::Value params;
|
||||
params[jss::account] = "n94JNrQYkDrpt62bbSR7nVEhdyAvcJXRAsjEkFYyqRkh9SUTYEqV";
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Account malformed.");
|
||||
}
|
||||
// test error on account that's not in the ledger.
|
||||
@@ -171,6 +176,8 @@ public:
|
||||
json::Value params;
|
||||
params[jss::account] = Account{"bogie"}.human();
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "actNotFound");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcActNotFound);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Account not found.");
|
||||
}
|
||||
Account const bob{"bob"};
|
||||
@@ -180,6 +187,8 @@ public:
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::ledger_index] = 10;
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "lgrNotFound");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcLgrNotFound);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "ledgerNotFound");
|
||||
}
|
||||
|
||||
@@ -190,6 +199,8 @@ public:
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::type] = 10;
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
resp[jss::result][jss::error_message] == "Invalid field 'type', not string.");
|
||||
}
|
||||
@@ -199,6 +210,8 @@ public:
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::type] = "expedited";
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Invalid field 'type'.");
|
||||
}
|
||||
// test error on limit -ve
|
||||
@@ -207,6 +220,8 @@ public:
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::limit] = -1;
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
resp[jss::result][jss::error_message] ==
|
||||
"Invalid field 'limit', not unsigned integer.");
|
||||
@@ -217,6 +232,8 @@ public:
|
||||
params[jss::account] = bob.human();
|
||||
params[jss::sponsored] = "true";
|
||||
auto resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
resp[jss::result][jss::error_message] == "Invalid field 'sponsored', not boolean.");
|
||||
}
|
||||
@@ -238,27 +255,39 @@ public:
|
||||
std::string mark = to_string(resumeMarker);
|
||||
params[jss::marker] = 10;
|
||||
resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
resp[jss::result][jss::error_message] == "Invalid field 'marker', not string.");
|
||||
|
||||
params[jss::marker] = "This is a string with no comma";
|
||||
resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Invalid field 'marker'.");
|
||||
|
||||
params[jss::marker] = "This string has a comma, but is not hex";
|
||||
resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Invalid field 'marker'.");
|
||||
|
||||
params[jss::marker] = std::string(&mark[1U], 64);
|
||||
resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Invalid field 'marker'.");
|
||||
|
||||
params[jss::marker] = std::string(&mark[1U], 65);
|
||||
resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Invalid field 'marker'.");
|
||||
|
||||
params[jss::marker] = std::string(&mark[1U], 65) + "not hex";
|
||||
resp = env.rpc("json", "account_objects", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Invalid field 'marker'.");
|
||||
|
||||
// Should this be an error?
|
||||
@@ -603,7 +632,8 @@ public:
|
||||
|
||||
// Make a lambda that checks if the response has error for invalid type
|
||||
auto const acctObjsTypeIsInvalid = [](json::Value const& resp) {
|
||||
return resp[jss::result].isMember(jss::error) &&
|
||||
return resp[jss::result][jss::error] == "invalidParams" &&
|
||||
resp[jss::result][jss::error_code] == RpcInvalidParams &&
|
||||
resp[jss::result][jss::error_message] == "Invalid field \'type\'.";
|
||||
};
|
||||
|
||||
@@ -1174,7 +1204,9 @@ public:
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::marker] = marker;
|
||||
json::Value const resp = env.rpc("json", "account_nfts", to_string(params));
|
||||
return resp[jss::result][jss::error_message] == errorMessage;
|
||||
return resp[jss::result][jss::error] == "invalidParams" &&
|
||||
resp[jss::result][jss::error_code] == RpcInvalidParams &&
|
||||
resp[jss::result][jss::error_message] == errorMessage;
|
||||
};
|
||||
|
||||
// test an invalid marker that is not a string
|
||||
@@ -1427,7 +1459,9 @@ public:
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::marker] = marker;
|
||||
json::Value const resp = env.rpc("json", "account_objects", to_string(params));
|
||||
return resp[jss::result][jss::error_message] == "Invalid field \'marker\'.";
|
||||
return resp[jss::result][jss::error] == "invalidParams" &&
|
||||
resp[jss::result][jss::error_code] == RpcInvalidParams &&
|
||||
resp[jss::result][jss::error_message] == "Invalid field \'marker\'.";
|
||||
};
|
||||
|
||||
auto const markerStr = marker.asString();
|
||||
|
||||
@@ -173,7 +173,9 @@ public:
|
||||
jvParams[jss::limit] = 0u;
|
||||
auto const jrr =
|
||||
env.rpc("json", "account_offers", jvParams.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(jrr.isMember(jss::error_message));
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'limit'.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,9 +197,9 @@ public:
|
||||
{
|
||||
// no account field
|
||||
auto const jrr = env.rpc("account_offers");
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "badSyntax");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcBadSyntax);
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Syntax error.");
|
||||
}
|
||||
|
||||
@@ -226,9 +228,9 @@ public:
|
||||
jvParams[jss::account] = "";
|
||||
auto const jrr =
|
||||
env.rpc("json", "account_offers", jvParams.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Account malformed.");
|
||||
BEAST_EXPECT(jrr.isMember(jss::ledger_current_index));
|
||||
BEAST_EXPECT(jrr[jss::validated] == false);
|
||||
@@ -237,9 +239,9 @@ public:
|
||||
{
|
||||
// bogus account value
|
||||
auto const jrr = env.rpc("account_offers", Account("bogus").human())[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "actNotFound");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcActNotFound);
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Account not found.");
|
||||
}
|
||||
|
||||
@@ -250,9 +252,9 @@ public:
|
||||
jvParams[jss::limit] = "0"; // NOT an integer
|
||||
auto const jrr =
|
||||
env.rpc("json", "account_offers", jvParams.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'limit', not unsigned integer.");
|
||||
}
|
||||
|
||||
@@ -263,9 +265,9 @@ public:
|
||||
jvParams[jss::marker] = "NOT_A_MARKER";
|
||||
auto const jrr =
|
||||
env.rpc("json", "account_offers", jvParams.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECTS(
|
||||
jrr[jss::error_message] == "Invalid field 'marker'.", jrr.toStyledString());
|
||||
}
|
||||
@@ -277,9 +279,9 @@ public:
|
||||
jvParams[jss::marker] = 1;
|
||||
auto const jrr =
|
||||
env.rpc("json", "account_offers", jvParams.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'marker', not string.");
|
||||
}
|
||||
|
||||
@@ -290,9 +292,9 @@ public:
|
||||
jvParams[jss::ledger_index] = 10u;
|
||||
auto const jrr =
|
||||
env.rpc("json", "account_offers", jvParams.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "lgrNotFound");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcLgrNotFound);
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "ledgerNotFound");
|
||||
}
|
||||
|
||||
|
||||
+129
-62
@@ -195,19 +195,27 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
(j[jss::result][jss::transactions].size() == 0);
|
||||
};
|
||||
|
||||
auto const isErr = [](json::Value const& j, ErrorCodeI code) {
|
||||
return j.isMember(jss::result) && j[jss::result].isMember(jss::error) &&
|
||||
j[jss::result][jss::error] == rpc::getErrorInfo(code).token;
|
||||
auto const isErr = [](json::Value const& j, ErrorCodeI code, std::string const& message) {
|
||||
return j.isMember(jss::result) &&
|
||||
j[jss::result][jss::error] == rpc::getErrorInfo(code).token &&
|
||||
j[jss::result][jss::error_code] == code &&
|
||||
j[jss::result][jss::error_message] == message;
|
||||
};
|
||||
|
||||
json::Value jParams;
|
||||
jParams[jss::api_version] = apiVersion;
|
||||
|
||||
BEAST_EXPECT(isErr(env.rpc("json", "account_tx", to_string(jParams)), RpcInvalidParams));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(jParams)),
|
||||
RpcInvalidParams,
|
||||
"Missing field 'account'."));
|
||||
|
||||
jParams[jss::account] = "0xDEADBEEF";
|
||||
|
||||
BEAST_EXPECT(isErr(env.rpc("json", "account_tx", to_string(jParams)), RpcActMalformed));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(jParams)),
|
||||
RpcActMalformed,
|
||||
"Account malformed."));
|
||||
|
||||
jParams[jss::account] = a1.human();
|
||||
BEAST_EXPECT(hasTxs(env.rpc(apiVersion, "json", "account_tx", to_string(jParams))));
|
||||
@@ -227,8 +235,10 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(
|
||||
isErr(env.rpc("json", "account_tx", to_string(p)), RpcLgrIdxMalformed));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcLgrIdxMalformed,
|
||||
"Ledger index malformed."));
|
||||
}
|
||||
|
||||
p[jss::ledger_index_min] = 1;
|
||||
@@ -239,15 +249,18 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(
|
||||
isErr(env.rpc("json", "account_tx", to_string(p)), RpcLgrIdxMalformed));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcLgrIdxMalformed,
|
||||
"Ledger index malformed."));
|
||||
}
|
||||
|
||||
p[jss::ledger_index_min] = 2;
|
||||
p[jss::ledger_index_max] = 1;
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
(apiVersion == 1 ? RpcLgrIdxsInvalid : RpcInvalidLgrRange)));
|
||||
(apiVersion == 1 ? RpcLgrIdxsInvalid : RpcInvalidLgrRange),
|
||||
(apiVersion == 1 ? "Ledger indexes invalid." : "Ledger range is invalid.")));
|
||||
}
|
||||
// Ledger index min only
|
||||
{
|
||||
@@ -262,14 +275,17 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(
|
||||
isErr(env.rpc("json", "account_tx", to_string(p)), RpcLgrIdxMalformed));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcLgrIdxMalformed,
|
||||
"Ledger index malformed."));
|
||||
}
|
||||
|
||||
p[jss::ledger_index_min] = env.current()->header().seq;
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
(apiVersion == 1 ? RpcLgrIdxsInvalid : RpcInvalidLgrRange)));
|
||||
(apiVersion == 1 ? RpcLgrIdxsInvalid : RpcInvalidLgrRange),
|
||||
(apiVersion == 1 ? "Ledger indexes invalid." : "Ledger range is invalid.")));
|
||||
}
|
||||
|
||||
// Ledger index max only
|
||||
@@ -285,8 +301,10 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(
|
||||
isErr(env.rpc("json", "account_tx", to_string(p)), RpcLgrIdxMalformed));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcLgrIdxMalformed,
|
||||
"Ledger index malformed."));
|
||||
}
|
||||
|
||||
p[jss::ledger_index_max] = 3;
|
||||
@@ -310,10 +328,14 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
BEAST_EXPECT(noTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
|
||||
p[jss::ledger_index] = env.current()->header().seq;
|
||||
BEAST_EXPECT(isErr(env.rpc("json", "account_tx", to_string(p)), RpcLgrNotValidated));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcLgrNotValidated,
|
||||
"Ledger not validated."));
|
||||
|
||||
p[jss::ledger_index] = env.current()->header().seq + 1;
|
||||
BEAST_EXPECT(isErr(env.rpc("json", "account_tx", to_string(p)), RpcLgrNotFound));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)), RpcLgrNotFound, "ledgerNotFound"));
|
||||
}
|
||||
|
||||
{
|
||||
@@ -326,10 +348,16 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
BEAST_EXPECT(hasTxs(env.rpc(apiVersion, "json", "account_tx", to_string(p))));
|
||||
|
||||
p[jss::ledger_index] = "current";
|
||||
BEAST_EXPECT(isErr(env.rpc("json", "account_tx", to_string(p)), RpcLgrNotValidated));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcLgrNotValidated,
|
||||
"Ledger not validated."));
|
||||
|
||||
p[jss::ledger_index] = "";
|
||||
BEAST_EXPECT(isErr(env.rpc("json", "account_tx", to_string(p)), RpcLgrNotValidated));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcLgrNotValidated,
|
||||
"Ledger not validated."));
|
||||
}
|
||||
|
||||
// Ledger Hash
|
||||
@@ -360,7 +388,10 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(isErr(env.rpc("json", "account_tx", to_string(p)), RpcInvalidParams));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcInvalidParams,
|
||||
"invalidParams"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,8 +405,10 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(
|
||||
isErr(env.rpc("json", "account_tx", to_string(p)), RpcLgrIdxMalformed));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcLgrIdxMalformed,
|
||||
"Ledger index malformed."));
|
||||
}
|
||||
}
|
||||
// test account non-string
|
||||
@@ -385,6 +418,7 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
params[jss::account] = param;
|
||||
auto jrr = env.rpc("json", "account_tx", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'account'.");
|
||||
};
|
||||
|
||||
@@ -406,7 +440,10 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(isErr(env.rpc("json", "account_tx", to_string(p)), RpcInvalidParams));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'binary'."));
|
||||
}
|
||||
|
||||
p[jss::binary] = true;
|
||||
@@ -420,7 +457,10 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(isErr(env.rpc("json", "account_tx", to_string(p)), RpcInvalidParams));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'forward'."));
|
||||
}
|
||||
|
||||
p[jss::forward] = false;
|
||||
@@ -433,70 +473,83 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
|
||||
// Test case: limit = 0 should fail (below minimum)
|
||||
p[jss::limit] = 0;
|
||||
BEAST_EXPECT(isErr(env.rpc("json", "account_tx", to_string(p)), RpcInvalidParams));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'limit'."));
|
||||
|
||||
// Test case: limit = 1.2 should fail (not an integer)
|
||||
p[jss::limit] = 1.2;
|
||||
BEAST_EXPECT(
|
||||
env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] ==
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer"));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer")));
|
||||
|
||||
// Test case: limit = "10" should fail (string instead of integer)
|
||||
p[jss::limit] = "10";
|
||||
BEAST_EXPECT(
|
||||
env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] ==
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer"));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer")));
|
||||
|
||||
// Test case: limit = true should fail (boolean instead of integer)
|
||||
p[jss::limit] = true;
|
||||
BEAST_EXPECT(
|
||||
env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] ==
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer"));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer")));
|
||||
|
||||
// Test case: limit = false should fail (boolean instead of integer)
|
||||
p[jss::limit] = false;
|
||||
BEAST_EXPECT(
|
||||
env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] ==
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer"));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer")));
|
||||
|
||||
// Test case: limit = -1 should fail (negative number)
|
||||
p[jss::limit] = -1;
|
||||
BEAST_EXPECT(
|
||||
env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] ==
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer"));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer")));
|
||||
|
||||
// Test case: limit = [] should fail (array instead of integer)
|
||||
p[jss::limit] = json::Value(json::ValueType::Array);
|
||||
BEAST_EXPECT(
|
||||
env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] ==
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer"));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer")));
|
||||
|
||||
// Test case: limit = {} should fail (object instead of integer)
|
||||
p[jss::limit] = json::Value(json::ValueType::Object);
|
||||
BEAST_EXPECT(
|
||||
env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] ==
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer"));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer")));
|
||||
|
||||
// Test case: limit = "malformed" should fail (malformed string)
|
||||
p[jss::limit] = "malformed";
|
||||
BEAST_EXPECT(
|
||||
env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] ==
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer"));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer")));
|
||||
|
||||
// Test case: limit = ["limit"] should fail (array with string)
|
||||
p[jss::limit] = json::Value(json::ValueType::Array);
|
||||
p[jss::limit].append("limit");
|
||||
BEAST_EXPECT(
|
||||
env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] ==
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer"));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer")));
|
||||
|
||||
// Test case: limit = {"limit": 10} should fail (object with
|
||||
// property)
|
||||
p[jss::limit] = json::Value(json::ValueType::Object);
|
||||
p[jss::limit][jss::limit] = 10;
|
||||
BEAST_EXPECT(
|
||||
env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] ==
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer"));
|
||||
BEAST_EXPECT(isErr(
|
||||
env.rpc("json", "account_tx", to_string(p)),
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::limit, "unsigned integer")));
|
||||
|
||||
// Test case: limit = 10 should succeed (valid integer)
|
||||
p[jss::limit] = 10;
|
||||
@@ -985,12 +1038,16 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
};
|
||||
|
||||
auto const checkError = [&](json::Value const& delegateParams,
|
||||
std::string const& errToken) {
|
||||
std::string const& errToken,
|
||||
ErrorCodeI code,
|
||||
std::string const& errMessage) {
|
||||
json::Value params;
|
||||
params[jss::account] = alice.human();
|
||||
params[jss::delegate] = delegateParams;
|
||||
auto res = env.rpc("json", "account_tx", to_string(params));
|
||||
BEAST_EXPECT(res[jss::result][jss::error] == errToken);
|
||||
BEAST_EXPECT(res[jss::result][jss::error_code] == code);
|
||||
BEAST_EXPECT(res[jss::result][jss::error_message] == errMessage);
|
||||
};
|
||||
|
||||
// Filter: Delegatee. Expects TX #2 (Signed by Bob)
|
||||
@@ -1061,27 +1118,27 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
// "delegate" is not an object (e.g., string)
|
||||
{
|
||||
json::Value const p = "not_an_object";
|
||||
checkError(p, "invalidParams");
|
||||
checkError(p, "invalidParams", RpcInvalidParams, "Invalid field 'delegate'.");
|
||||
}
|
||||
|
||||
// Missing "delegate_filter" inside object
|
||||
{
|
||||
json::Value const p(json::ValueType::Object);
|
||||
checkError(p, "invalidParams");
|
||||
checkError(p, "invalidParams", RpcInvalidParams, "Invalid field 'delegate_filter'.");
|
||||
}
|
||||
|
||||
// "delegate_filter" is not a string (e.g., int)
|
||||
{
|
||||
json::Value p;
|
||||
p[jss::delegate_filter] = 123;
|
||||
checkError(p, "invalidParams");
|
||||
checkError(p, "invalidParams", RpcInvalidParams, "Invalid field 'delegate_filter'.");
|
||||
}
|
||||
|
||||
// "delegate_filter" has invalid value
|
||||
{
|
||||
json::Value p;
|
||||
p[jss::delegate_filter] = "random_string";
|
||||
checkError(p, "invalidParams");
|
||||
checkError(p, "invalidParams", RpcInvalidParams, "Invalid field 'delegate_filter'.");
|
||||
}
|
||||
|
||||
// "counterparty" is not a string
|
||||
@@ -1089,7 +1146,7 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
json::Value p;
|
||||
p[jss::delegate_filter] = "actor";
|
||||
p[jss::counter_party] = 123;
|
||||
checkError(p, "invalidParams");
|
||||
checkError(p, "invalidParams", RpcInvalidParams, "Invalid field 'counter_party'.");
|
||||
}
|
||||
|
||||
// "counterparty" is malformed base58
|
||||
@@ -1097,7 +1154,7 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
json::Value p;
|
||||
p[jss::delegate_filter] = "actor";
|
||||
p[jss::counter_party] = "not_an_account";
|
||||
checkError(p, "actMalformed");
|
||||
checkError(p, "actMalformed", RpcActMalformed, "Account malformed.");
|
||||
}
|
||||
|
||||
// Multi-signed non-delegated TX: Alice pays Carol via multi-sig.
|
||||
@@ -1181,6 +1238,11 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
p[jss::marker] = delegateMarker;
|
||||
auto const r = env.rpc("json", "account_tx", to_string(p));
|
||||
BEAST_EXPECT(r[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(r[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
r[jss::result][jss::error_message] ==
|
||||
"Do not mix delegate and non-delegate pagination markers in account_tx; "
|
||||
"repeat the same `delegate` object when using a delegate marker.");
|
||||
}
|
||||
|
||||
// Obtain a non-delegate marker; it must not carry the flag.
|
||||
@@ -1205,6 +1267,11 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
p[jss::marker] = normalMarker;
|
||||
auto const r = env.rpc("json", "account_tx", to_string(p));
|
||||
BEAST_EXPECT(r[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(r[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
r[jss::result][jss::error_message] ==
|
||||
"Do not mix delegate and non-delegate pagination markers in account_tx; "
|
||||
"repeat the same `delegate` object when using a delegate marker.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/config/Constants.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/KeyType.h>
|
||||
#include <xrpl/protocol/Serializer.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
@@ -186,32 +187,42 @@ class AmendmentBlocked_test : public beast::unit_test::Suite
|
||||
|
||||
// ledger_accept
|
||||
jr = env.rpc("ledger_accept")[jss::result];
|
||||
BEAST_EXPECT(jr.isMember(jss::error) && jr[jss::error] == "amendmentBlocked");
|
||||
BEAST_EXPECT(jr[jss::status] == "error");
|
||||
BEAST_EXPECT(jr[jss::error] == "amendmentBlocked");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcAmendmentBlocked);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Amendment blocked, need upgrade.");
|
||||
BEAST_EXPECT(!jr.isMember(jss::warnings));
|
||||
|
||||
// ledger_current
|
||||
jr = env.rpc("ledger_current")[jss::result];
|
||||
BEAST_EXPECT(jr.isMember(jss::error) && jr[jss::error] == "amendmentBlocked");
|
||||
BEAST_EXPECT(jr[jss::status] == "error");
|
||||
BEAST_EXPECT(jr[jss::error] == "amendmentBlocked");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcAmendmentBlocked);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Amendment blocked, need upgrade.");
|
||||
BEAST_EXPECT(!jr.isMember(jss::warnings));
|
||||
|
||||
// owner_info
|
||||
jr = env.rpc("owner_info", alice.human())[jss::result];
|
||||
BEAST_EXPECT(jr.isMember(jss::error) && jr[jss::error] == "amendmentBlocked");
|
||||
BEAST_EXPECT(jr[jss::status] == "error");
|
||||
BEAST_EXPECT(jr[jss::error] == "amendmentBlocked");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcAmendmentBlocked);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Amendment blocked, need upgrade.");
|
||||
BEAST_EXPECT(!jr.isMember(jss::warnings));
|
||||
|
||||
// path_find
|
||||
jr = wsc->invoke("path_find", pfReq)[jss::result];
|
||||
BEAST_EXPECT(jr.isMember(jss::error) && jr[jss::error] == "amendmentBlocked");
|
||||
BEAST_EXPECT(jr[jss::status] == "error");
|
||||
BEAST_EXPECT(jr[jss::error] == "amendmentBlocked");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcAmendmentBlocked);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Amendment blocked, need upgrade.");
|
||||
BEAST_EXPECT(!jr.isMember(jss::warnings));
|
||||
|
||||
// submit
|
||||
jr = env.rpc("submit", strHex(s.slice()))[jss::result];
|
||||
BEAST_EXPECT(jr.isMember(jss::error) && jr[jss::error] == "amendmentBlocked");
|
||||
BEAST_EXPECT(jr[jss::status] == "error");
|
||||
BEAST_EXPECT(jr[jss::error] == "amendmentBlocked");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcAmendmentBlocked);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Amendment blocked, need upgrade.");
|
||||
BEAST_EXPECT(!jr.isMember(jss::warnings));
|
||||
|
||||
// submit_multisigned
|
||||
@@ -221,7 +232,9 @@ class AmendmentBlocked_test : public beast::unit_test::Suite
|
||||
BEAST_EXPECT(jr[jss::status] == "success");
|
||||
msReq[jss::tx_json] = jr[jss::tx_json];
|
||||
jr = env.rpc("json", "submit_multisigned", to_string(msReq))[jss::result];
|
||||
BEAST_EXPECT(jr.isMember(jss::error) && jr[jss::error] == "amendmentBlocked");
|
||||
BEAST_EXPECT(jr[jss::error] == "amendmentBlocked");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcAmendmentBlocked);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Amendment blocked, need upgrade.");
|
||||
BEAST_EXPECT(!jr.isMember(jss::warnings));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/ledger/Ledger.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/LedgerFormats.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
@@ -77,8 +78,12 @@ public:
|
||||
// non-conventional ledger input should throw an error
|
||||
params["ledger"] = "non_conventional_ledger_input";
|
||||
resp = env.rpc("json", "book_changes", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result].isMember(jss::error));
|
||||
BEAST_EXPECT(resp[jss::result][jss::status] != "success");
|
||||
BEAST_EXPECT(resp[jss::result][jss::status] == "error");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
resp[jss::result][jss::error_message] ==
|
||||
"Invalid field 'ledger', not string or number.");
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/ledger/helpers/DirectoryHelpers.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
@@ -1225,6 +1226,7 @@ public:
|
||||
jvParams[jss::ledger_index] = 10u;
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "lgrNotFound");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcLgrNotFound);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "ledgerNotFound");
|
||||
}
|
||||
|
||||
@@ -1233,6 +1235,7 @@ public:
|
||||
jvParams[jss::ledger_index] = "validated";
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Missing field 'taker_pays'.");
|
||||
}
|
||||
|
||||
@@ -1242,6 +1245,7 @@ public:
|
||||
jvParams[jss::taker_pays] = json::ValueType::Object;
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Missing field 'taker_gets'.");
|
||||
}
|
||||
|
||||
@@ -1252,6 +1256,7 @@ public:
|
||||
jvParams[jss::taker_gets] = json::ValueType::Object;
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'taker_pays', not object.");
|
||||
}
|
||||
|
||||
@@ -1262,6 +1267,7 @@ public:
|
||||
jvParams[jss::taker_gets] = "not an object";
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'taker_gets', not object.");
|
||||
}
|
||||
|
||||
@@ -1272,6 +1278,7 @@ public:
|
||||
jvParams[jss::taker_gets] = json::ValueType::Object;
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Missing field 'taker_pays.currency'.");
|
||||
}
|
||||
|
||||
@@ -1282,6 +1289,7 @@ public:
|
||||
jvParams[jss::taker_gets] = json::ValueType::Object;
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] == "Invalid field 'taker_pays.currency', not string.");
|
||||
}
|
||||
@@ -1293,6 +1301,7 @@ public:
|
||||
jvParams[jss::taker_gets] = json::ValueType::Object;
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Missing field 'taker_gets.currency'.");
|
||||
}
|
||||
|
||||
@@ -1303,6 +1312,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::currency] = 1;
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] == "Invalid field 'taker_gets.currency', not string.");
|
||||
}
|
||||
@@ -1314,6 +1324,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::currency] = "XRP";
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "srcCurMalformed");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcSrcCurMalformed);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] == "Invalid field 'taker_pays.currency', bad currency.");
|
||||
}
|
||||
@@ -1325,6 +1336,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::currency] = "NOT_VALID";
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "dstAmtMalformed");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcDstAmtMalformed);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] == "Invalid field 'taker_gets.currency', bad currency.");
|
||||
}
|
||||
@@ -1337,6 +1349,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::issuer] = 1;
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] == "Invalid field 'taker_gets.issuer', not string.");
|
||||
}
|
||||
@@ -1349,6 +1362,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::currency] = "USD";
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] == "Invalid field 'taker_pays.issuer', not string.");
|
||||
}
|
||||
@@ -1361,6 +1375,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::currency] = "USD";
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "srcIsrMalformed");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcSrcIsrMalformed);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] == "Invalid field 'taker_pays.issuer', bad issuer.");
|
||||
}
|
||||
@@ -1373,6 +1388,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::currency] = "USD";
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "srcIsrMalformed");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcSrcIsrMalformed);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] ==
|
||||
"Invalid field 'taker_pays.issuer', bad issuer account one.");
|
||||
@@ -1386,6 +1402,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::issuer] = gw.human() + "DEAD";
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "dstIsrMalformed");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcDstIsrMalformed);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] == "Invalid field 'taker_gets.issuer', bad issuer.");
|
||||
}
|
||||
@@ -1398,6 +1415,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::issuer] = toBase58(noAccount());
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "dstIsrMalformed");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcDstIsrMalformed);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] ==
|
||||
"Invalid field 'taker_gets.issuer', bad issuer account one.");
|
||||
@@ -1412,6 +1430,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::issuer] = gw.human();
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "srcIsrMalformed");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcSrcIsrMalformed);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] ==
|
||||
"Unneeded field 'taker_pays.issuer' "
|
||||
@@ -1427,6 +1446,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::issuer] = gw.human();
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "srcIsrMalformed");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcSrcIsrMalformed);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] ==
|
||||
"Invalid field 'taker_pays.issuer', expected non-XRP issuer.");
|
||||
@@ -1441,6 +1461,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::issuer] = gw.human();
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'taker', not string.");
|
||||
}
|
||||
|
||||
@@ -1453,6 +1474,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::issuer] = gw.human();
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'taker'.");
|
||||
}
|
||||
|
||||
@@ -1466,6 +1488,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::issuer] = gw.human();
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "badMarket");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcBadMarket);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "No such market.");
|
||||
}
|
||||
|
||||
@@ -1479,6 +1502,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::issuer] = gw.human();
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'limit', not unsigned integer.");
|
||||
}
|
||||
|
||||
@@ -1492,6 +1516,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::issuer] = gw.human();
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'limit'.");
|
||||
}
|
||||
|
||||
@@ -1503,6 +1528,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::currency] = "USD";
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "dstIsrMalformed");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcDstIsrMalformed);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] ==
|
||||
"Invalid field 'taker_gets.issuer', "
|
||||
@@ -1518,6 +1544,7 @@ public:
|
||||
jvParams[jss::taker_gets][jss::issuer] = gw.human();
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "dstIsrMalformed");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcDstIsrMalformed);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] ==
|
||||
"Unneeded field 'taker_gets.issuer' "
|
||||
@@ -1533,6 +1560,7 @@ public:
|
||||
jvParams[jss::domain] = "badString";
|
||||
auto const jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "domainMalformed");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcDomainMalformed);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Unable to parse domain.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <test/jtx/Env.h>
|
||||
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
namespace xrpl {
|
||||
@@ -22,8 +23,8 @@ class Connect_test : public beast::unit_test::Suite
|
||||
|
||||
auto const result = env.rpc("json", "connect", "{}");
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::result].isMember(jss::error));
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == "notSynced");
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcNotSynced);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Not synced to the network.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Protocol.h> // IWYU pragma: keep
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/TxFlags.h>
|
||||
@@ -154,12 +155,16 @@ public:
|
||||
Account const becky{"becky"};
|
||||
|
||||
// Lambda that checks the (error) result of deposit_authorized.
|
||||
auto const verifyErr =
|
||||
[this](json::Value const& result, char const* error, char const* errorMsg) {
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == errorMsg);
|
||||
};
|
||||
auto const verifyErr = [this](
|
||||
json::Value const& result,
|
||||
char const* error,
|
||||
ErrorCodeI code,
|
||||
char const* errorMsg) {
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == code);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == errorMsg);
|
||||
};
|
||||
|
||||
Env env(*this);
|
||||
{
|
||||
@@ -167,28 +172,33 @@ public:
|
||||
json::Value args{depositAuthArgs(alice, becky)};
|
||||
args.removeMember(jss::source_account);
|
||||
json::Value const result{env.rpc("json", "deposit_authorized", args.toStyledString())};
|
||||
verifyErr(result, "invalidParams", "Missing field 'source_account'.");
|
||||
verifyErr(result, "invalidParams", RpcInvalidParams, "Missing field 'source_account'.");
|
||||
}
|
||||
{
|
||||
// Non-string source_account field.
|
||||
json::Value args{depositAuthArgs(alice, becky)};
|
||||
args[jss::source_account] = 7.3;
|
||||
json::Value const result{env.rpc("json", "deposit_authorized", args.toStyledString())};
|
||||
verifyErr(result, "invalidParams", "Invalid field 'source_account', not a string.");
|
||||
verifyErr(
|
||||
result,
|
||||
"invalidParams",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'source_account', not a string.");
|
||||
}
|
||||
{
|
||||
// Corrupt source_account field.
|
||||
json::Value args{depositAuthArgs(alice, becky)};
|
||||
args[jss::source_account] = "rG1QQv2nh2gr7RCZ!P8YYcBUKCCN633jCn";
|
||||
json::Value const result{env.rpc("json", "deposit_authorized", args.toStyledString())};
|
||||
verifyErr(result, "actMalformed", "Account malformed.");
|
||||
verifyErr(result, "actMalformed", RpcActMalformed, "Account malformed.");
|
||||
}
|
||||
{
|
||||
// Missing destination_account field.
|
||||
json::Value args{depositAuthArgs(alice, becky)};
|
||||
args.removeMember(jss::destination_account);
|
||||
json::Value const result{env.rpc("json", "deposit_authorized", args.toStyledString())};
|
||||
verifyErr(result, "invalidParams", "Missing field 'destination_account'.");
|
||||
verifyErr(
|
||||
result, "invalidParams", RpcInvalidParams, "Missing field 'destination_account'.");
|
||||
}
|
||||
{
|
||||
// Non-string destination_account field.
|
||||
@@ -196,40 +206,46 @@ public:
|
||||
args[jss::destination_account] = 7.3;
|
||||
json::Value const result{env.rpc("json", "deposit_authorized", args.toStyledString())};
|
||||
verifyErr(
|
||||
result, "invalidParams", "Invalid field 'destination_account', not a string.");
|
||||
result,
|
||||
"invalidParams",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'destination_account', not a string.");
|
||||
}
|
||||
{
|
||||
// Corrupt destination_account field.
|
||||
json::Value args{depositAuthArgs(alice, becky)};
|
||||
args[jss::destination_account] = "rP6P9ypfAmc!pw8SZHNwM4nvZHFXDraQas";
|
||||
json::Value const result{env.rpc("json", "deposit_authorized", args.toStyledString())};
|
||||
verifyErr(result, "actMalformed", "Account malformed.");
|
||||
verifyErr(result, "actMalformed", RpcActMalformed, "Account malformed.");
|
||||
}
|
||||
{
|
||||
// Request an invalid ledger.
|
||||
json::Value const args{depositAuthArgs(alice, becky, "-1")};
|
||||
json::Value const result{env.rpc("json", "deposit_authorized", args.toStyledString())};
|
||||
verifyErr(
|
||||
result, "invalidParams", "Invalid field 'ledger_index', not string or number.");
|
||||
result,
|
||||
"invalidParams",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'ledger_index', not string or number.");
|
||||
}
|
||||
{
|
||||
// Request a ledger that doesn't exist yet as a string.
|
||||
json::Value const args{depositAuthArgs(alice, becky, "17")};
|
||||
json::Value const result{env.rpc("json", "deposit_authorized", args.toStyledString())};
|
||||
verifyErr(result, "lgrNotFound", "ledgerNotFound");
|
||||
verifyErr(result, "lgrNotFound", RpcLgrNotFound, "ledgerNotFound");
|
||||
}
|
||||
{
|
||||
// Request a ledger that doesn't exist yet.
|
||||
json::Value args{depositAuthArgs(alice, becky)};
|
||||
args[jss::ledger_index] = 17;
|
||||
json::Value const result{env.rpc("json", "deposit_authorized", args.toStyledString())};
|
||||
verifyErr(result, "lgrNotFound", "ledgerNotFound");
|
||||
verifyErr(result, "lgrNotFound", RpcLgrNotFound, "ledgerNotFound");
|
||||
}
|
||||
{
|
||||
// alice is not yet funded.
|
||||
json::Value const args{depositAuthArgs(alice, becky)};
|
||||
json::Value const result{env.rpc("json", "deposit_authorized", args.toStyledString())};
|
||||
verifyErr(result, "srcActNotFound", "Source account not found.");
|
||||
verifyErr(result, "srcActNotFound", RpcSrcActNotFound, "Source account not found.");
|
||||
}
|
||||
env.fund(XRP(1000), alice);
|
||||
env.close();
|
||||
@@ -237,7 +253,8 @@ public:
|
||||
// becky is not yet funded.
|
||||
json::Value const args{depositAuthArgs(alice, becky)};
|
||||
json::Value const result{env.rpc("json", "deposit_authorized", args.toStyledString())};
|
||||
verifyErr(result, "dstActNotFound", "Destination account not found.");
|
||||
verifyErr(
|
||||
result, "dstActNotFound", RpcDstActNotFound, "Destination account not found.");
|
||||
}
|
||||
env.fund(XRP(1000), becky);
|
||||
env.close();
|
||||
@@ -256,9 +273,11 @@ public:
|
||||
jtx::Account const& dst,
|
||||
bool authorized,
|
||||
std::vector<std::string> credentialIDs = {},
|
||||
std::string_view error = "")
|
||||
std::string_view error = "",
|
||||
ErrorCodeI code = RpcSuccess,
|
||||
std::string_view errorMessage = "")
|
||||
{
|
||||
BEAST_EXPECT(result[jss::status] == authorized ? jss::success : jss::error);
|
||||
BEAST_EXPECT(result[jss::status] == (authorized ? jss::success : jss::error));
|
||||
if (result.isMember(jss::deposit_authorized))
|
||||
BEAST_EXPECT(result[jss::deposit_authorized] == authorized);
|
||||
if (authorized)
|
||||
@@ -270,7 +289,11 @@ public:
|
||||
|
||||
BEAST_EXPECT(result.isMember(jss::error) == !error.empty());
|
||||
if (!error.empty())
|
||||
{
|
||||
BEAST_EXPECT(result[jss::error].asString() == error);
|
||||
BEAST_EXPECT(result[jss::error_code] == code);
|
||||
BEAST_EXPECT(result[jss::error_message].asString() == errorMessage);
|
||||
}
|
||||
|
||||
if (authorized)
|
||||
{
|
||||
@@ -334,7 +357,15 @@ public:
|
||||
args[jss::credentials] = json::ValueType::Array;
|
||||
|
||||
auto const jv = env.rpc("json", "deposit_authorized", args.toStyledString());
|
||||
checkCredentialsResponse(jv[jss::result], alice, becky, false, {}, "invalidParams");
|
||||
checkCredentialsResponse(
|
||||
jv[jss::result],
|
||||
alice,
|
||||
becky,
|
||||
false,
|
||||
{},
|
||||
"invalidParams",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'credentials', not is non-empty array of CredentialID(hash256).");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -348,7 +379,15 @@ public:
|
||||
args[jss::credentials].append(3);
|
||||
|
||||
auto const jv = env.rpc("json", "deposit_authorized", args.toStyledString());
|
||||
checkCredentialsResponse(jv[jss::result], alice, becky, false, {}, "invalidParams");
|
||||
checkCredentialsResponse(
|
||||
jv[jss::result],
|
||||
alice,
|
||||
becky,
|
||||
false,
|
||||
{},
|
||||
"invalidParams",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'credentials', not an array of CredentialID(hash256).");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -362,7 +401,14 @@ public:
|
||||
|
||||
auto const jv = env.rpc("json", "deposit_authorized", args.toStyledString());
|
||||
checkCredentialsResponse(
|
||||
jv[jss::result], alice, becky, false, {"hello world"}, "invalidParams");
|
||||
jv[jss::result],
|
||||
alice,
|
||||
becky,
|
||||
false,
|
||||
{"hello world"},
|
||||
"invalidParams",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'credentials', not an array of CredentialID(hash256).");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -389,7 +435,9 @@ public:
|
||||
"0127AB8B4B29CCDBB61AA51C0799A8A6BB80B86A9899807C11ED576AF8516"
|
||||
"473",
|
||||
},
|
||||
"badCredentials");
|
||||
"badCredentials",
|
||||
RpcBadCredentials,
|
||||
"credentials don't exist");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -403,7 +451,14 @@ public:
|
||||
|
||||
auto const jv = env.rpc("json", "deposit_authorized", args.toStyledString());
|
||||
checkCredentialsResponse(
|
||||
jv[jss::result], alice, becky, false, {zero}, "badCredentials");
|
||||
jv[jss::result],
|
||||
alice,
|
||||
becky,
|
||||
false,
|
||||
{zero},
|
||||
"badCredentials",
|
||||
RpcBadCredentials,
|
||||
"credentials don't exist");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +471,14 @@ public:
|
||||
"deposit_authorized",
|
||||
depositAuthArgs(alice, becky, "validated", {credIdx}).toStyledString());
|
||||
checkCredentialsResponse(
|
||||
jv[jss::result], alice, becky, false, {credIdx}, "badCredentials");
|
||||
jv[jss::result],
|
||||
alice,
|
||||
becky,
|
||||
false,
|
||||
{credIdx},
|
||||
"badCredentials",
|
||||
RpcBadCredentials,
|
||||
"credentials aren't accepted");
|
||||
}
|
||||
|
||||
// alice accept credentials
|
||||
@@ -430,7 +492,14 @@ public:
|
||||
"deposit_authorized",
|
||||
depositAuthArgs(alice, becky, "validated", {credIdx, credIdx}).toStyledString());
|
||||
checkCredentialsResponse(
|
||||
jv[jss::result], alice, becky, false, {credIdx, credIdx}, "badCredentials");
|
||||
jv[jss::result],
|
||||
alice,
|
||||
becky,
|
||||
false,
|
||||
{credIdx, credIdx},
|
||||
"badCredentials",
|
||||
RpcBadCredentials,
|
||||
"duplicates in credentials");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -453,7 +522,14 @@ public:
|
||||
"deposit_authorized",
|
||||
depositAuthArgs(alice, becky, "validated", kCredIds).toStyledString());
|
||||
checkCredentialsResponse(
|
||||
jv[jss::result], alice, becky, false, kCredIds, "invalidParams");
|
||||
jv[jss::result],
|
||||
alice,
|
||||
becky,
|
||||
false,
|
||||
kCredIds,
|
||||
"invalidParams",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'credentials', not array too long.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -500,7 +576,14 @@ public:
|
||||
"deposit_authorized",
|
||||
depositAuthArgs(becky, alice, "validated", {credDiana}).toStyledString());
|
||||
checkCredentialsResponse(
|
||||
jv[jss::result], becky, alice, false, {credDiana}, "badCredentials");
|
||||
jv[jss::result],
|
||||
becky,
|
||||
alice,
|
||||
false,
|
||||
{credDiana},
|
||||
"badCredentials",
|
||||
RpcBadCredentials,
|
||||
"credentials doesn't belong to the root account");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -549,7 +632,14 @@ public:
|
||||
depositAuthArgs(alice, becky, "validated", {credIdx2}).toStyledString());
|
||||
|
||||
checkCredentialsResponse(
|
||||
jv[jss::result], alice, becky, false, {credIdx2}, "badCredentials");
|
||||
jv[jss::result],
|
||||
alice,
|
||||
becky,
|
||||
false,
|
||||
{credIdx2},
|
||||
"badCredentials",
|
||||
RpcBadCredentials,
|
||||
"credentials are expired");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/ledger/AmendmentTable.h>
|
||||
#include <xrpl/ledger/View.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/digest.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
@@ -206,6 +207,7 @@ class Feature_test : public beast::unit_test::Suite
|
||||
// feature names are case-sensitive - expect error here
|
||||
jrr = env.rpc("feature", "fMM")[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "badFeature");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcBadFeature);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Feature unknown or invalid.");
|
||||
|
||||
// Test feature name size checks
|
||||
@@ -253,6 +255,7 @@ class Feature_test : public beast::unit_test::Suite
|
||||
params[jss::feature] = param;
|
||||
auto jrr = env.rpc("json", "feature", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid parameters.");
|
||||
};
|
||||
|
||||
@@ -266,6 +269,7 @@ class Feature_test : public beast::unit_test::Suite
|
||||
{
|
||||
auto jrr = env.rpc("feature", "AllTheThings")[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "badFeature");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcBadFeature);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Feature unknown or invalid.");
|
||||
}
|
||||
}
|
||||
@@ -320,6 +324,7 @@ class Feature_test : public beast::unit_test::Suite
|
||||
"EF";
|
||||
auto const result = env.rpc("json", "feature", to_string(params))[jss::result];
|
||||
BEAST_EXPECTS(result[jss::error] == "badFeature", result.toStyledString());
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcBadFeature);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Feature unknown or invalid.");
|
||||
}
|
||||
|
||||
@@ -332,6 +337,7 @@ class Feature_test : public beast::unit_test::Suite
|
||||
params[jss::vetoed] = true;
|
||||
auto const result = env.rpc("json", "feature", to_string(params))[jss::result];
|
||||
BEAST_EXPECTS(result[jss::error] == "noPermission", result[jss::error].asString());
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcNoPermission);
|
||||
BEAST_EXPECT(
|
||||
result[jss::error_message] == "You don't have permission for this command.");
|
||||
}
|
||||
@@ -513,6 +519,7 @@ class Feature_test : public beast::unit_test::Suite
|
||||
|
||||
auto const result = env.rpc("json", "feature", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid parameters.");
|
||||
};
|
||||
|
||||
@@ -521,6 +528,7 @@ class Feature_test : public beast::unit_test::Suite
|
||||
// anything other than accept or reject is an error
|
||||
jrr = env.rpc("feature", kFeatureName, "maybe");
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
@@ -584,6 +592,7 @@ class Feature_test : public beast::unit_test::Suite
|
||||
// anything other than accept or reject is an error
|
||||
jrr = env.rpc("feature", featureName, "maybe");
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/protocol/ApiVersion.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/STAmount.h>
|
||||
#include <xrpl/protocol/TxFlags.h>
|
||||
@@ -172,7 +173,12 @@ public:
|
||||
|
||||
auto response = jv[jss::result];
|
||||
auto const error = apiVersion < 2u ? "invalidHotWallet" : "invalidParams";
|
||||
auto const errorCode = apiVersion < 2u ? RpcInvalidHotwallet : RpcInvalidParams;
|
||||
auto const errorMessage =
|
||||
apiVersion < 2u ? "Invalid hotwallet." : "Invalid parameters.";
|
||||
BEAST_EXPECT(response[jss::error] == error);
|
||||
BEAST_EXPECT(response[jss::error_code] == errorCode);
|
||||
BEAST_EXPECT(response[jss::error_message] == errorMessage);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -201,6 +207,8 @@ public:
|
||||
auto jv = wsc->invoke("gateway_balances", qry);
|
||||
expect(jv[jss::status] == "error");
|
||||
BEAST_EXPECT(jv[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jv[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jv[jss::result][jss::error_message] == "Invalid field 'account'.");
|
||||
});
|
||||
|
||||
// The same applies to a non-string "ident".
|
||||
@@ -212,6 +220,8 @@ public:
|
||||
auto jv = wsc->invoke("gateway_balances", qry2);
|
||||
expect(jv[jss::status] == "error");
|
||||
BEAST_EXPECT(jv[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jv[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jv[jss::result][jss::error_message] == "Invalid field 'ident'.");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/core/ServiceRegistry.h>
|
||||
#include <xrpl/ledger/OpenView.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
@@ -42,10 +43,14 @@ public:
|
||||
auto const baseFee = env.current()->fees().base;
|
||||
// missing base_asset
|
||||
auto ret = Oracle::aggregatePrice(env, std::nullopt, "USD", kOracles);
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "invalidParams");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(ret[jss::error_message].asString() == "Missing field 'base_asset'.");
|
||||
|
||||
// missing quote_asset
|
||||
ret = Oracle::aggregatePrice(env, "XRP", std::nullopt, kOracles);
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "invalidParams");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(ret[jss::error_message].asString() == "Missing field 'quote_asset'.");
|
||||
|
||||
// invalid base_asset, quote_asset
|
||||
@@ -69,28 +74,44 @@ public:
|
||||
{
|
||||
ret = Oracle::aggregatePrice(env, "USD", v, kOracles);
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "invalidParams");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(ret[jss::error_message].asString() == "Invalid parameters.");
|
||||
ret = Oracle::aggregatePrice(env, v, "USD", kOracles);
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "invalidParams");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(ret[jss::error_message].asString() == "Invalid parameters.");
|
||||
ret = Oracle::aggregatePrice(env, v, v, kOracles);
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "invalidParams");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(ret[jss::error_message].asString() == "Invalid parameters.");
|
||||
}
|
||||
|
||||
// missing oracles array
|
||||
ret = Oracle::aggregatePrice(env, "XRP", "USD");
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "invalidParams");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(ret[jss::error_message].asString() == "Missing field 'oracles'.");
|
||||
|
||||
// empty oracles array
|
||||
ret = Oracle::aggregatePrice(env, "XRP", "USD", OraclesData{});
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "oracleMalformed");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcOracleMalformed);
|
||||
BEAST_EXPECT(ret[jss::error_message].asString() == "Oracle request is malformed.");
|
||||
|
||||
// no token pairs found
|
||||
ret = Oracle::aggregatePrice(env, "YAN", "USD", kOracles);
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "objectNotFound");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcObjectNotFound);
|
||||
BEAST_EXPECT(
|
||||
ret[jss::error_message].asString() == "The requested object was not found.");
|
||||
|
||||
// invalid oracle document id
|
||||
// id doesn't exist
|
||||
ret = Oracle::aggregatePrice(env, "XRP", "USD", {{{owner, 2}}});
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "objectNotFound");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcObjectNotFound);
|
||||
BEAST_EXPECT(
|
||||
ret[jss::error_message].asString() == "The requested object was not found.");
|
||||
// invalid values
|
||||
std::vector<AnyValue> const invalidDocument = {kNoneTag, 1.2, -1, "", "none", "1.2"};
|
||||
for (auto const& v : invalidDocument)
|
||||
@@ -99,17 +120,26 @@ public:
|
||||
json::Value jv;
|
||||
toJson(jv, v);
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "invalidParams");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(ret[jss::error_message].asString() == "Invalid parameters.");
|
||||
}
|
||||
// missing document id
|
||||
ret = Oracle::aggregatePrice(env, "XRP", "USD", {{{owner, std::nullopt}}});
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "oracleMalformed");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcOracleMalformed);
|
||||
BEAST_EXPECT(ret[jss::error_message].asString() == "Oracle request is malformed.");
|
||||
|
||||
// invalid owner
|
||||
ret = Oracle::aggregatePrice(env, "XRP", "USD", {{{some, 1}}});
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "objectNotFound");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcObjectNotFound);
|
||||
BEAST_EXPECT(
|
||||
ret[jss::error_message].asString() == "The requested object was not found.");
|
||||
// missing account
|
||||
ret = Oracle::aggregatePrice(env, "XRP", "USD", {{{std::nullopt, 1}}});
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "oracleMalformed");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcOracleMalformed);
|
||||
BEAST_EXPECT(ret[jss::error_message].asString() == "Oracle request is malformed.");
|
||||
|
||||
// oracles have wrong asset pair
|
||||
env.fund(XRP(1'000), owner);
|
||||
@@ -122,6 +152,9 @@ public:
|
||||
});
|
||||
ret = Oracle::aggregatePrice(env, "XRP", "USD", {{{owner, oracle.documentID()}}});
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "objectNotFound");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcObjectNotFound);
|
||||
BEAST_EXPECT(
|
||||
ret[jss::error_message].asString() == "The requested object was not found.");
|
||||
|
||||
// invalid trim value
|
||||
std::vector<AnyValue> const invalidTrim = {kNoneTag, 0, 26, -1, 1.2, "", "none", "1.2"};
|
||||
@@ -130,6 +163,8 @@ public:
|
||||
ret =
|
||||
Oracle::aggregatePrice(env, "XRP", "USD", {{{owner, oracle.documentID()}}}, v);
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "invalidParams");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(ret[jss::error_message].asString() == "Invalid parameters.");
|
||||
}
|
||||
|
||||
// invalid time threshold value
|
||||
@@ -139,6 +174,8 @@ public:
|
||||
ret = Oracle::aggregatePrice(
|
||||
env, "XRP", "USD", {{{owner, oracle.documentID()}}}, std::nullopt, v);
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "invalidParams");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(ret[jss::error_message].asString() == "Invalid parameters.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,6 +194,8 @@ public:
|
||||
}
|
||||
auto const ret = Oracle::aggregatePrice(env, "XRP", "USD", oracles);
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "oracleMalformed");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcOracleMalformed);
|
||||
BEAST_EXPECT(ret[jss::error_message].asString() == "Oracle request is malformed.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,6 +496,8 @@ public:
|
||||
// a nullptr dereference.
|
||||
auto const ret = Oracle::aggregatePrice(env, "XRP", "USD", oracles);
|
||||
BEAST_EXPECT(ret[jss::error].asString() == "objectNotFound");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcObjectNotFound);
|
||||
BEAST_EXPECT(ret[jss::error_message].asString() == "The requested object was not found.");
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+638
-343
File diff suppressed because it is too large.
Load diff
@@ -209,7 +209,12 @@ public:
|
||||
params[jss::seed_hex] = strings.masterSeedHex;
|
||||
|
||||
// Secret fields are mutually exclusive.
|
||||
BEAST_EXPECT(containsError(walletPropose(params)));
|
||||
auto const result = walletPropose(params);
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
result[jss::error_message] ==
|
||||
"Exactly one of the following must be specified: passphrase, seed or seed_hex");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -223,7 +228,8 @@ public:
|
||||
params[jss::key_type] = "secp256k1";
|
||||
params[jss::passphrase] = 20160506;
|
||||
auto result = walletPropose(params);
|
||||
BEAST_EXPECT(containsError(result));
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid field 'passphrase', not string.");
|
||||
}
|
||||
|
||||
@@ -232,7 +238,8 @@ public:
|
||||
params[jss::key_type] = "secp256k1";
|
||||
params[jss::seed] = json::ValueType::Object;
|
||||
auto result = walletPropose(params);
|
||||
BEAST_EXPECT(containsError(result));
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid field 'seed', not string.");
|
||||
}
|
||||
|
||||
@@ -241,7 +248,8 @@ public:
|
||||
params[jss::key_type] = "ed25519";
|
||||
params[jss::seed_hex] = json::ValueType::Array;
|
||||
auto result = walletPropose(params);
|
||||
BEAST_EXPECT(containsError(result));
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid field 'seed_hex', not string.");
|
||||
}
|
||||
|
||||
@@ -253,7 +261,8 @@ public:
|
||||
params[jss::seed_hex] = common::gMasterSeedHex;
|
||||
params[jss::seed] = common::gMasterSeed;
|
||||
auto result = walletPropose(params);
|
||||
BEAST_EXPECT(containsError(result));
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
result[jss::error_message] ==
|
||||
"Exactly one of the following must be specified: passphrase, "
|
||||
@@ -266,7 +275,8 @@ public:
|
||||
params[jss::key_type] = "prime256v1";
|
||||
params[jss::passphrase] = common::gMasterKey;
|
||||
auto result = walletPropose(params);
|
||||
BEAST_EXPECT(containsError(result));
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
@@ -275,7 +285,8 @@ public:
|
||||
params[jss::key_type] = json::ValueType::Object;
|
||||
params[jss::seed_hex] = common::gMasterSeedHex;
|
||||
auto result = walletPropose(params);
|
||||
BEAST_EXPECT(containsError(result));
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid field 'key_type', not string.");
|
||||
}
|
||||
|
||||
@@ -284,7 +295,8 @@ public:
|
||||
params[jss::key_type] = json::ValueType::Array;
|
||||
params[jss::seed] = common::gMasterSeed;
|
||||
auto result = walletPropose(params);
|
||||
BEAST_EXPECT(containsError(result));
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid field 'key_type', not string.");
|
||||
}
|
||||
}
|
||||
@@ -402,8 +414,9 @@ public:
|
||||
json::Value error;
|
||||
params[jss::secret] = 314159265;
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Invalid field 'secret', not string.");
|
||||
}
|
||||
|
||||
@@ -414,8 +427,9 @@ public:
|
||||
params[jss::secret].append("array:0");
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Invalid field 'secret', not string.");
|
||||
}
|
||||
|
||||
@@ -427,8 +441,9 @@ public:
|
||||
params[jss::secret]["number"] = 702;
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Invalid field 'secret', not string.");
|
||||
}
|
||||
|
||||
@@ -440,8 +455,9 @@ public:
|
||||
params[jss::secret] = common::gMasterSeed;
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
error[jss::error_message] ==
|
||||
"The secret field is not allowed if key_type is used.");
|
||||
@@ -455,8 +471,9 @@ public:
|
||||
params[jss::passphrase] = common::gMasterKey;
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Invalid field 'key_type'.");
|
||||
}
|
||||
|
||||
@@ -467,8 +484,9 @@ public:
|
||||
params[jss::seed_hex] = common::gMasterSeedHex;
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Invalid field 'key_type', not string.");
|
||||
}
|
||||
|
||||
@@ -479,8 +497,9 @@ public:
|
||||
params[jss::seed] = common::gMasterSeed;
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Invalid field 'key_type', not string.");
|
||||
}
|
||||
|
||||
@@ -492,8 +511,9 @@ public:
|
||||
params[jss::passphrase] = 1234567890;
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Invalid field 'passphrase', not string.");
|
||||
}
|
||||
|
||||
@@ -504,8 +524,9 @@ public:
|
||||
params[jss::passphrase] = json::ValueType::Object;
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Invalid field 'passphrase', not string.");
|
||||
}
|
||||
|
||||
@@ -516,8 +537,9 @@ public:
|
||||
params[jss::passphrase] = json::ValueType::Array;
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Invalid field 'passphrase', not string.");
|
||||
}
|
||||
|
||||
@@ -528,8 +550,9 @@ public:
|
||||
params[jss::passphrase] = "";
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "badSeed");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcBadSeed);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Disallowed seed.");
|
||||
}
|
||||
|
||||
@@ -541,8 +564,9 @@ public:
|
||||
params[jss::seed] = 443556;
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Invalid field 'seed', not string.");
|
||||
}
|
||||
|
||||
@@ -553,8 +577,9 @@ public:
|
||||
params[jss::seed] = json::ValueType::Object;
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Invalid field 'seed', not string.");
|
||||
}
|
||||
|
||||
@@ -565,8 +590,9 @@ public:
|
||||
params[jss::seed] = json::ValueType::Array;
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Invalid field 'seed', not string.");
|
||||
}
|
||||
|
||||
@@ -577,8 +603,9 @@ public:
|
||||
params[jss::seed] = "";
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "badSeed");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcBadSeed);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Disallowed seed.");
|
||||
}
|
||||
|
||||
@@ -589,8 +616,9 @@ public:
|
||||
params[jss::seed] = "s M V s h z D F p t Z E m h s";
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "badSeed");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcBadSeed);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Disallowed seed.");
|
||||
}
|
||||
|
||||
@@ -601,8 +629,9 @@ public:
|
||||
params[jss::seed] = "pnnjkbnobnml43679nbvjdsklnbjs";
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "badSeed");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcBadSeed);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Disallowed seed.");
|
||||
}
|
||||
|
||||
@@ -614,8 +643,9 @@ public:
|
||||
params[jss::seed_hex] = 443556;
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Invalid field 'seed_hex', not string.");
|
||||
}
|
||||
|
||||
@@ -626,8 +656,9 @@ public:
|
||||
params[jss::seed_hex] = json::ValueType::Object;
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Invalid field 'seed_hex', not string.");
|
||||
}
|
||||
|
||||
@@ -638,8 +669,9 @@ public:
|
||||
params[jss::seed_hex] = json::ValueType::Array;
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Invalid field 'seed_hex', not string.");
|
||||
}
|
||||
|
||||
@@ -650,8 +682,9 @@ public:
|
||||
params[jss::seed_hex] = "";
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "badSeed");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcBadSeed);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Disallowed seed.");
|
||||
}
|
||||
|
||||
@@ -662,8 +695,9 @@ public:
|
||||
params[jss::seed_hex] = "A670A19B";
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "badSeed");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcBadSeed);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Disallowed seed.");
|
||||
}
|
||||
|
||||
@@ -674,8 +708,9 @@ public:
|
||||
params[jss::seed_hex] = common::gPassphrase;
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "badSeed");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcBadSeed);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Disallowed seed.");
|
||||
}
|
||||
|
||||
@@ -686,8 +721,9 @@ public:
|
||||
params[jss::seed_hex] = "BE6A670A19B209E112146D0A7ED2AAD72567D0FC913";
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(!ret);
|
||||
BEAST_EXPECT(error[jss::error] == "badSeed");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcBadSeed);
|
||||
BEAST_EXPECT(error[jss::error_message] == "Disallowed seed.");
|
||||
}
|
||||
}
|
||||
@@ -723,7 +759,8 @@ public:
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(error[jss::error] == "badSeed");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcBadSeed);
|
||||
BEAST_EXPECT(
|
||||
error[jss::error_message] == "Specified seed is for an Ed25519 wallet.");
|
||||
}
|
||||
@@ -754,7 +791,8 @@ public:
|
||||
|
||||
auto const ret = keypairForSignature(params, error);
|
||||
|
||||
BEAST_EXPECT(containsError(error));
|
||||
BEAST_EXPECT(error[jss::error] == "badSeed");
|
||||
BEAST_EXPECT(error[jss::error_code] == RpcBadSeed);
|
||||
BEAST_EXPECT(
|
||||
error[jss::error_message] == "Specified seed is for an Ed25519 wallet.");
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/ledger/View.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/Serializer.h>
|
||||
@@ -131,8 +132,9 @@ public:
|
||||
json::Value jvParams;
|
||||
jvParams[jss::limit] = "0"; // NOT an integer
|
||||
auto const jrr = env.rpc("json", "ledger_data", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'limit', not integer.");
|
||||
}
|
||||
|
||||
@@ -141,8 +143,9 @@ public:
|
||||
json::Value jvParams;
|
||||
jvParams[jss::marker] = "NOT_A_MARKER";
|
||||
auto const jrr = env.rpc("json", "ledger_data", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'marker', not valid.");
|
||||
}
|
||||
|
||||
@@ -151,8 +154,9 @@ public:
|
||||
json::Value jvParams;
|
||||
jvParams[jss::marker] = 1;
|
||||
auto const jrr = env.rpc("json", "ledger_data", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'marker', not valid.");
|
||||
}
|
||||
|
||||
@@ -161,8 +165,9 @@ public:
|
||||
json::Value jvParams;
|
||||
jvParams[jss::ledger_index] = 10u;
|
||||
auto const jrr = env.rpc("json", "ledger_data", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "lgrNotFound");
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "lgrNotFound");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcLgrNotFound);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "ledgerNotFound");
|
||||
}
|
||||
|
||||
@@ -171,8 +176,9 @@ public:
|
||||
json::Value jvParams;
|
||||
jvParams[jss::binary] = "true";
|
||||
auto const jrr = env.rpc("json", "ledger_data", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'binary', not boolean.");
|
||||
}
|
||||
}
|
||||
@@ -459,8 +465,8 @@ public:
|
||||
jvParams[jss::ledger_index] = "current";
|
||||
jvParams[jss::type] = "misspelling";
|
||||
auto const jrr = env.rpc("json", "ledger_data", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr.isMember("error"));
|
||||
BEAST_EXPECT(jrr["error"] == "invalidParams");
|
||||
BEAST_EXPECT(jrr["error_code"] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr["error_message"] == "Invalid field 'type'.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,6 +153,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
checkErrorValue(
|
||||
json::Value const& jv,
|
||||
std::string const& err,
|
||||
ErrorCodeI code,
|
||||
std::string const& msg,
|
||||
std::source_location const location = std::source_location::current())
|
||||
{
|
||||
@@ -165,6 +166,14 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
"Expected error " + err + ", received " + jv[jss::error].asString() + ", at line " +
|
||||
std::to_string(location.line()) + ", " + jv.toStyledString());
|
||||
}
|
||||
if (BEAST_EXPECT(jv.isMember(jss::error_code)))
|
||||
{
|
||||
BEAST_EXPECTS(
|
||||
jv[jss::error_code] == code,
|
||||
"Expected error code " + std::to_string(code) + ", received " +
|
||||
jv[jss::error_code].asString() + ", at line " +
|
||||
std::to_string(location.line()) + ", " + jv.toStyledString());
|
||||
}
|
||||
if (msg.empty())
|
||||
{
|
||||
BEAST_EXPECTS(
|
||||
@@ -340,12 +349,21 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
apiVersion, "json", "ledger_entry", to_string(correctRequest))[jss::result];
|
||||
if (apiVersion < 2u)
|
||||
{
|
||||
checkErrorValue(jrr, "unknownOption", "", location);
|
||||
BEAST_EXPECTS(jrr[jss::status] == "error", std::to_string(location.line()));
|
||||
BEAST_EXPECTS(
|
||||
jrr[jss::error] == "unknownOption", std::to_string(location.line()));
|
||||
BEAST_EXPECTS(!jrr.isMember(jss::error_code), std::to_string(location.line()));
|
||||
BEAST_EXPECTS(
|
||||
jrr[jss::error_message].isNull(), std::to_string(location.line()));
|
||||
}
|
||||
else
|
||||
{
|
||||
checkErrorValue(
|
||||
jrr, "invalidParams", "No ledger_entry params provided.", location);
|
||||
jrr,
|
||||
"invalidParams",
|
||||
RpcInvalidParams,
|
||||
"No ledger_entry params provided.",
|
||||
location);
|
||||
}
|
||||
}
|
||||
auto const tryField = [&](json::Value fieldValue) -> void {
|
||||
@@ -354,7 +372,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
apiVersion, "json", "ledger_entry", to_string(correctRequest))[jss::result];
|
||||
auto const expectedErrMsg = rpc::expectedFieldMessage(
|
||||
fieldName, typeNameOverride.value_or(getTypeName(typeID)));
|
||||
checkErrorValue(jrr, expectedError, expectedErrMsg, location);
|
||||
checkErrorValue(jrr, expectedError, RpcInvalidParams, expectedErrMsg, location);
|
||||
};
|
||||
|
||||
auto const& badValues = getBadValues(typeID);
|
||||
@@ -387,13 +405,21 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
json::Value const jrr = env.rpc(
|
||||
apiVersion, "json", "ledger_entry", to_string(correctRequest))[jss::result];
|
||||
checkErrorValue(
|
||||
jrr, "malformedRequest", rpc::missingFieldMessage(fieldName.cStr()), location);
|
||||
jrr,
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
rpc::missingFieldMessage(fieldName.cStr()),
|
||||
location);
|
||||
|
||||
correctRequest[parentFieldName][fieldName] = json::ValueType::Null;
|
||||
json::Value const jrr2 = env.rpc(
|
||||
apiVersion, "json", "ledger_entry", to_string(correctRequest))[jss::result];
|
||||
checkErrorValue(
|
||||
jrr2, "malformedRequest", rpc::missingFieldMessage(fieldName.cStr()), location);
|
||||
jrr2,
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
rpc::missingFieldMessage(fieldName.cStr()),
|
||||
location);
|
||||
}
|
||||
auto const tryField = [&](json::Value fieldValue) -> void {
|
||||
correctRequest[parentFieldName][fieldName] = fieldValue;
|
||||
@@ -403,6 +429,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
checkErrorValue(
|
||||
jrr,
|
||||
expectedError,
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(fieldName, getTypeName(typeID)),
|
||||
location);
|
||||
};
|
||||
@@ -497,7 +524,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
"AA";
|
||||
auto const jrr = env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "lgrNotFound", "ledgerNotFound");
|
||||
checkErrorValue(jrr, "lgrNotFound", RpcLgrNotFound, "ledgerNotFound");
|
||||
}
|
||||
{
|
||||
// Missing ledger_entry ledger_hash
|
||||
@@ -511,7 +538,10 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
json::Value const jrr = env.rpc(
|
||||
apiVersion, "json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(
|
||||
jrr, "invalidParams", "Invalid field 'ledger_hash', not hex string.");
|
||||
jrr,
|
||||
"invalidParams",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'ledger_hash', not hex string.");
|
||||
};
|
||||
|
||||
auto const& badValues = getBadValues(typeId);
|
||||
@@ -530,7 +560,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
"00000000000000000000000000000000000000000000000000000000000000"
|
||||
"00";
|
||||
auto const jrr = env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(jrr, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
|
||||
forAllApiVersions([&, this](unsigned apiVersion) {
|
||||
@@ -546,11 +576,15 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
|
||||
if (apiVersion < 2u)
|
||||
{
|
||||
checkErrorValue(jrr, "unknownOption", "");
|
||||
BEAST_EXPECT(jrr[jss::status] == "error");
|
||||
BEAST_EXPECT(jrr[jss::error] == "unknownOption");
|
||||
BEAST_EXPECT(!jrr.isMember(jss::error_code));
|
||||
BEAST_EXPECT(jrr[jss::error_message].isNull());
|
||||
}
|
||||
else
|
||||
{
|
||||
checkErrorValue(jrr, "invalidParams", "No ledger_entry params provided.");
|
||||
checkErrorValue(
|
||||
jrr, "invalidParams", RpcInvalidParams, "No ledger_entry params provided.");
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -655,7 +689,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_hash] = ledgerHash;
|
||||
json::Value const jrr =
|
||||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(jrr, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -854,7 +888,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_hash] = ledgerHash;
|
||||
json::Value const jrr =
|
||||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(jrr, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
{
|
||||
// Request an index that is not a check. We'll use alice's
|
||||
@@ -872,7 +906,8 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_hash] = ledgerHash;
|
||||
json::Value const jrr =
|
||||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "unexpectedLedgerType", "Unexpected ledger type.");
|
||||
checkErrorValue(
|
||||
jrr, "unexpectedLedgerType", RpcUnexpectedLedgerType, "Unexpected ledger type.");
|
||||
}
|
||||
{
|
||||
// Check malformed cases
|
||||
@@ -931,7 +966,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
env,
|
||||
"48004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
|
||||
"E4");
|
||||
checkErrorValue(jv[jss::result], "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(jv[jss::result], "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -1126,7 +1161,8 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
auto const expectedErrMsg = fieldValue.isNull()
|
||||
? rpc::missingFieldMessage(jss::issuer.cStr())
|
||||
: rpc::expectedFieldMessage(jss::issuer, "AccountID");
|
||||
checkErrorValue(jrr, "malformedAuthorizedCredentials", expectedErrMsg);
|
||||
checkErrorValue(
|
||||
jrr, "malformedAuthorizedCredentials", RpcInvalidParams, expectedErrMsg);
|
||||
};
|
||||
|
||||
auto const& badValues = getBadValues(FieldType::AccountField);
|
||||
@@ -1155,6 +1191,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
checkErrorValue(
|
||||
jrr[jss::result],
|
||||
"malformedAuthorizedCredentials",
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::authorized_credentials, "array"));
|
||||
}
|
||||
|
||||
@@ -1177,7 +1214,8 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
auto const expectedErrMsg = fieldValue.isNull()
|
||||
? rpc::missingFieldMessage(jss::credential_type.cStr())
|
||||
: rpc::expectedFieldMessage(jss::credential_type, "hex string");
|
||||
checkErrorValue(jrr, "malformedAuthorizedCredentials", expectedErrMsg);
|
||||
checkErrorValue(
|
||||
jrr, "malformedAuthorizedCredentials", RpcInvalidParams, expectedErrMsg);
|
||||
};
|
||||
|
||||
auto const& badValues = getBadValues(FieldType::BlobField);
|
||||
@@ -1207,6 +1245,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
checkErrorValue(
|
||||
jrr[jss::result],
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
"Must have exactly one of `authorized` and "
|
||||
"`authorized_credentials`.");
|
||||
}
|
||||
@@ -1239,6 +1278,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
checkErrorValue(
|
||||
jrr[jss::result],
|
||||
"malformedAuthorizedCredentials",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'authorized_credentials', not array of objects.");
|
||||
}
|
||||
|
||||
@@ -1257,6 +1297,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
checkErrorValue(
|
||||
jrr[jss::result],
|
||||
"malformedAuthorizedCredentials",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'authorized_credentials', not array of objects.");
|
||||
}
|
||||
|
||||
@@ -1271,6 +1312,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
checkErrorValue(
|
||||
jrr[jss::result],
|
||||
"malformedAuthorizedCredentials",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'authorized_credentials', array empty.");
|
||||
}
|
||||
|
||||
@@ -1308,6 +1350,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
checkErrorValue(
|
||||
jrr[jss::result],
|
||||
"malformedAuthorizedCredentials",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'authorized_credentials', array too long.");
|
||||
}
|
||||
}
|
||||
@@ -1443,7 +1486,10 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
json::Value const jrr =
|
||||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(
|
||||
jrr, "malformedRequest", "Must have exactly one of `owner` and `dir_root` fields.");
|
||||
jrr,
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
"Must have exactly one of `owner` and `dir_root` fields.");
|
||||
}
|
||||
{
|
||||
// Incomplete directory object. Missing both dir_root and owner.
|
||||
@@ -1454,7 +1500,10 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
json::Value const jrr =
|
||||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(
|
||||
jrr, "malformedRequest", "Must have exactly one of `owner` and `dir_root` fields.");
|
||||
jrr,
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
"Must have exactly one of `owner` and `dir_root` fields.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1617,7 +1666,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
jvParams[jss::nft_offer][jss::seq] = offerSeq + 1000;
|
||||
json::Value const jrr =
|
||||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(jrr, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
|
||||
// negative tests
|
||||
@@ -1835,7 +1884,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_hash] = ledgerHash;
|
||||
json::Value const jrr =
|
||||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(jrr, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
{
|
||||
// Request an index that is not a payment channel.
|
||||
@@ -1844,7 +1893,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_hash] = ledgerHash;
|
||||
json::Value const jrr =
|
||||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(jrr, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -1919,6 +1968,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
checkErrorValue(
|
||||
jrr,
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'accounts', not length-2 array of "
|
||||
"Accounts.");
|
||||
}
|
||||
@@ -1937,6 +1987,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
checkErrorValue(
|
||||
jrr,
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'accounts', not length-2 array of "
|
||||
"Accounts.");
|
||||
}
|
||||
@@ -1957,6 +2008,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
checkErrorValue(
|
||||
jrr,
|
||||
"malformedAddress",
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::accounts, "array of Accounts"));
|
||||
}
|
||||
|
||||
@@ -1972,6 +2024,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
checkErrorValue(
|
||||
jrr,
|
||||
"malformedAddress",
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::accounts, "array of Accounts"));
|
||||
}
|
||||
};
|
||||
@@ -1994,7 +2047,8 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_hash] = ledgerHash;
|
||||
json::Value const jrr =
|
||||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "malformedRequest", "Cannot have a trustline to self.");
|
||||
checkErrorValue(
|
||||
jrr, "malformedRequest", RpcInvalidParams, "Cannot have a trustline to self.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2048,7 +2102,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_hash] = ledgerHash;
|
||||
json::Value const jrr =
|
||||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(jrr, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
{
|
||||
// Request an index that is not a signer list.
|
||||
@@ -2057,7 +2111,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_hash] = ledgerHash;
|
||||
json::Value const jrr =
|
||||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(jrr, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -2148,7 +2202,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_hash] = ledgerHash;
|
||||
json::Value const jrr =
|
||||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(jrr, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
{
|
||||
// First real ticket requested by index.
|
||||
@@ -2184,7 +2238,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_hash] = ledgerHash;
|
||||
json::Value const jrr =
|
||||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(jrr, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
{
|
||||
// Request a ticket using an account root entry.
|
||||
@@ -2193,7 +2247,8 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_hash] = ledgerHash;
|
||||
json::Value const jrr =
|
||||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "unexpectedLedgerType", "Unexpected ledger type.");
|
||||
checkErrorValue(
|
||||
jrr, "unexpectedLedgerType", RpcUnexpectedLedgerType, "Unexpected ledger type.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -2261,7 +2316,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
jvParams[jss::transaction_proposal][jss::ticket_seq] = ticketSeq + 1;
|
||||
jvParams[jss::ledger_hash] = ledgerHash;
|
||||
auto const jrr = env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(jrr, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
{
|
||||
// Lookup by an index of the wrong entry type.
|
||||
@@ -2269,7 +2324,8 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
jvParams[jss::transaction_proposal] = to_string(keylet::account(target).key);
|
||||
jvParams[jss::ledger_hash] = ledgerHash;
|
||||
auto const jrr = env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "unexpectedLedgerType", "Unexpected ledger type.");
|
||||
checkErrorValue(
|
||||
jrr, "unexpectedLedgerType", RpcUnexpectedLedgerType, "Unexpected ledger type.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -2333,7 +2389,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_hash] = ledgerHash;
|
||||
json::Value const jrr =
|
||||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(jrr, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
{
|
||||
// Malformed DID index
|
||||
@@ -2455,7 +2511,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_hash] = ledgerHash;
|
||||
json::Value const jrr =
|
||||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(jrr, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
{
|
||||
// Request the MPToken using its owner + mptIssuanceID.
|
||||
@@ -2478,7 +2534,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_hash] = ledgerHash;
|
||||
json::Value const jrr =
|
||||
env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(jrr, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
{
|
||||
// Malformed MPTIssuance index
|
||||
@@ -2546,7 +2602,8 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
"12F1F1F1F180D67377B2FAB292A31C922470326268D2B9B74CD1E582645B9A"
|
||||
"DE";
|
||||
auto const jrr = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkErrorValue(jrr[jss::result], "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(
|
||||
jrr[jss::result], "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
{
|
||||
// test basic malformed scenarios
|
||||
@@ -2592,7 +2649,9 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
auto checkResult = [&](bool good,
|
||||
json::Value const& jv,
|
||||
json::StaticString const& expectedType,
|
||||
std::optional<std::string> const& expectedError = {}) {
|
||||
std::optional<std::string> const& expectedError = {},
|
||||
ErrorCodeI expectedCode = RpcEntryNotFound,
|
||||
std::string const& expectedMessage = "Entry not found.") {
|
||||
if (good)
|
||||
{
|
||||
BEAST_EXPECTS(
|
||||
@@ -2607,9 +2666,10 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
{
|
||||
BEAST_EXPECTS(
|
||||
jv.isObject() && jv.isMember(jss::result) &&
|
||||
jv[jss::result].isMember(jss::error) &&
|
||||
!jv[jss::result].isMember(jss::node) &&
|
||||
jv[jss::result][jss::error] == expectedError.value_or("entryNotFound"),
|
||||
jv[jss::result][jss::error] == expectedError.value_or("entryNotFound") &&
|
||||
jv[jss::result][jss::error_code] == expectedCode &&
|
||||
jv[jss::result][jss::error_message] == expectedMessage,
|
||||
to_string(jv));
|
||||
}
|
||||
};
|
||||
@@ -2640,7 +2700,13 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[field] = json::ValueType::Null;
|
||||
auto const jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, expectedType, "malformedRequest");
|
||||
checkResult(
|
||||
false,
|
||||
jv,
|
||||
expectedType,
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(field, "hex string"));
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
}
|
||||
|
||||
@@ -2650,7 +2716,13 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[field] = "arbitrary string";
|
||||
auto const jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, expectedType, "malformedRequest");
|
||||
checkResult(
|
||||
false,
|
||||
jv,
|
||||
expectedType,
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(field, "hex string"));
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
}
|
||||
|
||||
@@ -2660,7 +2732,13 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[field] = false;
|
||||
auto const jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, expectedType, "invalidParams");
|
||||
checkResult(
|
||||
false,
|
||||
jv,
|
||||
expectedType,
|
||||
"invalidParams",
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(field, "true"));
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
}
|
||||
|
||||
@@ -2672,7 +2750,8 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[field] = badKey;
|
||||
auto const jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, expectedType, "entryNotFound");
|
||||
checkResult(
|
||||
false, jv, expectedType, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
BEAST_EXPECTS(jv[jss::result][jss::index] == badKey, to_string(jv));
|
||||
}
|
||||
|
||||
@@ -2683,7 +2762,13 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
params[jss::index] = field;
|
||||
params[jss::api_version] = 2;
|
||||
auto const jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, expectedType, "malformedRequest");
|
||||
checkResult(
|
||||
false,
|
||||
jv,
|
||||
expectedType,
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::index, "hex string"));
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
}
|
||||
|
||||
@@ -2722,7 +2807,13 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
params[jss::index] = field;
|
||||
params[jss::api_version] = 2;
|
||||
auto const jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, expectedType, "malformedRequest");
|
||||
checkResult(
|
||||
false,
|
||||
jv,
|
||||
expectedType,
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::index, "hex string"));
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
}
|
||||
|
||||
@@ -2787,7 +2878,9 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
auto checkResult = [&](bool good,
|
||||
json::Value const& jv,
|
||||
int expectedCount,
|
||||
std::optional<std::string> const& expectedError = {}) {
|
||||
std::optional<std::string> const& expectedError = {},
|
||||
ErrorCodeI expectedCode = RpcEntryNotFound,
|
||||
std::string const& expectedMessage = "Entry not found.") {
|
||||
if (good)
|
||||
{
|
||||
BEAST_EXPECTS(
|
||||
@@ -2807,9 +2900,10 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
{
|
||||
BEAST_EXPECTS(
|
||||
jv.isObject() && jv.isMember(jss::result) &&
|
||||
jv[jss::result].isMember(jss::error) &&
|
||||
!jv[jss::result].isMember(jss::node) &&
|
||||
jv[jss::result][jss::error] == expectedError.value_or("entryNotFound"),
|
||||
jv[jss::result][jss::error] == expectedError.value_or("entryNotFound") &&
|
||||
jv[jss::result][jss::error_code] == expectedCode &&
|
||||
jv[jss::result][jss::error_message] == expectedMessage,
|
||||
to_string(jv));
|
||||
}
|
||||
};
|
||||
@@ -2839,7 +2933,13 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::hashes] = json::ValueType::Null;
|
||||
auto jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, 0, "malformedRequest");
|
||||
checkResult(
|
||||
false,
|
||||
jv,
|
||||
0,
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::hashes, "hex string"));
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
}
|
||||
|
||||
@@ -2849,7 +2949,13 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::hashes] = "arbitrary string";
|
||||
auto const jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, 0, "malformedRequest");
|
||||
checkResult(
|
||||
false,
|
||||
jv,
|
||||
0,
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::hashes, "hex string"));
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
}
|
||||
|
||||
@@ -2859,7 +2965,13 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::hashes] = "10";
|
||||
auto const jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, 0, "malformedRequest");
|
||||
checkResult(
|
||||
false,
|
||||
jv,
|
||||
0,
|
||||
"malformedRequest",
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::hashes, "hex string"));
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
}
|
||||
|
||||
@@ -2869,7 +2981,13 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::hashes] = false;
|
||||
auto const jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, 0, "invalidParams");
|
||||
checkResult(
|
||||
false,
|
||||
jv,
|
||||
0,
|
||||
"invalidParams",
|
||||
RpcInvalidParams,
|
||||
rpc::expectedFieldMessage(jss::hashes, "true"));
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
}
|
||||
|
||||
@@ -2879,7 +2997,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::hashes] = -1;
|
||||
auto const jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, 0, "internal");
|
||||
checkResult(false, jv, 0, "internal", RpcInternal, "Internal error.");
|
||||
BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
|
||||
}
|
||||
|
||||
@@ -2890,7 +3008,8 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
params[jss::ledger_index] = jss::validated;
|
||||
params[jss::hashes] = badKey;
|
||||
auto const jv = env.rpc("json", "ledger_entry", to_string(params));
|
||||
checkResult(false, jv, 0, "entryNotFound");
|
||||
checkResult(
|
||||
false, jv, 0, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
BEAST_EXPECT(jv[jss::result][jss::index] == badKey);
|
||||
}
|
||||
|
||||
@@ -3028,12 +3147,18 @@ class LedgerEntry_XChain_test : public beast::unit_test::Suite,
|
||||
public test::jtx::XChainBridgeObjects
|
||||
{
|
||||
void
|
||||
checkErrorValue(json::Value const& jv, std::string const& err, std::string const& msg)
|
||||
checkErrorValue(
|
||||
json::Value const& jv,
|
||||
std::string const& err,
|
||||
ErrorCodeI code,
|
||||
std::string const& msg)
|
||||
{
|
||||
if (BEAST_EXPECT(jv.isMember(jss::status)))
|
||||
BEAST_EXPECT(jv[jss::status] == "error");
|
||||
if (BEAST_EXPECT(jv.isMember(jss::error)))
|
||||
BEAST_EXPECT(jv[jss::error] == err);
|
||||
if (BEAST_EXPECT(jv.isMember(jss::error_code)))
|
||||
BEAST_EXPECT(jv[jss::error_code] == code);
|
||||
if (msg.empty())
|
||||
{
|
||||
BEAST_EXPECT(
|
||||
@@ -3110,7 +3235,7 @@ class LedgerEntry_XChain_test : public beast::unit_test::Suite,
|
||||
json::Value const jrr =
|
||||
mcEnv.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
|
||||
checkErrorValue(jrr, "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(jrr, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
{
|
||||
// create two claim ids and verify that the bridge counter was
|
||||
@@ -3297,7 +3422,7 @@ class LedgerEntry_XChain_test : public beast::unit_test::Suite,
|
||||
[jss::xchain_owned_create_account_claim_id] = 1;
|
||||
json::Value const jrr =
|
||||
scEnv.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "entryNotFound", "Entry not found.");
|
||||
checkErrorValue(jrr, "entryNotFound", RpcEntryNotFound, "Entry not found.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
namespace xrpl {
|
||||
@@ -53,8 +54,10 @@ class LedgerHeader_test : public beast::unit_test::Suite
|
||||
json::Value params{json::ValueType::Object};
|
||||
params[jss::api_version] = 2;
|
||||
auto const result = env.client().invoke("ledger_header", params)[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "unknownCmd");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "unknownCmd");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcUnknownCommand);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Unknown method.");
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -37,12 +37,18 @@ namespace xrpl::test {
|
||||
class LedgerRPC_test : public beast::unit_test::Suite
|
||||
{
|
||||
void
|
||||
checkErrorValue(json::Value const& jv, std::string const& err, std::string const& msg)
|
||||
checkErrorValue(
|
||||
json::Value const& jv,
|
||||
std::string const& err,
|
||||
ErrorCodeI code,
|
||||
std::string const& msg)
|
||||
{
|
||||
if (BEAST_EXPECT(jv.isMember(jss::status)))
|
||||
BEAST_EXPECT(jv[jss::status] == "error");
|
||||
if (BEAST_EXPECT(jv.isMember(jss::error)))
|
||||
BEAST_EXPECT(jv[jss::error] == err);
|
||||
if (BEAST_EXPECT(jv.isMember(jss::error_code)))
|
||||
BEAST_EXPECT(jv[jss::error_code] == code);
|
||||
if (msg.empty())
|
||||
{
|
||||
BEAST_EXPECT(
|
||||
@@ -139,7 +145,10 @@ class LedgerRPC_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_index] = "potato";
|
||||
auto const jrr = env.rpc("json", "ledger", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(
|
||||
jrr, "invalidParams", "Invalid field 'ledger_index', not string or number.");
|
||||
jrr,
|
||||
"invalidParams",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'ledger_index', not string or number.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -148,7 +157,10 @@ class LedgerRPC_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_index] = -1;
|
||||
auto const jrr = env.rpc("json", "ledger", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(
|
||||
jrr, "invalidParams", "Invalid field 'ledger_index', not string or number.");
|
||||
jrr,
|
||||
"invalidParams",
|
||||
RpcInvalidParams,
|
||||
"Invalid field 'ledger_index', not string or number.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -156,13 +168,13 @@ class LedgerRPC_test : public beast::unit_test::Suite
|
||||
json::Value jvParams;
|
||||
jvParams[jss::ledger_index] = 10u;
|
||||
auto const jrr = env.rpc("json", "ledger", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "lgrNotFound", "ledgerNotFound");
|
||||
checkErrorValue(jrr, "lgrNotFound", RpcLgrNotFound, "ledgerNotFound");
|
||||
}
|
||||
|
||||
{
|
||||
// unrecognized string arg -- error
|
||||
auto const jrr = env.rpc("ledger", "arbitrary_text")[jss::result];
|
||||
checkErrorValue(jrr, "lgrNotFound", "ledgerNotFound");
|
||||
checkErrorValue(jrr, "lgrNotFound", RpcLgrNotFound, "ledgerNotFound");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -171,20 +183,21 @@ class LedgerRPC_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_index] = "validated";
|
||||
jvParams[jss::queue] = true;
|
||||
auto const jrr = env.rpc("json", "ledger", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "invalidParams", "Invalid parameters.");
|
||||
checkErrorValue(jrr, "invalidParams", RpcInvalidParams, "Invalid parameters.");
|
||||
}
|
||||
|
||||
{
|
||||
// Request a ledger with a very large (double) sequence.
|
||||
auto const ret = env.rpc("json", "ledger", "{ \"ledger_index\" : 2e15 }");
|
||||
BEAST_EXPECT(rpc::containsError(ret));
|
||||
BEAST_EXPECT(ret[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(ret[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(ret[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
{
|
||||
// Request a ledger with very large (integer) sequence.
|
||||
auto const ret = env.rpc("json", "ledger", "{ \"ledger_index\" : 1000000000000000 }");
|
||||
checkErrorValue(ret, "invalidParams", "Invalid parameters.");
|
||||
checkErrorValue(ret, "invalidParams", RpcInvalidParams, "Invalid parameters.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -193,7 +206,7 @@ class LedgerRPC_test : public beast::unit_test::Suite
|
||||
json::Value jvParams;
|
||||
jvParams[field] = "blah";
|
||||
auto const jrr = env.rpc("json", "ledger", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "invalidParams", "Invalid parameters.");
|
||||
checkErrorValue(jrr, "invalidParams", RpcInvalidParams, "Invalid parameters.");
|
||||
};
|
||||
testBooleanField(jss::full);
|
||||
testBooleanField(jss::accounts);
|
||||
@@ -255,7 +268,8 @@ class LedgerRPC_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_index] = 1u;
|
||||
jvParams[jss::full] = true;
|
||||
auto const jrr = env.rpc("json", "ledger", to_string(jvParams))[jss::result];
|
||||
checkErrorValue(jrr, "noPermission", "You don't have permission for this command.");
|
||||
checkErrorValue(
|
||||
jrr, "noPermission", RpcNoPermission, "You don't have permission for this command.");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -422,6 +436,7 @@ class LedgerRPC_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger] = "invalid";
|
||||
jrr = env.rpc("json", "ledger", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] == "Invalid field 'ledger', not string or number.");
|
||||
|
||||
@@ -436,6 +451,7 @@ class LedgerRPC_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger] = 20;
|
||||
jrr = env.rpc("json", "ledger", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "lgrNotFound");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcLgrNotFound);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "ledgerNotFound");
|
||||
}
|
||||
|
||||
@@ -455,12 +471,14 @@ class LedgerRPC_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_hash] = "DEADBEEF" + hash3;
|
||||
jrr = env.rpc("json", "ledger", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'ledger_hash', not hex string.");
|
||||
|
||||
// request with non-string ledger_hash
|
||||
jvParams[jss::ledger_hash] = 2;
|
||||
jrr = env.rpc("json", "ledger", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'ledger_hash', not hex string.");
|
||||
|
||||
// malformed (non hex) hash
|
||||
@@ -469,6 +487,7 @@ class LedgerRPC_test : public beast::unit_test::Suite
|
||||
"7F2775F2F7485BB37307984C3C0F2340";
|
||||
jrr = env.rpc("json", "ledger", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'ledger_hash', not hex string.");
|
||||
|
||||
// properly formed, but just doesn't exist
|
||||
@@ -477,6 +496,7 @@ class LedgerRPC_test : public beast::unit_test::Suite
|
||||
"5A75FD71FC3FD6F36FEB803C5F1D812D";
|
||||
jrr = env.rpc("json", "ledger", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "lgrNotFound");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcLgrNotFound);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "ledgerNotFound");
|
||||
}
|
||||
|
||||
@@ -506,6 +526,7 @@ class LedgerRPC_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_index] = "invalid";
|
||||
jrr = env.rpc("json", "ledger", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::error_message] == "Invalid field 'ledger_index', not string or number.");
|
||||
|
||||
@@ -524,6 +545,7 @@ class LedgerRPC_test : public beast::unit_test::Suite
|
||||
jvParams[jss::ledger_index] = 7;
|
||||
jrr = env.rpc("json", "ledger", to_string(jvParams))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "lgrNotFound");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcLgrNotFound);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "ledgerNotFound");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,21 +43,24 @@ public:
|
||||
// arbitrary text is converted to 0.
|
||||
auto const result = env.rpc("ledger_request", "arbitrary_text");
|
||||
BEAST_EXPECT(
|
||||
rpc::containsError(result[jss::result]) &&
|
||||
result[jss::result][jss::error] == "invalidParams" &&
|
||||
result[jss::result][jss::error_code] == RpcInvalidParams &&
|
||||
result[jss::result][jss::error_message] == "Ledger index too small");
|
||||
}
|
||||
|
||||
{
|
||||
auto const result = env.rpc("ledger_request", "-1");
|
||||
BEAST_EXPECT(
|
||||
rpc::containsError(result[jss::result]) &&
|
||||
result[jss::result][jss::error] == "invalidParams" &&
|
||||
result[jss::result][jss::error_code] == RpcInvalidParams &&
|
||||
result[jss::result][jss::error_message] == "Ledger index too small");
|
||||
}
|
||||
|
||||
{
|
||||
auto const result = env.rpc("ledger_request", "0");
|
||||
BEAST_EXPECT(
|
||||
rpc::containsError(result[jss::result]) &&
|
||||
result[jss::result][jss::error] == "invalidParams" &&
|
||||
result[jss::result][jss::error_code] == RpcInvalidParams &&
|
||||
result[jss::result][jss::error_message] == "Ledger index too small");
|
||||
}
|
||||
|
||||
@@ -112,7 +115,8 @@ public:
|
||||
auto const result = env.rpc("ledger_request", ledgerHash);
|
||||
|
||||
BEAST_EXPECT(
|
||||
rpc::containsError(result[jss::result]) &&
|
||||
result[jss::result][jss::error] == "invalidParams" &&
|
||||
result[jss::result][jss::error_code] == RpcInvalidParams &&
|
||||
result[jss::result][jss::error_message] ==
|
||||
"Invalid field 'ledger_hash', not hex string.");
|
||||
}
|
||||
@@ -130,14 +134,16 @@ public:
|
||||
{
|
||||
auto const result = env.rpc("ledger_request", "4");
|
||||
BEAST_EXPECT(
|
||||
rpc::containsError(result[jss::result]) &&
|
||||
result[jss::result][jss::error] == "invalidParams" &&
|
||||
result[jss::result][jss::error_code] == RpcInvalidParams &&
|
||||
result[jss::result][jss::error_message] == "Ledger index too large");
|
||||
}
|
||||
|
||||
{
|
||||
auto const result = env.rpc("ledger_request", "5");
|
||||
BEAST_EXPECT(
|
||||
rpc::containsError(result[jss::result]) &&
|
||||
result[jss::result][jss::error] == "invalidParams" &&
|
||||
result[jss::result][jss::error_code] == RpcInvalidParams &&
|
||||
result[jss::result][jss::error_message] == "Ledger index too large");
|
||||
}
|
||||
}
|
||||
@@ -236,8 +242,9 @@ public:
|
||||
"8FE8592EF22FBC2E8C774C7A1ED76AA3FCE64BED17D748CBA9AFDF7072FE36C7");
|
||||
|
||||
result = env.rpc("ledger_request", "6")[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Ledger index too large");
|
||||
}
|
||||
|
||||
@@ -259,8 +266,9 @@ public:
|
||||
jvParams[jss::ledger_index] = "1";
|
||||
auto const result =
|
||||
env.rpc("json", "ledger_request", jvParams.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
result[jss::error_message] ==
|
||||
"Exactly one of 'ledger_hash' or 'ledger_index' can be "
|
||||
@@ -272,8 +280,9 @@ public:
|
||||
jvParams[jss::ledger_index] = "index";
|
||||
auto const result =
|
||||
env.rpc("json", "ledger_request", jvParams.toStyledString())[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid field 'ledger_index', not number.");
|
||||
}
|
||||
|
||||
@@ -285,11 +294,13 @@ public:
|
||||
if (apiVersion == 1)
|
||||
{
|
||||
BEAST_EXPECT(result[jss::error] == "noCurrent");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcNoCurrent);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Current ledger is unavailable.");
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(result[jss::error] == "notSynced");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcNotSynced);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Not synced to the network.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/config/Constants.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
#include <memory>
|
||||
@@ -27,6 +28,8 @@ public:
|
||||
{
|
||||
// manifest with no public key
|
||||
auto const info = env.rpc("json", "manifest", "{ }");
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(info[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message] == "Missing field 'public_key'.");
|
||||
}
|
||||
{
|
||||
@@ -36,6 +39,8 @@ public:
|
||||
"manifest",
|
||||
"{ \"public_key\": "
|
||||
"\"abcdef12345\"}");
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(info[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/SecretKey.h>
|
||||
#include <xrpl/protocol/TxFlags.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
@@ -49,6 +50,7 @@ class NoRippleCheck_test : public beast::unit_test::Suite
|
||||
{ // missing account field
|
||||
auto const result = env.rpc("json", "noripple_check", "{}")[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Missing field 'account'.");
|
||||
}
|
||||
|
||||
@@ -57,6 +59,7 @@ class NoRippleCheck_test : public beast::unit_test::Suite
|
||||
params[jss::account] = alice.human();
|
||||
auto const result = env.rpc("json", "noripple_check", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Missing field 'role'.");
|
||||
}
|
||||
|
||||
@@ -68,6 +71,7 @@ class NoRippleCheck_test : public beast::unit_test::Suite
|
||||
params[jss::role] = "user";
|
||||
auto jrr = env.rpc("json", "noripple_check", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'account'.");
|
||||
};
|
||||
|
||||
@@ -85,6 +89,7 @@ class NoRippleCheck_test : public beast::unit_test::Suite
|
||||
params[jss::role] = "not_a_role";
|
||||
auto const result = env.rpc("json", "noripple_check", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid field 'role'.");
|
||||
}
|
||||
|
||||
@@ -95,6 +100,7 @@ class NoRippleCheck_test : public beast::unit_test::Suite
|
||||
params[jss::limit] = -1;
|
||||
auto const result = env.rpc("json", "noripple_check", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
result[jss::error_message] == "Invalid field 'limit', not unsigned integer.");
|
||||
}
|
||||
@@ -106,6 +112,7 @@ class NoRippleCheck_test : public beast::unit_test::Suite
|
||||
params[jss::ledger_hash] = 1;
|
||||
auto const result = env.rpc("json", "noripple_check", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
result[jss::error_message] == "Invalid field 'ledger_hash', not hex string.");
|
||||
}
|
||||
@@ -117,6 +124,7 @@ class NoRippleCheck_test : public beast::unit_test::Suite
|
||||
params[jss::ledger] = "current";
|
||||
auto const result = env.rpc("json", "noripple_check", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "actNotFound");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcActNotFound);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Account not found.");
|
||||
}
|
||||
|
||||
@@ -129,6 +137,7 @@ class NoRippleCheck_test : public beast::unit_test::Suite
|
||||
params[jss::transactions] = true;
|
||||
auto const result = env.rpc("json", "noripple_check", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Account malformed.");
|
||||
// The changelog promises malformed-account responses carry
|
||||
// neither `transactions` nor any ledger metadata.
|
||||
@@ -147,6 +156,7 @@ class NoRippleCheck_test : public beast::unit_test::Suite
|
||||
params[jss::ledger_hash] = "ABCDEF";
|
||||
auto const result = env.rpc("json", "noripple_check", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
result[jss::error_message] ==
|
||||
"Exactly one of 'ledger', 'ledger_hash', or 'ledger_index' can "
|
||||
@@ -161,6 +171,7 @@ class NoRippleCheck_test : public beast::unit_test::Suite
|
||||
params[jss::ledger] = json::ValueType::Object;
|
||||
auto const result = env.rpc("json", "noripple_check", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
result[jss::error_message] == "Invalid field 'ledger', not string or number.");
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/protocol/ApiVersion.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/TER.h>
|
||||
#include <xrpl/protocol/TxFlags.h>
|
||||
@@ -256,6 +257,9 @@ public:
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(lines[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(lines[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
lines[jss::result][jss::error_message] == "Invalid field 'transactions'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STAmount.h>
|
||||
#include <xrpl/protocol/UintTypes.h>
|
||||
@@ -34,6 +35,7 @@ class OwnerInfo_test : public beast::unit_test::Suite
|
||||
{ // missing account field
|
||||
auto const result = env.rpc("json", "owner_info", "{}")[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Missing field 'account'.");
|
||||
}
|
||||
|
||||
@@ -44,8 +46,10 @@ class OwnerInfo_test : public beast::unit_test::Suite
|
||||
if (BEAST_EXPECT(result.isMember(jss::accepted) && result.isMember(jss::current)))
|
||||
{
|
||||
BEAST_EXPECT(result[jss::accepted][jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(result[jss::accepted][jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(result[jss::accepted][jss::error_message] == "Account malformed.");
|
||||
BEAST_EXPECT(result[jss::current][jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(result[jss::current][jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(result[jss::current][jss::error_message] == "Account malformed.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +183,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
// No params
|
||||
json::Value const params = json::ValueType::Object;
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
resp[jss::result][jss::error_message] ==
|
||||
"Neither `tx_blob` nor `tx_json` included.");
|
||||
@@ -194,6 +196,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_blob] = "1200";
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
resp[jss::result][jss::error_message] ==
|
||||
"Can only include one of `tx_blob` and `tx_json`.");
|
||||
@@ -204,6 +208,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_blob] = "1200";
|
||||
params[jss::binary] = "100";
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Invalid field 'binary'.");
|
||||
}
|
||||
{
|
||||
@@ -212,6 +218,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_blob] = "12";
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Invalid field 'tx_blob'.");
|
||||
}
|
||||
{
|
||||
@@ -220,6 +228,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_json] = json::ValueType::Object;
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
resp[jss::result][jss::error_message] == "Missing field 'tx.TransactionType'.");
|
||||
}
|
||||
@@ -231,6 +241,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_json] = txJson;
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Missing field 'tx.Account'.");
|
||||
}
|
||||
{
|
||||
@@ -239,6 +251,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_blob] = "";
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Invalid field 'tx_blob'.");
|
||||
}
|
||||
{
|
||||
@@ -247,6 +261,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_blob] = 1.1;
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Invalid field 'tx_blob'.");
|
||||
}
|
||||
{
|
||||
@@ -255,6 +271,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_json] = "";
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
resp[jss::result][jss::error_message] == "Invalid field 'tx_json', not object.");
|
||||
}
|
||||
@@ -267,6 +285,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
txJson[jss::Account] = env.master.human();
|
||||
params[jss::tx_json] = txJson;
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Invalid field 'seed'.");
|
||||
}
|
||||
{
|
||||
@@ -278,6 +298,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
txJson[jss::Account] = env.master.human();
|
||||
params[jss::tx_json] = txJson;
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Invalid field 'secret'.");
|
||||
}
|
||||
{
|
||||
@@ -289,6 +311,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
txJson[jss::Account] = env.master.human();
|
||||
params[jss::tx_json] = txJson;
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Invalid field 'seed_hex'.");
|
||||
}
|
||||
{
|
||||
@@ -300,6 +324,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
txJson[jss::Account] = env.master.human();
|
||||
params[jss::tx_json] = txJson;
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Invalid field 'passphrase'.");
|
||||
}
|
||||
{
|
||||
@@ -311,6 +337,9 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_json] = txJson;
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidTransaction");
|
||||
BEAST_EXPECT(!resp[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message].isNull());
|
||||
BEAST_EXPECT(
|
||||
resp[jss::result][jss::error_exception] ==
|
||||
"Field 'Destination' is required but missing.");
|
||||
@@ -327,6 +356,7 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
BEAST_EXPECTS(
|
||||
resp[jss::result][jss::error] == "srcActMalformed",
|
||||
resp[jss::result][jss::error].toStyledString());
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcSrcActMalformed);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Invalid field 'tx.Account'.");
|
||||
}
|
||||
{
|
||||
@@ -338,6 +368,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_json] = txJson;
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "srcActNotFound");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcSrcActNotFound);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Source account not found.");
|
||||
}
|
||||
{
|
||||
@@ -350,6 +382,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_json] = txJson;
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Invalid field 'tx.Signers'.");
|
||||
}
|
||||
{
|
||||
@@ -363,6 +397,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_json] = txJson;
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Invalid field 'tx.Signers[0]'.");
|
||||
}
|
||||
{
|
||||
@@ -375,6 +411,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_json] = txJson;
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
resp[jss::result][jss::error_message] ==
|
||||
"Invalid field 'SponsorSignature', not object.");
|
||||
@@ -391,6 +429,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_json] = txJson;
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECTS(
|
||||
resp[jss::result][jss::error_message] ==
|
||||
"Invalid field 'tx.SponsorSignature.Signers'.",
|
||||
@@ -406,6 +446,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_json] = txJson;
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
resp[jss::result][jss::error_message] == "Field 'tx_json.foo' is unknown.");
|
||||
}
|
||||
@@ -415,6 +457,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
txJson[jss::TransactionType] = jss::AccountSet;
|
||||
txJson[jss::Account] = alice.human();
|
||||
auto const resp = env.rpc("simulate", to_string(txJson), "1");
|
||||
BEAST_EXPECT(resp[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(resp[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
{
|
||||
@@ -427,6 +471,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_json] = txJson;
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "transactionSigned");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcTxSigned);
|
||||
BEAST_EXPECT(
|
||||
resp[jss::result][jss::error_message] == "Transaction should not be signed.");
|
||||
}
|
||||
@@ -449,6 +495,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_json] = txJson;
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "transactionSigned");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcTxSigned);
|
||||
BEAST_EXPECT(
|
||||
resp[jss::result][jss::error_message] == "Transaction should not be signed.");
|
||||
}
|
||||
@@ -462,6 +510,8 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_json] = txJson;
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(
|
||||
resp[jss::result][jss::error_message] ==
|
||||
"tfInnerBatchTxn flag is not allowed on top-level transactions.");
|
||||
@@ -530,6 +580,7 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
{
|
||||
auto const resp = simulate(env, tx);
|
||||
BEAST_EXPECT(resp[jss::error] == "noPermission");
|
||||
BEAST_EXPECT(resp[jss::error_code] == RpcNoPermission);
|
||||
BEAST_EXPECT(
|
||||
resp[jss::error_message] ==
|
||||
"WASM transactions are only supported in admin mode.");
|
||||
@@ -559,7 +610,10 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
|
||||
using namespace jtx;
|
||||
|
||||
// Pin the reference fee so the asserted error message doesn't depend on
|
||||
// UNIT_TEST_REFERENCE_FEE.
|
||||
Env env(*this, envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->fees.referenceFee = 10;
|
||||
cfg->section(Sections::kTransactionQueue).set(Keys::kMinimumTxnInLedgerStandalone, "3");
|
||||
return cfg;
|
||||
}));
|
||||
@@ -579,11 +633,10 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
auto const result = resp[jss::result];
|
||||
if (BEAST_EXPECT(result.isMember(jss::error)))
|
||||
{
|
||||
BEAST_EXPECT(result[jss::error] == "highFee");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcHighFee);
|
||||
}
|
||||
BEAST_EXPECT(result[jss::error] == "highFee");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcHighFee);
|
||||
BEAST_EXPECT(
|
||||
result[jss::error_message] == "Fee of 8889 exceeds the requested tx limit of 100");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -613,6 +666,7 @@ class Simulate_test : public beast::unit_test::Suite
|
||||
params[jss::tx_json] = jt.jv;
|
||||
auto const resp = env.rpc("json", "simulate", to_string(params));
|
||||
BEAST_EXPECT(resp[jss::result][jss::error] == "notImpl");
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_code] == RpcNotImpl);
|
||||
BEAST_EXPECT(resp[jss::result][jss::error_message] == "Not implemented.");
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Seed.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
@@ -39,6 +40,7 @@ public:
|
||||
params[jss::fail_hard] = param;
|
||||
auto const jrr = env.rpc("json", "submit", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'fail_hard', not boolean.");
|
||||
}
|
||||
|
||||
@@ -50,6 +52,7 @@ public:
|
||||
params[jss::fail_hard] = param;
|
||||
auto const jrr = env.rpc("json", "submit", to_string(params))[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Invalid field 'fail_hard', not boolean.");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Fees.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
@@ -621,6 +622,7 @@ public:
|
||||
{
|
||||
auto const jr = env.rpc("json", method, "{}")[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
@@ -633,6 +635,7 @@ public:
|
||||
if (subscribe)
|
||||
{
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Failed to parse url.");
|
||||
}
|
||||
// else TODO: why isn't this an error for unsubscribe ?
|
||||
@@ -646,6 +649,7 @@ public:
|
||||
if (subscribe)
|
||||
{
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Only http and https is supported.");
|
||||
}
|
||||
}
|
||||
@@ -656,6 +660,7 @@ public:
|
||||
jv[jss::url] = "no-url";
|
||||
auto const jr = envNonadmin.rpc("json", method, to_string(jv))[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "noPermission");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcNoPermission);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "You don't have permission for this command.");
|
||||
}
|
||||
|
||||
@@ -677,6 +682,7 @@ public:
|
||||
jv[f] = nonArray;
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
@@ -685,6 +691,7 @@ public:
|
||||
jv[f] = json::ValueType::Array;
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "actMalformed");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Account malformed.");
|
||||
}
|
||||
}
|
||||
@@ -695,6 +702,7 @@ public:
|
||||
jv[jss::mpt_issuances] = nonArray;
|
||||
auto jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
@@ -704,6 +712,7 @@ public:
|
||||
jv[jss::mpt_issuances][0u] = 1;
|
||||
auto jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
@@ -713,6 +722,7 @@ public:
|
||||
jv[jss::mpt_issuances][0u] = "not-an-mpt-issuance-id";
|
||||
auto jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
@@ -722,6 +732,7 @@ public:
|
||||
jv[jss::mpt_issuances][0u] = "0123456789ABCDEF";
|
||||
auto jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
@@ -731,6 +742,7 @@ public:
|
||||
jv[jss::books] = nonArray;
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
@@ -740,6 +752,7 @@ public:
|
||||
jv[jss::books][0u] = 1;
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
@@ -752,6 +765,7 @@ public:
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
|
||||
BEAST_EXPECT(jr[jss::error] == "srcCurMalformed");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcSrcCurMalformed);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Source currency is malformed.");
|
||||
}
|
||||
|
||||
@@ -764,6 +778,7 @@ public:
|
||||
jv[jss::books][0u][jss::taker_pays][jss::currency] = "ZZZZ";
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "srcCurMalformed");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcSrcCurMalformed);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Source currency is malformed.");
|
||||
}
|
||||
|
||||
@@ -777,6 +792,7 @@ public:
|
||||
jv[jss::books][0u][jss::taker_pays][jss::issuer] = 1;
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "srcIsrMalformed");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcSrcIsrMalformed);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Source issuer is malformed.");
|
||||
}
|
||||
|
||||
@@ -790,6 +806,7 @@ public:
|
||||
jv[jss::books][0u][jss::taker_pays][jss::issuer] = Account{"gateway"}.human() + "DEAD";
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "srcIsrMalformed");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcSrcIsrMalformed);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Source issuer is malformed.");
|
||||
}
|
||||
|
||||
@@ -803,6 +820,7 @@ public:
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
// NOTE: this error is slightly incongruous with the equivalent source currency error
|
||||
BEAST_EXPECT(jr[jss::error] == "dstAmtMalformed");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcDstAmtMalformed);
|
||||
BEAST_EXPECT(
|
||||
jr[jss::error_message] == "Destination amount/currency/issuer is malformed.");
|
||||
}
|
||||
@@ -818,6 +836,7 @@ public:
|
||||
// NOTE: this error is slightly incongruous with the
|
||||
// equivalent source currency error
|
||||
BEAST_EXPECT(jr[jss::error] == "dstAmtMalformed");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcDstAmtMalformed);
|
||||
BEAST_EXPECT(
|
||||
jr[jss::error_message] == "Destination amount/currency/issuer is malformed.");
|
||||
}
|
||||
@@ -832,6 +851,7 @@ public:
|
||||
jv[jss::books][0u][jss::taker_gets][jss::issuer] = 1;
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "dstIsrMalformed");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcDstIsrMalformed);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Destination issuer is malformed.");
|
||||
}
|
||||
|
||||
@@ -845,6 +865,7 @@ public:
|
||||
jv[jss::books][0u][jss::taker_gets][jss::issuer] = Account{"gateway"}.human() + "DEAD";
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "dstIsrMalformed");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcDstIsrMalformed);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Destination issuer is malformed.");
|
||||
}
|
||||
|
||||
@@ -858,6 +879,7 @@ public:
|
||||
Account{"gateway"}["USD"](1).value().getJson(JsonOptions::Values::IncludeDate);
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "badMarket");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcBadMarket);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "No such market.");
|
||||
}
|
||||
|
||||
@@ -867,6 +889,7 @@ public:
|
||||
jv[jss::streams] = nonArray;
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
@@ -876,6 +899,7 @@ public:
|
||||
jv[jss::streams][0u] = 1;
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "malformedStream");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcStreamMalformed);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Stream malformed.");
|
||||
}
|
||||
|
||||
@@ -885,6 +909,7 @@ public:
|
||||
jv[jss::streams][0u] = "not_a_stream";
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "malformedStream");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcStreamMalformed);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Stream malformed.");
|
||||
}
|
||||
|
||||
@@ -901,6 +926,7 @@ public:
|
||||
jv[jss::books][0u][jss::taker] = 1;
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECTS(jr[jss::error] == "actMalformed", jr.toStyledString());
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Account malformed.");
|
||||
}
|
||||
|
||||
@@ -915,6 +941,7 @@ public:
|
||||
jv[jss::books][0u][jss::taker] = "not_an_account";
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECTS(jr[jss::error] == "actMalformed", jr.toStyledString());
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Account malformed.");
|
||||
}
|
||||
|
||||
@@ -929,6 +956,7 @@ public:
|
||||
jv[jss::books][0u][jss::taker] = Account{"alice"}.human() + "DEAD";
|
||||
auto const jr = wsc->invoke(method, jv)[jss::result];
|
||||
BEAST_EXPECTS(jr[jss::error] == "actMalformed", jr.toStyledString());
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcActMalformed);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Account malformed.");
|
||||
}
|
||||
}
|
||||
@@ -1784,6 +1812,7 @@ public:
|
||||
auto const jr =
|
||||
wsc->invoke("subscribe", accountsRequest(makeAccountStrings(6)))[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Too many subscriptions for this connection.");
|
||||
}
|
||||
|
||||
@@ -1866,6 +1895,7 @@ public:
|
||||
{
|
||||
auto const jr = wsc->invoke("subscribe", req)[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Too many subscriptions for this connection.");
|
||||
}
|
||||
|
||||
@@ -1916,6 +1946,7 @@ public:
|
||||
auto const jr =
|
||||
wsc->invoke("subscribe", accountHistoryRequest(alice.human()))[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Invalid parameters.");
|
||||
BEAST_EXPECT(jr[jss::error_message] != "Too many subscriptions for this connection.");
|
||||
}
|
||||
@@ -1951,6 +1982,7 @@ public:
|
||||
auto const jr =
|
||||
wsc->invoke("subscribe", accountHistoryRequest(bob.human()))[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Too many subscriptions for this connection.");
|
||||
}
|
||||
}
|
||||
@@ -1974,6 +2006,7 @@ public:
|
||||
auto const jr = wsc->invoke(
|
||||
"subscribe", mptIssuancesRequest(makeMPTIssuanceStrings(6)))[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Too many subscriptions for this connection.");
|
||||
}
|
||||
|
||||
@@ -2017,6 +2050,7 @@ public:
|
||||
auto const jr = wsc->invoke(
|
||||
"subscribe", mptIssuancesRequest(makeMPTIssuanceStrings(1, 100)))[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Too many subscriptions for this connection.");
|
||||
}
|
||||
}
|
||||
@@ -2041,6 +2075,7 @@ public:
|
||||
auto const jr = wsc->invoke(
|
||||
"subscribe", mptIssuancesRequest(makeMPTIssuanceStrings(3)))[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Too many subscriptions for this connection.");
|
||||
|
||||
// Two more issuances do fit the remaining allowance.
|
||||
@@ -2062,6 +2097,7 @@ public:
|
||||
auto const jr =
|
||||
wsc->invoke("subscribe", accountsRequest(makeAccountStrings(1)))[jss::result];
|
||||
BEAST_EXPECT(jr[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(jr[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(jr[jss::error_message] == "Too many subscriptions for this connection.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,16 +38,20 @@ class TransactionEntry_test : public beast::unit_test::Suite
|
||||
{
|
||||
// no params
|
||||
auto const result = env.client().invoke("transaction_entry", {})[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "fieldNotFoundTransaction");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "fieldNotFoundTransaction");
|
||||
BEAST_EXPECT(!result.isMember(jss::error_code));
|
||||
BEAST_EXPECT(result[jss::error_message].isNull());
|
||||
}
|
||||
|
||||
{
|
||||
json::Value params{json::ValueType::Object};
|
||||
params[jss::ledger] = 20;
|
||||
auto const result = env.client().invoke("transaction_entry", params)[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "lgrNotFound");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "lgrNotFound");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcLgrNotFound);
|
||||
BEAST_EXPECT(result[jss::error_message] == "ledgerNotFound");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -55,8 +59,10 @@ class TransactionEntry_test : public beast::unit_test::Suite
|
||||
params[jss::ledger] = "current";
|
||||
params[jss::tx_hash] = "DEADBEEF";
|
||||
auto const result = env.client().invoke("transaction_entry", params)[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "notYetImplemented");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "notYetImplemented");
|
||||
BEAST_EXPECT(!result.isMember(jss::error_code));
|
||||
BEAST_EXPECT(result[jss::error_message].isNull());
|
||||
}
|
||||
|
||||
{
|
||||
@@ -65,8 +71,10 @@ class TransactionEntry_test : public beast::unit_test::Suite
|
||||
params[jss::tx_hash] =
|
||||
"E2FE8D4AF3FCC3944DDF6CD8CDDC5E3F0AD50863EF8919AFEF10CB6408CD4D05";
|
||||
auto const result = env.client().invoke("transaction_entry", params)[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "notYetImplemented");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "notYetImplemented");
|
||||
BEAST_EXPECT(!result.isMember(jss::error_code));
|
||||
BEAST_EXPECT(result[jss::error_message].isNull());
|
||||
BEAST_EXPECT(result.isMember(jss::ledger_current_index));
|
||||
BEAST_EXPECT(!result.isMember(jss::ledger_hash));
|
||||
BEAST_EXPECT(result[jss::validated] == false);
|
||||
@@ -78,8 +86,10 @@ class TransactionEntry_test : public beast::unit_test::Suite
|
||||
params[jss::tx_hash] = "DEADBEEF";
|
||||
auto const result = env.client().invoke("transaction_entry", params)[jss::result];
|
||||
BEAST_EXPECT(!result[jss::ledger_hash].asString().empty());
|
||||
BEAST_EXPECT(result[jss::error] == "malformedRequest");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "malformedRequest");
|
||||
BEAST_EXPECT(!result.isMember(jss::error_code));
|
||||
BEAST_EXPECT(result[jss::error_message].isNull());
|
||||
}
|
||||
|
||||
for (auto const type : {json::ValueType::Object, json::ValueType::Array})
|
||||
@@ -88,8 +98,10 @@ class TransactionEntry_test : public beast::unit_test::Suite
|
||||
params[jss::ledger] = "closed";
|
||||
params[jss::tx_hash] = json::Value{type};
|
||||
auto const result = env.client().invoke("transaction_entry", params)[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "malformedRequest");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "malformedRequest");
|
||||
BEAST_EXPECT(!result.isMember(jss::error_code));
|
||||
BEAST_EXPECT(result[jss::error_message].isNull());
|
||||
}
|
||||
|
||||
std::string const txHash{
|
||||
@@ -100,58 +112,74 @@ class TransactionEntry_test : public beast::unit_test::Suite
|
||||
// No arguments
|
||||
json::Value const result{env.rpc("transaction_entry")};
|
||||
BEAST_EXPECT(result[jss::ledger_hash].asString().empty());
|
||||
BEAST_EXPECT(result[jss::error] == "badSyntax");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "badSyntax");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcBadSyntax);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Syntax error.");
|
||||
}
|
||||
|
||||
{
|
||||
// One argument
|
||||
json::Value const result{env.rpc("transaction_entry", txHash)};
|
||||
BEAST_EXPECT(result[jss::error] == "badSyntax");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "badSyntax");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcBadSyntax);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Syntax error.");
|
||||
}
|
||||
|
||||
{
|
||||
// First argument with too few characters
|
||||
json::Value const result{env.rpc("transaction_entry", txHash.substr(1), "closed")};
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
{
|
||||
// First argument with too many characters
|
||||
json::Value const result{env.rpc("transaction_entry", txHash + "A", "closed")};
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
{
|
||||
// Second argument not valid
|
||||
json::Value const result{env.rpc("transaction_entry", txHash, "closer")};
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
{
|
||||
// Ledger index of 0 is not valid
|
||||
json::Value const result{env.rpc("transaction_entry", txHash, "0")};
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
{
|
||||
// Three arguments
|
||||
json::Value const result{env.rpc("transaction_entry", txHash, "closed", "extra")};
|
||||
BEAST_EXPECT(result[jss::error] == "badSyntax");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "badSyntax");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcBadSyntax);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Syntax error.");
|
||||
}
|
||||
|
||||
{
|
||||
// Valid structure, but transaction not found.
|
||||
json::Value const result{env.rpc("transaction_entry", txHash, "closed")};
|
||||
BEAST_EXPECT(!result[jss::result][jss::ledger_hash].asString().empty());
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == "transactionNotFound");
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == "transactionNotFound");
|
||||
BEAST_EXPECT(!result[jss::result].isMember(jss::error_code));
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message].isNull());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
@@ -30,8 +31,10 @@ class TransactionHistory_test : public beast::unit_test::Suite
|
||||
{
|
||||
// no params
|
||||
auto const result = env.client().invoke("tx_history", {})[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid parameters.");
|
||||
}
|
||||
|
||||
{
|
||||
@@ -39,8 +42,11 @@ class TransactionHistory_test : public beast::unit_test::Suite
|
||||
json::Value params{json::ValueType::Object};
|
||||
params[jss::start] = 10001; // limited to <= 10000 for non admin
|
||||
auto const result = env.client().invoke("tx_history", params)[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "noPermission");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "noPermission");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcNoPermission);
|
||||
BEAST_EXPECT(
|
||||
result[jss::error_message] == "You don't have permission for this command.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,8 +60,10 @@ class TransactionHistory_test : public beast::unit_test::Suite
|
||||
json::Value params{json::ValueType::Object};
|
||||
params[jss::api_version] = 2;
|
||||
auto const result = env.client().invoke("tx_history", params)[jss::result];
|
||||
BEAST_EXPECT(result[jss::error] == "unknownCmd");
|
||||
BEAST_EXPECT(result[jss::status] == "error");
|
||||
BEAST_EXPECT(result[jss::error] == "unknownCmd");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcUnknownCommand);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Unknown method.");
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -110,9 +110,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
to_string(startLegSeq),
|
||||
to_string(endLegSeq + deltaEndSeq));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == notFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == notFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcTxnNotFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Transaction not found.");
|
||||
|
||||
if (deltaEndSeq != 0)
|
||||
{
|
||||
@@ -153,9 +154,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
to_string(startLegSeq),
|
||||
to_string(endLegSeq + deltaEndSeq));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == notFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == notFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcTxnNotFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Transaction not found.");
|
||||
BEAST_EXPECT(!result[jss::result][jss::searched_all].asBool());
|
||||
}
|
||||
|
||||
@@ -168,9 +170,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
to_string(startLegSeq),
|
||||
to_string(endLegSeq));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == notFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == notFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcTxnNotFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Transaction not found.");
|
||||
|
||||
BEAST_EXPECT(!result[jss::result][jss::searched_all].asBool());
|
||||
}
|
||||
@@ -184,9 +187,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
to_string(startLegSeq),
|
||||
to_string(deletedLedger - 1));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == notFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == notFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcTxnNotFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Transaction not found.");
|
||||
|
||||
BEAST_EXPECT(result[jss::result][jss::searched_all].asBool());
|
||||
}
|
||||
@@ -213,9 +217,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
to_string(deletedLedger - 1),
|
||||
to_string(startLegSeq));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == invalid);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == invalid);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcInvalidLgrRange);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Ledger range is invalid.");
|
||||
|
||||
BEAST_EXPECT(!result[jss::result].isMember(jss::searched_all));
|
||||
}
|
||||
@@ -229,9 +234,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
to_string(-1),
|
||||
to_string(deletedLedger - 1));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == invalid);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == invalid);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcInvalidLgrRange);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Ledger range is invalid.");
|
||||
|
||||
BEAST_EXPECT(!result[jss::result].isMember(jss::searched_all));
|
||||
}
|
||||
@@ -241,9 +247,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
auto const result = env.rpc(
|
||||
command, to_string(tx->getTransactionID()), binary, to_string(-20), to_string(-10));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == invalid);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == invalid);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcInvalidLgrRange);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Ledger range is invalid.");
|
||||
|
||||
BEAST_EXPECT(!result[jss::result].isMember(jss::searched_all));
|
||||
}
|
||||
@@ -253,9 +260,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
auto const result =
|
||||
env.rpc(command, to_string(tx->getTransactionID()), binary, to_string(20));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == invalid);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == invalid);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcInvalidLgrRange);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Ledger range is invalid.");
|
||||
|
||||
BEAST_EXPECT(!result[jss::result].isMember(jss::searched_all));
|
||||
}
|
||||
@@ -283,9 +291,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
to_string(startLegSeq),
|
||||
to_string(startLegSeq + 1001));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == excessive);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == excessive);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcExcessiveLgrRange);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Ledger range exceeds 1000.");
|
||||
|
||||
BEAST_EXPECT(!result[jss::result].isMember(jss::searched_all));
|
||||
}
|
||||
@@ -351,9 +360,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
auto const result = env.rpc(
|
||||
command, ctid, binary, to_string(startLegSeq), to_string(endLegSeq + deltaEndSeq));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == notFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == notFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcTxnNotFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Transaction not found.");
|
||||
|
||||
if (deltaEndSeq != 0)
|
||||
{
|
||||
@@ -394,9 +404,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
auto const result = env.rpc(
|
||||
command, ctid, binary, to_string(startLegSeq), to_string(endLegSeq + deltaEndSeq));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == notFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == notFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcTxnNotFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Transaction not found.");
|
||||
BEAST_EXPECT(!result[jss::result][jss::searched_all].asBool());
|
||||
}
|
||||
|
||||
@@ -406,9 +417,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
auto const result =
|
||||
env.rpc(command, ctid, to_string(startLegSeq), to_string(endLegSeq));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == notFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == notFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcTxnNotFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Transaction not found.");
|
||||
|
||||
BEAST_EXPECT(!result[jss::result][jss::searched_all].asBool());
|
||||
}
|
||||
@@ -419,9 +431,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
auto const result =
|
||||
env.rpc(command, ctid, to_string(startLegSeq), to_string(deletedLedger - 1));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == notFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == notFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcTxnNotFound);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Transaction not found.");
|
||||
|
||||
BEAST_EXPECT(!result[jss::result][jss::searched_all].asBool());
|
||||
}
|
||||
@@ -447,9 +460,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
auto const result = env.rpc(
|
||||
command, ctid, binary, to_string(deletedLedger - 1), to_string(startLegSeq));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == invalid);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == invalid);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcInvalidLgrRange);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Ledger range is invalid.");
|
||||
|
||||
BEAST_EXPECT(!result[jss::result].isMember(jss::searched_all));
|
||||
}
|
||||
@@ -459,9 +473,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
auto const result =
|
||||
env.rpc(command, ctid, binary, to_string(-1), to_string(deletedLedger - 1));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == invalid);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == invalid);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcInvalidLgrRange);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Ledger range is invalid.");
|
||||
|
||||
BEAST_EXPECT(!result[jss::result].isMember(jss::searched_all));
|
||||
}
|
||||
@@ -470,9 +485,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
{
|
||||
auto const result = env.rpc(command, ctid, binary, to_string(-20), to_string(-10));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == invalid);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == invalid);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcInvalidLgrRange);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Ledger range is invalid.");
|
||||
|
||||
BEAST_EXPECT(!result[jss::result].isMember(jss::searched_all));
|
||||
}
|
||||
@@ -481,9 +497,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
{
|
||||
auto const result = env.rpc(command, ctid, binary, to_string(20));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == invalid);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == invalid);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcInvalidLgrRange);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Ledger range is invalid.");
|
||||
|
||||
BEAST_EXPECT(!result[jss::result].isMember(jss::searched_all));
|
||||
}
|
||||
@@ -507,9 +524,10 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
auto const result = env.rpc(
|
||||
command, ctid, binary, to_string(startLegSeq), to_string(startLegSeq + 1001));
|
||||
|
||||
BEAST_EXPECT(
|
||||
result[jss::result][jss::status] == jss::error &&
|
||||
result[jss::result][jss::error] == excessive);
|
||||
BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
|
||||
BEAST_EXPECT(result[jss::result][jss::error] == excessive);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_code] == RpcExcessiveLgrRange);
|
||||
BEAST_EXPECT(result[jss::result][jss::error_message] == "Ledger range exceeds 1000.");
|
||||
|
||||
BEAST_EXPECT(!result[jss::result].isMember(jss::searched_all));
|
||||
}
|
||||
@@ -945,6 +963,7 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
auto result = signFor(env, tx);
|
||||
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Missing field 'tx_json.NetworkID'.");
|
||||
}
|
||||
|
||||
@@ -958,6 +977,7 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
auto result = signFor(env, tx);
|
||||
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid field 'tx_json.NetworkID'.");
|
||||
}
|
||||
|
||||
@@ -971,6 +991,7 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
auto result = signFor(env, tx);
|
||||
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid field 'tx_json.NetworkID'.");
|
||||
}
|
||||
|
||||
@@ -985,6 +1006,7 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
auto result = signFor(env, tx);
|
||||
|
||||
BEAST_EXPECT(result[jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(result[jss::error_message] == "Invalid field 'tx_json.NetworkID'.");
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/config/Constants.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
#include <memory>
|
||||
@@ -27,6 +28,8 @@ public:
|
||||
{
|
||||
Env env(*this);
|
||||
auto const info = env.rpc("validator_info");
|
||||
BEAST_EXPECT(info[jss::result][jss::error] == "invalidParams");
|
||||
BEAST_EXPECT(info[jss::result][jss::error_code] == RpcInvalidParams);
|
||||
BEAST_EXPECT(info[jss::result][jss::error_message] == "not a validator");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,33 +306,57 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En
|
||||
// 1 - FAILS with wrong pass
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
jrr = makeAdminRequest(env, proto, *user, *password + "_")[jss::result];
|
||||
BEAST_EXPECT(jrr["error"] == protoWs ? "forbidden" : "noPermission");
|
||||
BEAST_EXPECT(
|
||||
jrr["error_message"] == protoWs ? "Bad credentials."
|
||||
: "You don't have permission for this command.");
|
||||
if (protoWs)
|
||||
{
|
||||
BEAST_EXPECT(jrr[jss::error] == "forbidden");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcForbidden);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Bad credentials.");
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(jrr.isNull());
|
||||
}
|
||||
|
||||
// 2 - FAILS with password in an object
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
jrr = makeAdminRequest(env, proto, *user, *password, true)[jss::result];
|
||||
BEAST_EXPECT(jrr["error"] == protoWs ? "forbidden" : "noPermission");
|
||||
BEAST_EXPECT(
|
||||
jrr["error_message"] == protoWs ? "Bad credentials."
|
||||
: "You don't have permission for this command.");
|
||||
if (protoWs)
|
||||
{
|
||||
BEAST_EXPECT(jrr[jss::error] == "forbidden");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcForbidden);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Bad credentials.");
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(jrr.isNull());
|
||||
}
|
||||
|
||||
// 3 - FAILS with wrong user
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
jrr = makeAdminRequest(env, proto, *user + "_", *password)[jss::result];
|
||||
BEAST_EXPECT(jrr["error"] == protoWs ? "forbidden" : "noPermission");
|
||||
BEAST_EXPECT(
|
||||
jrr["error_message"] == protoWs ? "Bad credentials."
|
||||
: "You don't have permission for this command.");
|
||||
if (protoWs)
|
||||
{
|
||||
BEAST_EXPECT(jrr[jss::error] == "forbidden");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcForbidden);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Bad credentials.");
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(jrr.isNull());
|
||||
}
|
||||
|
||||
// 4 - FAILS no credentials
|
||||
jrr = makeAdminRequest(env, proto, "", "")[jss::result];
|
||||
BEAST_EXPECT(jrr["error"] == protoWs ? "forbidden" : "noPermission");
|
||||
BEAST_EXPECT(
|
||||
jrr["error_message"] == protoWs ? "Bad credentials."
|
||||
: "You don't have permission for this command.");
|
||||
if (protoWs)
|
||||
{
|
||||
BEAST_EXPECT(jrr[jss::error] == "forbidden");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcForbidden);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Bad credentials.");
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(jrr.isNull());
|
||||
}
|
||||
|
||||
// 5 - SUCCEEDS with proper credentials
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
@@ -353,10 +377,16 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En
|
||||
{
|
||||
// 1 - FAILS - admin disabled
|
||||
jrr = makeAdminRequest(env, proto, "", "")[jss::result];
|
||||
BEAST_EXPECT(jrr["error"] == protoWs ? "forbidden" : "noPermission");
|
||||
BEAST_EXPECT(
|
||||
jrr["error_message"] == protoWs ? "Bad credentials."
|
||||
: "You don't have permission for this command.");
|
||||
if (protoWs)
|
||||
{
|
||||
BEAST_EXPECT(jrr[jss::error] == "forbidden");
|
||||
BEAST_EXPECT(jrr[jss::error_code] == RpcForbidden);
|
||||
BEAST_EXPECT(jrr[jss::error_message] == "Bad credentials.");
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(jrr.isNull());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -730,7 +760,9 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En
|
||||
|
||||
{ // send invalid json
|
||||
auto resp = sendAndParse("NOT JSON");
|
||||
BEAST_EXPECT(resp.isMember(jss::error) && resp[jss::error] == "jsonInvalid");
|
||||
BEAST_EXPECT(resp[jss::error] == "jsonInvalid");
|
||||
BEAST_EXPECT(!resp.isMember(jss::error_code));
|
||||
BEAST_EXPECT(resp[jss::error_message].isNull());
|
||||
BEAST_EXPECT(!resp.isMember(jss::status));
|
||||
}
|
||||
|
||||
@@ -739,8 +771,10 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En
|
||||
jv[jss::command] = "foo";
|
||||
jv[jss::method] = "bar";
|
||||
auto resp = sendAndParse(to_string(jv));
|
||||
BEAST_EXPECT(resp.isMember(jss::error) && resp[jss::error] == "missingCommand");
|
||||
BEAST_EXPECT(resp.isMember(jss::status) && resp[jss::status] == "error");
|
||||
BEAST_EXPECT(resp[jss::status] == "error");
|
||||
BEAST_EXPECT(resp[jss::error] == "missingCommand");
|
||||
BEAST_EXPECT(!resp.isMember(jss::error_code));
|
||||
BEAST_EXPECT(resp[jss::error_message].isNull());
|
||||
}
|
||||
|
||||
{ // send a ping (not an error)
|
||||
|
||||
@@ -48,6 +48,13 @@ TEST(ProposalHelpers, plain_payment_is_valid)
|
||||
EXPECT_TRUE(proposal::isValidProposalTxnType(txOfType(ttPAYMENT)));
|
||||
}
|
||||
|
||||
// No TransactionType at all. STTx construction rejects this first, but the
|
||||
// helper takes any STObject, so it must return false rather than throw.
|
||||
TEST(ProposalHelpers, typeless_object_is_rejected)
|
||||
{
|
||||
EXPECT_FALSE(proposal::isValidProposalTxnType(STObject{sfGeneric}));
|
||||
}
|
||||
|
||||
// A nested TransactionProposalCreate. In practice STTx construction rejects
|
||||
// this earlier (the payload lacks TransactionProposalCreate's own template
|
||||
// fields), but the defense here re-checks that guard so the two cannot
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
#include <xrpld/rpc/Role.h>
|
||||
#include <xrpld/rpc/detail/SpecBridge.hpp>
|
||||
#include <xrpld/rpc/handlers/Handlers.h>
|
||||
#include <xrpld/rpc/handlers/account/AccountChannels.h>
|
||||
#include <xrpld/rpc/handlers/account/AccountCurrencies.h>
|
||||
#include <xrpld/rpc/handlers/account/AccountInfo.h>
|
||||
#include <xrpld/rpc/handlers/account/AccountLines.h>
|
||||
#include <xrpld/rpc/handlers/account/AccountNFTs.h>
|
||||
#include <xrpld/rpc/handlers/account/AccountOffers.h>
|
||||
#include <xrpld/rpc/handlers/ledger/Ledger.h>
|
||||
@@ -118,7 +121,7 @@ constexpr auto kHandlerArray = std::to_array<Handler>({
|
||||
// Request-response methods
|
||||
{
|
||||
.name = method::kAccountInfo,
|
||||
.valueMethod = Method::of<&byRef<&doAccountInfo>>(),
|
||||
.valueMethod = Method::of<&handle<AccountInfoHandler>>(),
|
||||
.role = Role::USER,
|
||||
.condition = Condition::NoCondition,
|
||||
},
|
||||
@@ -130,13 +133,13 @@ constexpr auto kHandlerArray = std::to_array<Handler>({
|
||||
},
|
||||
{
|
||||
.name = method::kAccountLines,
|
||||
.valueMethod = Method::of<&byRef<&doAccountLines>>(),
|
||||
.valueMethod = Method::of<&handle<AccountLinesHandler>>(),
|
||||
.role = Role::USER,
|
||||
.condition = Condition::NoCondition,
|
||||
},
|
||||
{
|
||||
.name = method::kAccountChannels,
|
||||
.valueMethod = Method::of<&byRef<&doAccountChannels>>(),
|
||||
.valueMethod = Method::of<&handle<AccountChannelsHandler>>(),
|
||||
.role = Role::USER,
|
||||
.condition = Condition::NoCondition,
|
||||
},
|
||||
|
||||
Loaded 100 of 107 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user