Skip to content

Commit

Permalink
Add additional coverage tests (and excclusions) and fix a couple warn…
Browse files Browse the repository at this point in the history
…ings
  • Loading branch information
greg7mdp authored and seelabs committed Oct 25, 2022
1 parent 123c9a4 commit 69e910b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/ripple/app/tx/impl/XChainBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,15 +502,16 @@ BridgeCreate::preclaim(PreclaimContext const& ctx)
if (!isXRP(bridge.issuingChainIssue()) &&
!ctx.view.read(keylet::account(bridge.issuingChainIssue().account)))
{
return tecNO_ISSUER;
return tecNO_ISSUER; // LCOV_EXCL_LINE unreachable get
// temSIDECHAIN_NONDOOR_OWNER first
}
}

{
// Check reserve
auto const sle = ctx.view.read(keylet::account(account));
if (!sle)
return terNO_ACCOUNT;
return terNO_ACCOUNT; // LCOV_EXCL_LINE unreachable after preflight

auto const balance = (*sle)[sfBalance];
auto const reserve =
Expand Down Expand Up @@ -713,12 +714,14 @@ XChainClaim::preclaim(PreclaimContext const& ctx)
if (isLockingChain)
{
if (bridgeSpec.lockingChainIssue() != thisChainAmount.issue())
return tecBAD_XCHAIN_TRANSFER_ISSUE;
return tecBAD_XCHAIN_TRANSFER_ISSUE; // LCOV_EXCL_LINE -
// checked in preflight
}
else
{
if (bridgeSpec.issuingChainIssue() != thisChainAmount.issue())
return tecBAD_XCHAIN_TRANSFER_ISSUE;
return tecBAD_XCHAIN_TRANSFER_ISSUE; // LCOV_EXCL_LINE -
// checked in preflight
}
}

Expand Down
22 changes: 18 additions & 4 deletions src/test/app/XChain_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,13 @@ struct XChain_test : public beast::unit_test::suite,
.disableFeature(featureXChainBridge)
.close()
.tx(bridge_modify(mcDoor, jvb, XRP(1), XRP(2)), ter(temDISABLED));

// coverage test: bridge_modify return temSIDECHAIN_NONDOOR_OWNER;
XEnv(*this)
.tx(create_bridge(mcDoor, jvb))
.close()
.tx(bridge_modify(mcAlice, jvb, XRP(1), XRP(2)),
ter(temSIDECHAIN_NONDOOR_OWNER));
}

void
Expand Down Expand Up @@ -3138,9 +3145,6 @@ struct XChain_test : public beast::unit_test::suite,
XEnv mcEnv(*this);
XEnv scEnv(*this, true);

XRPAmount res0 = mcEnv.reserve(0);
XRPAmount tx_fee = mcEnv.txFee();

Account a{"a"};
Account doorA{"doorA"};

Expand Down Expand Up @@ -4297,6 +4301,13 @@ struct XChain_test : public beast::unit_test::suite,
.tx(xchain_claim(scAlice, jvb, 1, XRP(1000), scBob),
ter(temDISABLED))
.close();

// coverage test: XChainClaim::preclaim - isLockingChain = true;
XEnv(*this)
.tx(create_bridge(mcDoor, jvb))
.close()
.tx(xchain_claim(mcAlice, jvb, 1, XRP(1000), mcBob),
ter(tecXCHAIN_NO_CLAIM_ID));
}

void
Expand Down Expand Up @@ -5291,7 +5302,6 @@ struct XChainCoverage_test : public beast::unit_test::suite,
XEnv mcEnv(*this);
XEnv scEnv(*this, true);

XRPAmount res0 = mcEnv.reserve(0);
XRPAmount tx_fee = mcEnv.txFee();

Account a{"a"};
Expand Down Expand Up @@ -5387,6 +5397,10 @@ struct XChainCoverage_test : public beast::unit_test::suite,
// mcAlice, bridge(mcuAlice, mcAlice["USD"], mcBob,
// mcBob["USD"])),
// ter(terNO_ACCOUNT));

// coverage test: BridgeCreate::preclaim() returns tecNO_ISSUER.

// coverage test: transferHelper() - dst == src
}

void
Expand Down

0 comments on commit 69e910b

Please sign in to comment.