Fix the behavior of co-sign + pre-fund

This commit is contained in:
tequ
2025-10-28 17:18:38 +09:00
parent 4fe7e87b4f
commit d0bcca6bf1
25 changed files with 143 additions and 79 deletions

View File

@@ -26,6 +26,8 @@
#include <xrpl/basics/strHex.h>
#include <xrpl/protocol/Feature.h>
#include "test/jtx/txflags.h"
namespace ripple {
namespace test {
@@ -426,6 +428,67 @@ public:
}
}
void
testPreFundAndCosign()
{
testcase("PreFund and Cosign");
using namespace test::jtx;
Account const alice("alice");
Account const sponsor("sponsor");
{
// both pre-funded and co-signed,pre-funded value is used
Env env{*this, testable_amendments()};
env.fund(XRP(10000), alice, sponsor);
env.close();
env(sponsor::set(sponsor, 0, 100, XRP(100), XRP(1)),
sponsor::sponseeAcc(alice),
ter(tesSUCCESS));
env.close();
env(ticket::create(alice, 1),
sponsor::as(sponsor, tfSponsorReserve | tfSponsorFee),
sig(sfSponsorSignature, sponsor),
fee(XRP(1)),
ter(tesSUCCESS));
env.close();
auto const sle = env.le(keylet::sponsor(sponsor, alice));
BEAST_EXPECT(sle);
BEAST_EXPECT(sle->at(sfReserveCount) == 99);
BEAST_EXPECT(sle->at(sfFeeAmount) == XRP(99));
}
{
// if pre-funded value is not enough, error
Env env{*this, testable_amendments()};
env.fund(XRP(10000), alice, sponsor);
env.close();
env(sponsor::set(sponsor, 0, 10, XRP(10), XRP(100)),
sponsor::sponseeAcc(alice),
ter(tesSUCCESS));
env.close();
// fee insufficient
env(ticket::create(alice, 1),
sponsor::as(sponsor, tfSponsorReserve | tfSponsorFee),
sig(sfSponsorSignature, sponsor),
fee(XRP(11)),
ter(terINSUF_FEE_B));
env.close();
// reserve insufficient
env(ticket::create(alice, 11),
sponsor::as(sponsor, tfSponsorReserve | tfSponsorFee),
sig(sfSponsorSignature, sponsor),
fee(XRP(1)),
ter(tecINSUFFICIENT_RESERVE));
env.close();
}
}
void
testTransferSponsor()
{
@@ -4260,6 +4323,8 @@ public:
testSimpleSponsorshipSet();
testPreFundAndCosign();
testTransferSponsor();
testSponsorFee();
testSponsorAccount();