rippled
Loading...
Searching...
No Matches
apply_test.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2020 Dev Null Productions
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#include <test/jtx/Env.h>
21
22#include <xrpld/app/tx/apply.h>
23
24#include <xrpl/basics/StringUtilities.h>
25#include <xrpl/protocol/Feature.h>
26
27namespace ripple {
28
30{
31public:
32 void
33 run() override
34 {
35 testcase("Require Fully Canonicial Signature");
37 }
38
39 void
41 {
42 // Construct a payments w/out a fully-canonical tx
43 std::string const non_fully_canonical_tx =
44 "12000022000000002400000001201B00497D9C6140000000000F6950684000000"
45 "00000000C732103767C7B2C13AD90050A4263745E4BAB2B975417FA22E87780E1"
46 "506DDAF21139BE74483046022100E95670988A34C4DB0FA73A8BFD6383872AF43"
47 "8C147A62BC8387406298C3EADC1022100A7DC80508ED5A4750705C702A81CBF9D"
48 "2C2DC3AFEDBED37BBCCD97BC8C40E08F8114E25A26437D923EEF4D6D815DF9336"
49 "8B62E6440848314BB85996936E4F595287774684DC2AC6266024BEF";
50
51 auto ret = strUnHex(non_fully_canonical_tx);
52 SerialIter sitTrans(makeSlice(*ret));
53 STTx const tx = *std::make_shared<STTx const>(std::ref(sitTrans));
54
55 {
56 test::jtx::Env no_fully_canonical(
57 *this,
59 featureRequireFullyCanonicalSig);
60
62 no_fully_canonical.app().getHashRouter(),
63 tx,
64 no_fully_canonical.current()->rules(),
65 no_fully_canonical.app().config())
66 .first;
67
69 fail("Non-Fully canoncial signature was not permitted");
70 }
71
72 {
73 test::jtx::Env fully_canonical(
75
77 fully_canonical.app().getHashRouter(),
78 tx,
79 fully_canonical.current()->rules(),
80 fully_canonical.app().config())
81 .first;
83 fail("Non-Fully canoncial signature was permitted");
84 }
85
86 pass();
87 }
88};
89
90BEAST_DEFINE_TESTSUITE(Apply, tx, ripple);
91
92} // namespace ripple
A testsuite class.
Definition suite.h:55
void pass()
Record a successful test condition.
Definition suite.h:511
testcase_t testcase
Memberspace for declaring test cases.
Definition suite.h:155
void fail(String const &reason, char const *file, int line)
Record a failure.
Definition suite.h:533
virtual Config & config()=0
virtual HashRouter & getHashRouter()=0
void testFullyCanonicalSigs()
void run() override
Runs the suite.
A transaction testing environment.
Definition Env.h:121
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition Env.h:331
Application & app()
Definition Env.h:261
T is_same_v
TER valid(STTx const &tx, ReadView const &view, AccountID const &src, beast::Journal j)
FeatureBitset testable_amendments()
Definition Env.h:74
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
std::optional< Blob > strUnHex(std::size_t strSize, Iterator begin, Iterator end)
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
Definition Slice.h:244
Validity
Describes the pre-processing validity of a transaction.
Definition apply.h:41
@ Valid
Signature and local checks are good / passed.
std::pair< Validity, std::string > checkValidity(HashRouter &router, STTx const &tx, Rules const &rules, Config const &config)
Checks transaction signature and local checks.
Definition apply.cpp:44
T ref(T... args)