3#include <test/jtx/Account.h>
4#include <test/jtx/Env.h>
5#include <test/jtx/JTx.h>
6#include <test/jtx/TestHelpers.h>
7#include <test/jtx/amount.h>
8#include <test/jtx/fee.h>
9#include <test/jtx/noop.h>
10#include <test/jtx/sig.h>
11#include <test/jtx/sponsor.h>
13#include <xrpl/basics/Slice.h>
14#include <xrpl/basics/StringUtilities.h>
15#include <xrpl/beast/unit_test/suite.h>
16#include <xrpl/protocol/Feature.h>
17#include <xrpl/protocol/SField.h>
18#include <xrpl/protocol/STTx.h>
19#include <xrpl/protocol/Serializer.h>
20#include <xrpl/protocol/TxFlags.h>
21#include <xrpl/tx/apply.h>
34 testcase(
"Require Fully Canonical Signature");
48 testcase(
"Forced validity ignores the prefix era");
52 Env preFix{*
this, testableAmendments() - fixCleanup3_4_0};
53 Env postFix{*
this, testableAmendments()};
54 auto const preFixRules = preFix.current()->rules();
57 Account const sponsor{
"sponsor"};
58 postFix.fund(XRP(10'000), alice, sponsor);
64 auto const jt = postFix.jt(
68 Sig(sfSponsorSignature, sponsor));
69 if (!BEAST_EXPECT(jt.stx))
74 auto& router = preFix.app().getHashRouter();
89 testcase(
"Role signature cache is era specific");
93 Env preFix{*
this, testableAmendments() - fixCleanup3_4_0};
94 Env postFix{*
this, testableAmendments()};
95 auto const preFixRules = preFix.current()->rules();
96 auto const postFixRules = postFix.current()->rules();
99 Account const sponsor{
"sponsor"};
100 Account const counterparty{
"counterparty"};
101 for (
auto* env : {&preFix, &postFix})
103 env->fund(XRP(10'000), alice, sponsor, counterparty);
114 auto const jt = makeTx(preFix);
115 if (!BEAST_EXPECT(jt.stx))
118 auto& router = preFix.app().getHashRouter();
136 auto const jt = makeTx(postFix);
137 if (!BEAST_EXPECT(jt.stx))
140 auto& router = postFix.app().getHashRouter();
147 checkBothDirections([&](Env& env) {
152 Sig(sfSponsorSignature, sponsor));
159 checkBothDirections([&](Env& env) {
162 loan::kCounterparty(counterparty),
164 Sig(sfCounterpartySignature, counterparty));
173 "12000022000000002400000001201B00497D9C6140000000000F6950684000000"
174 "00000000C732103767C7B2C13AD90050A4263745E4BAB2B975417FA22E87780E1"
175 "506DDAF21139BE74483046022100E95670988A34C4DB0FA73A8BFD6383872AF43"
176 "8C147A62BC8387406298C3EADC1022100A7DC80508ED5A4750705C702A81CBF9D"
177 "2C2DC3AFEDBED37BBCCD97BC8C40E08F8114E25A26437D923EEF4D6D815DF9336"
178 "8B62E6440848314BB85996936E4F595287774684DC2AC6266024BEF";
180 auto ret =
strUnHex(nonFullyCanonicalTx);
192 fail(
"Non-Fully canonical signature was permitted");
void pass()
Record a successful test condition.
void fail(String const &reason, char const *file, int line)
Record a failure.
TestcaseT testcase
Memberspace for declaring test cases.
void testFullyCanonicalSigs()
void testForcedValidityIgnoresPrefixEra()
void testRoleSignatureCacheIsEraSpecific()
void run() override
Runs the suite.
Number is a floating point type that can represent a wide range of values.
virtual HashRouter & getHashRouter()=0
A transaction testing environment.
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
TER valid(STTx const &tx, ReadView const &view, AccountID const &src, beast::Journal j)
FeatureBitset testableAmendments()
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
constexpr FlagValue spfSponsorFee
Validity
Describes the pre-processing validity of a transaction.
@ SigBad
Signature is bad.
@ Valid
Signature and local checks are good / passed.
@ SigGoodOnly
Signature is good, but local checks fail.
std::pair< Validity, std::string > checkValidity(HashRouter &router, STTx const &tx, Rules const &rules)
Checks transaction signature and local checks.
Slice makeSlice(std::array< T, N > const &a)
void forceValidity(HashRouter &router, UInt256 const &txid, Validity validity)
Sets the validity of a given transaction in the cache.
std::optional< Blob > strUnHex(std::size_t strSize, Iterator begin, Iterator end)
BEAST_DEFINE_TESTSUITE(AccountTxPaging, app, xrpl)