Merge branch 'develop' into ximinez/lending-number-simple

This commit is contained in:
Ed Hennis
2025-11-15 03:13:10 -05:00
committed by GitHub
11 changed files with 79 additions and 133 deletions

View File

@@ -1703,7 +1703,6 @@ class Delegate_test : public beast::unit_test::suite
// NFTokenMint, NFTokenBurn, NFTokenCreateOffer, NFTokenCancelOffer,
// NFTokenAcceptOffer are not included, they are tested separately.
std::unordered_map<std::string, uint256> txRequiredFeatures{
{"TicketCreate", featureTicketBatch},
{"CheckCreate", featureChecks},
{"CheckCash", featureChecks},
{"CheckCancel", featureChecks},

View File

@@ -360,52 +360,6 @@ class Ticket_test : public beast::unit_test::suite
BEAST_EXPECT(ticketSeq < acctRootSeq);
}
void
testTicketNotEnabled()
{
testcase("Feature Not Enabled");
using namespace test::jtx;
Env env{*this, testable_amendments() - featureTicketBatch};
env(ticket::create(env.master, 1), ter(temDISABLED));
env.close();
env.require(owners(env.master, 0), tickets(env.master, 0));
env(noop(env.master), ticket::use(1), ter(temMALFORMED));
env(noop(env.master),
ticket::use(1),
seq(env.seq(env.master)),
ter(temMALFORMED));
// Close enough ledgers that the previous transactions are no
// longer retried.
for (int i = 0; i < 8; ++i)
env.close();
env.enableFeature(featureTicketBatch);
env.close();
env.require(owners(env.master, 0), tickets(env.master, 0));
std::uint32_t ticketSeq{env.seq(env.master) + 1};
env(ticket::create(env.master, 2));
checkTicketCreateMeta(env);
env.close();
env.require(owners(env.master, 2), tickets(env.master, 2));
env(noop(env.master), ticket::use(ticketSeq++));
checkTicketConsumeMeta(env);
env.close();
env.require(owners(env.master, 1), tickets(env.master, 1));
env(fset(env.master, asfDisableMaster),
ticket::use(ticketSeq++),
ter(tecNO_ALTERNATIVE_KEY));
checkTicketConsumeMeta(env);
env.close();
env.require(owners(env.master, 0), tickets(env.master, 0));
}
void
testTicketCreatePreflightFail()
{
@@ -907,70 +861,43 @@ class Ticket_test : public beast::unit_test::suite
void
testFixBothSeqAndTicket()
{
using namespace test::jtx;
// It is an error if a transaction contains a non-zero Sequence field
// and a TicketSequence field. Verify that the error is detected.
testcase("Fix both Seq and Ticket");
// Try the test without featureTicketBatch enabled.
using namespace test::jtx;
{
Env env{*this, testable_amendments() - featureTicketBatch};
Account alice{"alice"};
Env env{*this, testable_amendments()};
Account alice{"alice"};
env.fund(XRP(10000), alice);
env.close();
env.fund(XRP(10000), alice);
env.close();
// Fail to create a ticket.
std::uint32_t const ticketSeq = env.seq(alice) + 1;
env(ticket::create(alice, 1), ter(temDISABLED));
env.close();
env.require(owners(alice, 0), tickets(alice, 0));
BEAST_EXPECT(ticketSeq == env.seq(alice) + 1);
// Create a ticket.
std::uint32_t const ticketSeq = env.seq(alice) + 1;
env(ticket::create(alice, 1));
env.close();
env.require(owners(alice, 1), tickets(alice, 1));
BEAST_EXPECT(ticketSeq + 1 == env.seq(alice));
// Create a transaction that includes both a ticket and a non-zero
// sequence number. Since a ticket is used and tickets are not yet
// enabled the transaction should be malformed.
env(noop(alice),
ticket::use(ticketSeq),
seq(env.seq(alice)),
ter(temMALFORMED));
env.close();
}
// Try the test with featureTicketBatch enabled.
{
Env env{*this, testable_amendments()};
Account alice{"alice"};
// Create a transaction that includes both a ticket and a non-zero
// sequence number. The transaction fails with temSEQ_AND_TICKET.
env(noop(alice),
ticket::use(ticketSeq),
seq(env.seq(alice)),
ter(temSEQ_AND_TICKET));
env.close();
env.fund(XRP(10000), alice);
env.close();
// Create a ticket.
std::uint32_t const ticketSeq = env.seq(alice) + 1;
env(ticket::create(alice, 1));
env.close();
env.require(owners(alice, 1), tickets(alice, 1));
BEAST_EXPECT(ticketSeq + 1 == env.seq(alice));
// Create a transaction that includes both a ticket and a non-zero
// sequence number. The transaction fails with temSEQ_AND_TICKET.
env(noop(alice),
ticket::use(ticketSeq),
seq(env.seq(alice)),
ter(temSEQ_AND_TICKET));
env.close();
// Verify that the transaction failed by looking at alice's
// sequence number and tickets.
env.require(owners(alice, 1), tickets(alice, 1));
BEAST_EXPECT(ticketSeq + 1 == env.seq(alice));
}
// Verify that the transaction failed by looking at alice's
// sequence number and tickets.
env.require(owners(alice, 1), tickets(alice, 1));
BEAST_EXPECT(ticketSeq + 1 == env.seq(alice));
}
public:
void
run() override
{
testTicketNotEnabled();
testTicketCreatePreflightFail();
testTicketCreatePreclaimFail();
testTicketInsufficientReserve();

View File

@@ -1329,7 +1329,7 @@ class Vault_test : public beast::unit_test::suite
Vault& vault) {
auto [tx, keylet] = vault.create({.owner = owner, .asset = asset});
testcase("insufficient fee");
env(tx, fee(env.current()->fees().base), ter(telINSUF_FEE_P));
env(tx, fee(env.current()->fees().base - 1), ter(telINSUF_FEE_P));
});
testCase([this](
@@ -2074,6 +2074,10 @@ class Vault_test : public beast::unit_test::suite
auto const sleMPT = env.le(mptoken);
BEAST_EXPECT(sleMPT == nullptr);
// Use one reserve so the next transaction fails
env(ticket::create(owner, 1));
env.close();
// No reserve to create MPToken for asset in VaultWithdraw
tx = vault.withdraw(
{.depositor = owner,
@@ -2091,7 +2095,7 @@ class Vault_test : public beast::unit_test::suite
}
},
{.requireAuth = false,
.initialXRP = acctReserve + incReserve * 4 - 1});
.initialXRP = acctReserve + incReserve * 4 + 1});
testCase([this](
Env& env,
@@ -2980,6 +2984,9 @@ class Vault_test : public beast::unit_test::suite
env.le(keylet::line(owner, asset.raw().get<Issue>()));
BEAST_EXPECT(trustline == nullptr);
env(ticket::create(owner, 1));
env.close();
// Fail because not enough reserve to create trust line
tx = vault.withdraw(
{.depositor = owner,
@@ -2995,7 +3002,7 @@ class Vault_test : public beast::unit_test::suite
env(tx);
env.close();
},
CaseArgs{.initialXRP = acctReserve + incReserve * 4 - 1});
CaseArgs{.initialXRP = acctReserve + incReserve * 4 + 1});
testCase(
[&, this](
@@ -3016,8 +3023,7 @@ class Vault_test : public beast::unit_test::suite
env(pay(owner, charlie, asset(100)));
env.close();
// Use up some reserve on tickets
env(ticket::create(charlie, 2));
env(ticket::create(charlie, 3));
env.close();
// Fail because not enough reserve to create MPToken for shares
@@ -3035,7 +3041,7 @@ class Vault_test : public beast::unit_test::suite
env(tx);
env.close();
},
CaseArgs{.initialXRP = acctReserve + incReserve * 4 - 1});
CaseArgs{.initialXRP = acctReserve + incReserve * 4 + 1});
testCase([&, this](
Env& env,

View File

@@ -19,7 +19,6 @@ Vault::create(CreateArgs const& args)
jv[jss::TransactionType] = jss::VaultCreate;
jv[jss::Account] = args.owner.human();
jv[jss::Asset] = to_json(args.asset);
jv[jss::Fee] = STAmount(env.current()->fees().increment).getJson();
if (args.flags)
jv[jss::Flags] = *args.flags;
return {jv, keylet};