Skip to content

Commit

Permalink
[fold] add pseudo txn
Browse files Browse the repository at this point in the history
  • Loading branch information
dangell7 committed Jan 11, 2025
1 parent 89ee58e commit 971c848
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/test/app/Batch_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2068,6 +2068,41 @@ class Batch_test : public beast::unit_test::suite
BEAST_EXPECT(env.balance(bob) == preBob + XRP(2));
}

void
testPseudoTxn(FeatureBitset features)
{
testcase("pseudo txn");

using namespace test::jtx;
using namespace std::literals;

test::jtx::Env env{*this, envconfig()};

auto const alice = Account("alice");
auto const bob = Account("bob");

env.fund(XRP(1000), alice, bob);
env.close();

STTx const stx = STTx(ttAMENDMENT, [&](auto& obj) {
obj.setAccountID(sfAccount, AccountID());
obj.setFieldH256(sfAmendment, uint256(2));
obj.setFieldU32(sfLedgerSequence, env.seq(alice));
obj.setFieldU32(sfFlags, tfInnerBatchTxn);
});

std::string reason;
BEAST_EXPECT(isPseudoTx(stx));
BEAST_EXPECT(!passesLocalChecks(stx, reason));
BEAST_EXPECT(reason == "Cannot submit pseudo transactions.");
env.app().openLedger().modify(
[&](OpenView& view, beast::Journal j) {
auto const result = ripple::apply(env.app(), view, stx, tapNONE, j);
BEAST_EXPECT(!result.second && result.first == temINVALID_FLAG);
return result.second;
});
}

void
testWithFeats(FeatureBitset features)
{
Expand Down Expand Up @@ -2097,6 +2132,7 @@ class Batch_test : public beast::unit_test::suite
testTicketsOuter(features);
testTicketsInner(features);
testTicketsOuterInner(features);
testPseudoTxn(features);
}

public:
Expand Down
10 changes: 10 additions & 0 deletions src/xrpld/app/tx/detail/Transactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ namespace ripple {
NotTEC
preflight0(PreflightContext const& ctx)
{
if (ctx.tx.isFlag(tfInnerBatchTxn) && !ctx.rules.enabled(featureBatch))
return temINVALID_FLAG;

if (isPseudoTx(ctx.tx) && ctx.tx.isFlag(tfInnerBatchTxn))
{
JLOG(ctx.j.warn()) << "Pseudo transactions cannot contain the "
"tfInnerBatchTxn flag.";
return temINVALID_FLAG;
}

if (!isPseudoTx(ctx.tx) || ctx.tx.isFieldPresent(sfNetworkID))
{
uint32_t nodeNID = ctx.app.config().NETWORK_ID;
Expand Down

0 comments on commit 971c848

Please sign in to comment.