mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Better error codes for payment channel claim (RIPD-1512)
This commit is contained in:
@@ -175,7 +175,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
testcase ("simple");
|
||||
using namespace jtx;
|
||||
using namespace std::literals::chrono_literals;
|
||||
Env env (*this, with_features (featurePayChan));
|
||||
Env env (*this);
|
||||
auto const alice = Account ("alice");
|
||||
auto const bob = Account ("bob");
|
||||
auto USDA = alice["USD"];
|
||||
@@ -242,7 +242,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
auto const reqBal = chanBal + delta;
|
||||
auto const authAmt = reqBal + XRP (-100);
|
||||
assert (reqBal <= chanAmt);
|
||||
env (claim (alice, chan, reqBal, authAmt), ter (tecNO_PERMISSION));
|
||||
env (claim (alice, chan, reqBal, authAmt), ter (temBAD_AMOUNT));
|
||||
}
|
||||
{
|
||||
// No signature needed since the owner is claiming
|
||||
@@ -290,11 +290,10 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
auto const sig =
|
||||
signClaimAuth (alice.pk (), alice.sk (), chan, authAmt);
|
||||
env (claim (bob, chan, reqAmt, authAmt, Slice (sig), alice.pk ()),
|
||||
ter (tecNO_PERMISSION));
|
||||
ter (temBAD_AMOUNT));
|
||||
BEAST_EXPECT (channelBalance (*env.current (), chan) == chanBal);
|
||||
BEAST_EXPECT (channelAmount (*env.current (), chan) == chanAmt);
|
||||
auto const feeDrops = env.current ()->fees ().base;
|
||||
BEAST_EXPECT (env.balance (bob) == preBob - feeDrops);
|
||||
BEAST_EXPECT (env.balance (bob) == preBob);
|
||||
}
|
||||
|
||||
// Dst tries to fund the channel
|
||||
@@ -347,7 +346,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
auto const carol = Account ("carol");
|
||||
{
|
||||
// If dst claims after cancel after, channel closes
|
||||
Env env (*this, with_features (featurePayChan));
|
||||
Env env (*this);
|
||||
env.fund (XRP (10000), alice, bob);
|
||||
auto const pk = alice.pk ();
|
||||
auto const settleDelay = 100s;
|
||||
@@ -386,7 +385,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
}
|
||||
{
|
||||
// Third party can close after cancel after
|
||||
Env env (*this, with_features (featurePayChan));
|
||||
Env env (*this);
|
||||
env.fund (XRP (10000), alice, bob, carol);
|
||||
auto const pk = alice.pk ();
|
||||
auto const settleDelay = 100s;
|
||||
@@ -416,7 +415,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
testcase ("expiration");
|
||||
using namespace jtx;
|
||||
using namespace std::literals::chrono_literals;
|
||||
Env env (*this, with_features (featurePayChan));
|
||||
Env env (*this);
|
||||
auto const alice = Account ("alice");
|
||||
auto const bob = Account ("bob");
|
||||
auto const carol = Account ("carol");
|
||||
@@ -477,7 +476,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
testcase ("settle delay");
|
||||
using namespace jtx;
|
||||
using namespace std::literals::chrono_literals;
|
||||
Env env (*this, with_features (featurePayChan));
|
||||
Env env (*this);
|
||||
auto const alice = Account ("alice");
|
||||
auto const bob = Account ("bob");
|
||||
env.fund (XRP (10000), alice, bob);
|
||||
@@ -537,7 +536,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
testcase ("close dry");
|
||||
using namespace jtx;
|
||||
using namespace std::literals::chrono_literals;
|
||||
Env env (*this, with_features (featurePayChan));
|
||||
Env env (*this);
|
||||
auto const alice = Account ("alice");
|
||||
auto const bob = Account ("bob");
|
||||
env.fund (XRP (10000), alice, bob);
|
||||
@@ -573,7 +572,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
testcase ("default amount");
|
||||
using namespace jtx;
|
||||
using namespace std::literals::chrono_literals;
|
||||
Env env (*this, with_features (featurePayChan));
|
||||
Env env (*this);
|
||||
auto const alice = Account ("alice");
|
||||
auto const bob = Account ("bob");
|
||||
env.fund (XRP (10000), alice, bob);
|
||||
@@ -632,7 +631,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
using namespace std::literals::chrono_literals;
|
||||
{
|
||||
// Create a channel where dst disallows XRP
|
||||
Env env (*this, with_features (featurePayChan));
|
||||
Env env (*this);
|
||||
auto const alice = Account ("alice");
|
||||
auto const bob = Account ("bob");
|
||||
env.fund (XRP (10000), alice, bob);
|
||||
@@ -648,7 +647,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
{
|
||||
// Claim to a channel where dst disallows XRP
|
||||
// (channel is created before disallow xrp is set)
|
||||
Env env (*this, with_features (featurePayChan));
|
||||
Env env (*this);
|
||||
auto const alice = Account ("alice");
|
||||
auto const bob = Account ("bob");
|
||||
env.fund (XRP (10000), alice, bob);
|
||||
@@ -674,7 +673,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
using namespace jtx;
|
||||
using namespace std::literals::chrono_literals;
|
||||
// Create a channel where dst disallows XRP
|
||||
Env env (*this, with_features (featurePayChan));
|
||||
Env env (*this);
|
||||
auto const alice = Account ("alice");
|
||||
auto const bob = Account ("bob");
|
||||
env.fund (XRP (10000), alice, bob);
|
||||
@@ -699,7 +698,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
testcase ("Multiple channels to the same account");
|
||||
using namespace jtx;
|
||||
using namespace std::literals::chrono_literals;
|
||||
Env env (*this, with_features (featurePayChan));
|
||||
Env env (*this);
|
||||
auto const alice = Account ("alice");
|
||||
auto const bob = Account ("bob");
|
||||
env.fund (XRP (10000), alice, bob);
|
||||
@@ -721,7 +720,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
testcase ("RPC");
|
||||
using namespace jtx;
|
||||
using namespace std::literals::chrono_literals;
|
||||
Env env (*this, with_features (featurePayChan));
|
||||
Env env (*this);
|
||||
auto const alice = Account ("alice");
|
||||
auto const bob = Account ("bob");
|
||||
env.fund (XRP (10000), alice, bob);
|
||||
@@ -791,7 +790,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
testcase ("Optional Fields");
|
||||
using namespace jtx;
|
||||
using namespace std::literals::chrono_literals;
|
||||
Env env (*this, with_features (featurePayChan));
|
||||
Env env (*this);
|
||||
auto const alice = Account ("alice");
|
||||
auto const bob = Account ("bob");
|
||||
auto const carol = Account ("carol");
|
||||
@@ -831,7 +830,7 @@ struct PayChan_test : public beast::unit_test::suite
|
||||
testcase ("malformed pk");
|
||||
using namespace jtx;
|
||||
using namespace std::literals::chrono_literals;
|
||||
Env env (*this, with_features (featurePayChan));
|
||||
Env env (*this);
|
||||
auto const alice = Account ("alice");
|
||||
auto const bob = Account ("bob");
|
||||
auto USDA = alice["USD"];
|
||||
|
||||
Reference in New Issue
Block a user