mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-04 17:27:00 +00:00
add tests for sponsor field
This commit is contained in:
@@ -276,6 +276,41 @@ public:
|
||||
ter(tesSUCCESS));
|
||||
}
|
||||
|
||||
void
|
||||
testInvalidSponsorField()
|
||||
{
|
||||
testcase("Invalid Sponsor Field");
|
||||
using namespace test::jtx;
|
||||
Env env{*this, testable_amendments()};
|
||||
Account const alice("alice");
|
||||
Account const sponsor("sponsor");
|
||||
Account const noFunded("noFunded");
|
||||
env.fund(XRP(10000), alice, sponsor);
|
||||
env.close();
|
||||
|
||||
// Invalid Sponsor Account (Account = Sponsor.Account)
|
||||
env(noop(alice), sponsor::as(alice), ter(temMALFORMED));
|
||||
|
||||
// Invalid Sponsor Account
|
||||
// (SponsorSignature is specified but Sponsor.Account is not specified)
|
||||
env(noop(alice), sig(sfSponsorSignature, sponsor), ter(temMALFORMED));
|
||||
|
||||
// Invalid Sponsor Account (Sponsor.Account doesn't exist)
|
||||
env(noop(alice),
|
||||
sponsor::as(noFunded, tfSponsorReserve),
|
||||
ter(terNO_SPONSORSHIP));
|
||||
env(noop(alice),
|
||||
sponsor::as(noFunded, tfSponsorReserve),
|
||||
sig(sfSponsorSignature, noFunded),
|
||||
ter(terNO_ACCOUNT));
|
||||
|
||||
// Invalid Flags
|
||||
env(noop(alice), sponsor::as(sponsor, 4), ter(temINVALID_FLAG));
|
||||
env(noop(alice),
|
||||
sponsor::as(sponsor, ~tfSponsorMask),
|
||||
ter(temINVALID_FLAG));
|
||||
}
|
||||
|
||||
void
|
||||
testSimpleSponsorshipSet()
|
||||
{
|
||||
@@ -4513,6 +4548,8 @@ public:
|
||||
testSingleSigning();
|
||||
testMultiSigning();
|
||||
|
||||
testInvalidSponsorField();
|
||||
|
||||
testSimpleSponsorshipSet();
|
||||
|
||||
testPreFundAndCosign();
|
||||
|
||||
@@ -211,13 +211,13 @@ Transactor::preflight1(PreflightContext const& ctx, std::uint32_t flagMask)
|
||||
auto const sponsor = ctx.tx.getFieldObject(sfSponsor);
|
||||
if (sponsor[sfAccount] == ctx.tx[sfAccount])
|
||||
{
|
||||
JLOG(ctx.j.fatal()) << "preflight1: invalid sponsor account";
|
||||
JLOG(ctx.j.debug()) << "preflight1: invalid sponsor account";
|
||||
return temMALFORMED;
|
||||
}
|
||||
if (!(sponsor.getFlags() & tfSponsorMask))
|
||||
{
|
||||
JLOG(ctx.j.fatal()) << "preflight1: invalid sponsor flags";
|
||||
return temMALFORMED;
|
||||
JLOG(ctx.j.debug()) << "preflight1: invalid sponsor flags";
|
||||
return temINVALID_FLAG;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user