PayChan and Escrow should ignore DisallowXRP (RIPD-1462)

This commit is contained in:
Scott Schurr
2017-10-02 18:33:22 -07:00
committed by Nikolaos D. Bougalis
parent 259394029a
commit cc0ce7163a
4 changed files with 79 additions and 25 deletions

View File

@@ -629,40 +629,57 @@ struct PayChan_test : public beast::unit_test::suite
testcase ("Disallow XRP");
using namespace jtx;
using namespace std::literals::chrono_literals;
auto const alice = Account ("alice");
auto const bob = Account ("bob");
{
// Create a channel where dst disallows XRP
Env env (*this);
auto const alice = Account ("alice");
auto const bob = Account ("bob");
Env env (*this, supported_amendments() - featureDepositAuth);
env.fund (XRP (10000), alice, bob);
env (fset (bob, asfDisallowXRP));
auto const pk = alice.pk ();
auto const settleDelay = 3600s;
auto const channelFunds = XRP (1000);
env (create (alice, bob, channelFunds, settleDelay, pk),
env (create (alice, bob, XRP (1000), 3600s, alice.pk()),
ter (tecNO_TARGET));
auto const chan = channel (*env.current (), alice, bob);
BEAST_EXPECT (!channelExists (*env.current (), chan));
}
{
// Create a channel where dst disallows XRP. Ignore that flag,
// since it's just advisory.
Env env (*this);
env.fund (XRP (10000), alice, bob);
env (fset (bob, asfDisallowXRP));
env (create (alice, bob, XRP (1000), 3600s, alice.pk()));
auto const chan = channel (*env.current (), alice, bob);
BEAST_EXPECT (channelExists (*env.current (), chan));
}
{
// Claim to a channel where dst disallows XRP
// (channel is created before disallow xrp is set)
Env env (*this);
auto const alice = Account ("alice");
auto const bob = Account ("bob");
Env env (*this, supported_amendments() - featureDepositAuth);
env.fund (XRP (10000), alice, bob);
auto const pk = alice.pk ();
auto const settleDelay = 3600s;
auto const channelFunds = XRP (1000);
env (create (alice, bob, channelFunds, settleDelay, pk));
env (create (alice, bob, XRP (1000), 3600s, alice.pk()));
auto const chan = channel (*env.current (), alice, bob);
BEAST_EXPECT (channelExists (*env.current (), chan));
env (fset (bob, asfDisallowXRP));
auto const preBob = env.balance (bob);
auto const reqBal = XRP (500).value();
env (claim (alice, chan, reqBal, reqBal), ter(tecNO_TARGET));
}
{
// Claim to a channel where dst disallows XRP (channel is
// created before disallow xrp is set). Ignore that flag
// since it is just advisory.
Env env (*this);
env.fund (XRP (10000), alice, bob);
env (create (alice, bob, XRP (1000), 3600s, alice.pk()));
auto const chan = channel (*env.current (), alice, bob);
BEAST_EXPECT (channelExists (*env.current (), chan));
env (fset (bob, asfDisallowXRP));
auto const reqBal = XRP (500).value();
env (claim (alice, chan, reqBal, reqBal));
}
}
void