mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
refactor: Restructure Transactor::preflight to reduce boilerplate (#5592)
* Restructures `Transactor::preflight` to create several functions that will remove the need for error-prone boilerplate code in derived classes' implementations of `preflight`.
This commit is contained in:
@@ -3572,7 +3572,7 @@ private:
|
||||
env.current()->rules(),
|
||||
tapNONE,
|
||||
env.journal);
|
||||
auto pf = AMMBid::preflight(pfctx);
|
||||
auto pf = Transactor::invokePreflight<AMMBid>(pfctx);
|
||||
BEAST_EXPECT(pf == temDISABLED);
|
||||
env.app().config().features.insert(featureAMM);
|
||||
}
|
||||
@@ -3587,7 +3587,7 @@ private:
|
||||
env.current()->rules(),
|
||||
tapNONE,
|
||||
env.journal);
|
||||
auto pf = AMMBid::preflight(pfctx);
|
||||
auto pf = Transactor::invokePreflight<AMMBid>(pfctx);
|
||||
BEAST_EXPECT(pf != tesSUCCESS);
|
||||
}
|
||||
|
||||
@@ -3602,7 +3602,7 @@ private:
|
||||
env.current()->rules(),
|
||||
tapNONE,
|
||||
env.journal);
|
||||
auto pf = AMMBid::preflight(pfctx);
|
||||
auto pf = Transactor::invokePreflight<AMMBid>(pfctx);
|
||||
BEAST_EXPECT(pf == temBAD_AMM_TOKENS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <test/jtx.h>
|
||||
|
||||
#include <xrpld/app/tx/apply.h>
|
||||
|
||||
#include <xrpl/protocol/AmountConversions.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Quality.h>
|
||||
@@ -578,6 +580,32 @@ public:
|
||||
env.close();
|
||||
}
|
||||
|
||||
void
|
||||
testBadSigningKey()
|
||||
{
|
||||
using namespace test::jtx;
|
||||
testcase("Bad signing key");
|
||||
Env env(*this);
|
||||
Account const alice("alice");
|
||||
|
||||
env.fund(XRP(10000), alice);
|
||||
env.close();
|
||||
|
||||
auto jtx = env.jt(noop("alice"), ter(temBAD_SIGNATURE));
|
||||
if (!BEAST_EXPECT(jtx.stx))
|
||||
return;
|
||||
auto stx = std::make_shared<STTx>(*jtx.stx);
|
||||
stx->at(sfSigningPubKey) = makeSlice(std::string("badkey"));
|
||||
|
||||
env.app().openLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
auto const result =
|
||||
ripple::apply(env.app(), view, *stx, tapNONE, j);
|
||||
BEAST_EXPECT(result.ter == temBAD_SIGNATURE);
|
||||
BEAST_EXPECT(!result.applied);
|
||||
return result.applied;
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
run() override
|
||||
{
|
||||
@@ -594,6 +622,7 @@ public:
|
||||
testRequireAuthWithDir();
|
||||
testTransferRate();
|
||||
testTicket();
|
||||
testBadSigningKey();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user