Skip to content

Commit

Permalink
Update Import Tests (XRPLF#99)
Browse files Browse the repository at this point in the history
* add fee multiplier

* add warn logs

* add unl sequence json

* add import sequence tests

* Update TER.cpp

* remove issuer xpop

* Update Import_test.cpp

* update max xpop

* update/add max & fee change tests

* fixup issuer/hook test
  • Loading branch information
dangell7 authored Sep 19, 2023
1 parent 89df87d commit debf178
Show file tree
Hide file tree
Showing 4 changed files with 1,164 additions and 772 deletions.
17 changes: 12 additions & 5 deletions src/ripple/app/tx/impl/Import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ Import::preflight(PreflightContext const& ctx)

auto& tx = ctx.tx;


if (tx.getFieldVL(sfBlob).size() > (512 * 1024))
{
JLOG(ctx.j.warn())
Expand Down Expand Up @@ -869,12 +868,19 @@ Import::preclaim(PreclaimContext const& ctx)
auto const vlInfo = getVLInfo(*xpop, ctx.j);

if (!vlInfo)
{
JLOG(ctx.j.warn())
<< "Import: during preclaim could not parse vlInfo, bailing.";
return tefINTERNAL;
}

auto const& sleVL = ctx.view.read(keylet::import_vlseq(vlInfo->second));

if (sleVL && sleVL->getFieldU32(sfImportSequence) > vlInfo->first)
{
JLOG(ctx.j.warn())
<< "Import: import vl sequence already used, bailing.";
return tefPAST_IMPORT_VL_SEQ;
}

// check master VL key
std::string strPk = (*xpop)[jss::validation][jss::unl][jss::public_key].asString();
Expand All @@ -883,7 +889,6 @@ Import::preclaim(PreclaimContext const& ctx)
found != ctx.app.config().IMPORT_VL_KEYS.end())
return tesSUCCESS;

// not found in our local VL keys
auto pkHex = strUnHex(strPk);
if (!pkHex)
return tefINTERNAL;
Expand All @@ -903,6 +908,8 @@ Import::preclaim(PreclaimContext const& ctx)
return tesSUCCESS;
}

JLOG(ctx.j.warn())
<< "Import: import vl key not recognized, bailing.";
return telIMPORT_VL_KEY_NOT_RECOGNISED;
}

Expand Down Expand Up @@ -1091,7 +1098,7 @@ Import::doApply()

auto const keyletVL = keylet::import_vlseq(infoVL->second);
auto sleVL = view().peek(keyletVL);

if (!sleVL)
{
// create VL import seq counter
Expand Down Expand Up @@ -1231,7 +1238,7 @@ Import::doApply()
sle->setFieldU64(sfAccountIndex, accIdx);
sleFees->setFieldU64(sfAccountCount, accIdx + 1);
}

if (ctx_.tx.getSigningPubKey().empty() ||
calcAccountID(PublicKey(makeSlice(ctx_.tx.getSigningPubKey()))) != id)
{
Expand Down
1 change: 1 addition & 0 deletions src/ripple/protocol/impl/TER.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ transResults()
MAKE_ERROR(tefNOT_MULTI_SIGNING, "Account has no appropriate list of multi-signers."),
MAKE_ERROR(tefPAST_SEQ, "This sequence number has already passed."),
MAKE_ERROR(tefPAST_IMPORT_SEQ, "This import sequence number has already been used."),
MAKE_ERROR(tefPAST_IMPORT_VL_SEQ, "This import validator list sequence number has already been used."),
MAKE_ERROR(tefWRONG_PRIOR, "This previous transaction does not match."),
MAKE_ERROR(tefBAD_AUTH_MASTER, "Auth for unclaimed account needs correct master key."),
MAKE_ERROR(tefINVARIANT_FAILED, "Fee claim violated invariants for the transaction."),
Expand Down
Loading

0 comments on commit debf178

Please sign in to comment.