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#include <xrpld/app/tx/apply.h>
22#include <xrpl/basics/StringUtilities.h>
23#include <xrpl/protocol/Feature.h>
24
25namespace ripple {
26
28{
29public:
30 void
31 run() override
32 {
33 testcase("Require Fully Canonicial Signature");
35 }
36
37 void
39 {
40 // Construct a payments w/out a fully-canonical tx
41 const std::string non_fully_canonical_tx =
42 "12000022000000002400000001201B00497D9C6140000000000F6950684000000"
43 "00000000C732103767C7B2C13AD90050A4263745E4BAB2B975417FA22E87780E1"
44 "506DDAF21139BE74483046022100E95670988A34C4DB0FA73A8BFD6383872AF43"
45 "8C147A62BC8387406298C3EADC1022100A7DC80508ED5A4750705C702A81CBF9D"
46 "2C2DC3AFEDBED37BBCCD97BC8C40E08F8114E25A26437D923EEF4D6D815DF9336"
47 "8B62E6440848314BB85996936E4F595287774684DC2AC6266024BEF";
48
49 auto ret = strUnHex(non_fully_canonical_tx);
50 SerialIter sitTrans(makeSlice(*ret));
51 STTx const tx = *std::make_shared<STTx const>(std::ref(sitTrans));
52
53 {
54 test::jtx::Env no_fully_canonical(
55 *this,
57 featureRequireFullyCanonicalSig);
58
60 no_fully_canonical.app().getHashRouter(),
61 tx,
62 no_fully_canonical.current()->rules(),
63 no_fully_canonical.app().config())
64 .first;
65
67 fail("Non-Fully canoncial signature was not permitted");
68 }
69
70 {
71 test::jtx::Env fully_canonical(
73
75 fully_canonical.app().getHashRouter(),
76 tx,
77 fully_canonical.current()->rules(),
78 fully_canonical.app().config())
79 .first;
81 fail("Non-Fully canoncial signature was permitted");
82 }
83
84 pass();
85 }
86};
87
88BEAST_DEFINE_TESTSUITE(Apply, app, ripple);
89
90} // namespace ripple
A testsuite class.
Definition: suite.h:53
void pass()
Record a successful test condition.
Definition: suite.h:509
testcase_t testcase
Memberspace for declaring test cases.
Definition: suite.h:153
void fail(String const &reason, char const *file, int line)
Record a failure.
Definition: suite.h:531
virtual Config & config()=0
virtual HashRouter & getHashRouter()=0
void testFullyCanonicalSigs()
Definition: apply_test.cpp:38
void run() override
Runs the suite.
Definition: apply_test.cpp:31
A transaction testing environment.
Definition: Env.h:117
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition: Env.h:325
Application & app()
Definition: Env.h:255
TER valid(PreclaimContext const &ctx, AccountID const &src)
FeatureBitset supported_amendments()
Definition: Env.h:70
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
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:243
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:37
T ref(T... args)