mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Maintenance of Offer and PayStrand unit tests
This commit is contained in:
committed by
manojsdoshi
parent
09ae9168ca
commit
22cc9a254a
@@ -2367,389 +2367,50 @@ public:
|
||||
int owners; // Owners on account
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
TestData const tests[]{
|
||||
// acct fundXrp bookAmt preTrust
|
||||
// offerAmt tec spentXrp balanceUSD
|
||||
// offers owners
|
||||
{"ann",
|
||||
reserve(env, 0) + 0 * f,
|
||||
1,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tecUNFUNDED_OFFER,
|
||||
f,
|
||||
USD(0),
|
||||
0,
|
||||
0}, // Account is at the reserve, and will dip below once fees are
|
||||
// subtracted.
|
||||
{"bev",
|
||||
reserve(env, 0) + 1 * f,
|
||||
1,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tecUNFUNDED_OFFER,
|
||||
f,
|
||||
USD(0),
|
||||
0,
|
||||
0}, // Account has just enough for the reserve and the fee.
|
||||
{"cam",
|
||||
reserve(env, 0) + 2 * f,
|
||||
0,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tecINSUF_RESERVE_OFFER,
|
||||
f,
|
||||
USD(0),
|
||||
0,
|
||||
0}, // Account has enough for the reserve, the fee and the offer,
|
||||
// and a bit more, but not enough for the reserve after the
|
||||
// offer is placed.
|
||||
{"deb",
|
||||
reserve(env, 0) + 2 * f,
|
||||
1,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
2 * f,
|
||||
USD(0.00001),
|
||||
0,
|
||||
1}, // Account has enough to buy a little USD then the offer runs
|
||||
// dry.
|
||||
{"eve",
|
||||
reserve(env, 1) + 0 * f,
|
||||
0,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
f,
|
||||
USD(0),
|
||||
1,
|
||||
1}, // No offer to cross
|
||||
{"flo",
|
||||
reserve(env, 1) + 0 * f,
|
||||
1,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(1) + f,
|
||||
USD(1),
|
||||
0,
|
||||
1},
|
||||
{"gay",
|
||||
reserve(env, 1) + 1 * f,
|
||||
1000,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(50) + f,
|
||||
USD(50),
|
||||
0,
|
||||
1},
|
||||
{"hye",
|
||||
XRP(1000) + 1 * f,
|
||||
1000,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(800) + f,
|
||||
USD(800),
|
||||
0,
|
||||
1},
|
||||
{"ivy",
|
||||
XRP(1) + reserve(env, 1) + 1 * f,
|
||||
1,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(1) + f,
|
||||
USD(1),
|
||||
0,
|
||||
1},
|
||||
{"joy",
|
||||
XRP(1) + reserve(env, 2) + 1 * f,
|
||||
1,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(1) + f,
|
||||
USD(1),
|
||||
1,
|
||||
2},
|
||||
{"kim",
|
||||
XRP(900) + reserve(env, 2) + 1 * f,
|
||||
999,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(999) + f,
|
||||
USD(999),
|
||||
0,
|
||||
1},
|
||||
{"liz",
|
||||
XRP(998) + reserve(env, 0) + 1 * f,
|
||||
999,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(998) + f,
|
||||
USD(998),
|
||||
0,
|
||||
1},
|
||||
{"meg",
|
||||
XRP(998) + reserve(env, 1) + 1 * f,
|
||||
999,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(999) + f,
|
||||
USD(999),
|
||||
0,
|
||||
1},
|
||||
{"nia",
|
||||
XRP(998) + reserve(env, 2) + 1 * f,
|
||||
999,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(999) + f,
|
||||
USD(999),
|
||||
1,
|
||||
2},
|
||||
{"ova",
|
||||
XRP(999) + reserve(env, 0) + 1 * f,
|
||||
1000,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(999) + f,
|
||||
USD(999),
|
||||
0,
|
||||
1},
|
||||
{"pam",
|
||||
XRP(999) + reserve(env, 1) + 1 * f,
|
||||
1000,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(1000) + f,
|
||||
USD(1000),
|
||||
0,
|
||||
1},
|
||||
{"rae",
|
||||
XRP(999) + reserve(env, 2) + 1 * f,
|
||||
1000,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(1000) + f,
|
||||
USD(1000),
|
||||
0,
|
||||
1},
|
||||
{"sue",
|
||||
XRP(1000) + reserve(env, 2) + 1 * f,
|
||||
0,
|
||||
noPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
f,
|
||||
USD(0),
|
||||
1,
|
||||
1},
|
||||
// acct fundXrp bookAmt preTrust offerAmt tec spentXrp balanceUSD offers owners
|
||||
{"ann", reserve(env, 0) + 0 * f, 1, noPreTrust, 1000, tecUNFUNDED_OFFER, f, USD( 0), 0, 0}, // Account is at the reserve, and will dip below once fees are subtracted.
|
||||
{"bev", reserve(env, 0) + 1 * f, 1, noPreTrust, 1000, tecUNFUNDED_OFFER, f, USD( 0), 0, 0}, // Account has just enough for the reserve and the fee.
|
||||
{"cam", reserve(env, 0) + 2 * f, 0, noPreTrust, 1000, tecINSUF_RESERVE_OFFER, f, USD( 0), 0, 0}, // Account has enough for the reserve, the fee and the offer, and a bit more, but not enough for the reserve after the offer is placed.
|
||||
{"deb", reserve(env, 0) + 2 * f, 1, noPreTrust, 1000, tesSUCCESS, 2 * f, USD(0.00001), 0, 1}, // Account has enough to buy a little USD then the offer runs dry.
|
||||
{"eve", reserve(env, 1) + 0 * f, 0, noPreTrust, 1000, tesSUCCESS, f, USD( 0), 1, 1}, // No offer to cross
|
||||
{"flo", reserve(env, 1) + 0 * f, 1, noPreTrust, 1000, tesSUCCESS, XRP( 1) + f, USD( 1), 0, 1},
|
||||
{"gay", reserve(env, 1) + 1 * f, 1000, noPreTrust, 1000, tesSUCCESS, XRP( 50) + f, USD( 50), 0, 1},
|
||||
{"hye", XRP(1000) + 1 * f, 1000, noPreTrust, 1000, tesSUCCESS, XRP( 800) + f, USD( 800), 0, 1},
|
||||
{"ivy", XRP( 1) + reserve(env, 1) + 1 * f, 1, noPreTrust, 1000, tesSUCCESS, XRP( 1) + f, USD( 1), 0, 1},
|
||||
{"joy", XRP( 1) + reserve(env, 2) + 1 * f, 1, noPreTrust, 1000, tesSUCCESS, XRP( 1) + f, USD( 1), 1, 2},
|
||||
{"kim", XRP( 900) + reserve(env, 2) + 1 * f, 999, noPreTrust, 1000, tesSUCCESS, XRP( 999) + f, USD( 999), 0, 1},
|
||||
{"liz", XRP( 998) + reserve(env, 0) + 1 * f, 999, noPreTrust, 1000, tesSUCCESS, XRP( 998) + f, USD( 998), 0, 1},
|
||||
{"meg", XRP( 998) + reserve(env, 1) + 1 * f, 999, noPreTrust, 1000, tesSUCCESS, XRP( 999) + f, USD( 999), 0, 1},
|
||||
{"nia", XRP( 998) + reserve(env, 2) + 1 * f, 999, noPreTrust, 1000, tesSUCCESS, XRP( 999) + f, USD( 999), 1, 2},
|
||||
{"ova", XRP( 999) + reserve(env, 0) + 1 * f, 1000, noPreTrust, 1000, tesSUCCESS, XRP( 999) + f, USD( 999), 0, 1},
|
||||
{"pam", XRP( 999) + reserve(env, 1) + 1 * f, 1000, noPreTrust, 1000, tesSUCCESS, XRP(1000) + f, USD( 1000), 0, 1},
|
||||
{"rae", XRP( 999) + reserve(env, 2) + 1 * f, 1000, noPreTrust, 1000, tesSUCCESS, XRP(1000) + f, USD( 1000), 0, 1},
|
||||
{"sue", XRP(1000) + reserve(env, 2) + 1 * f, 0, noPreTrust, 1000, tesSUCCESS, f, USD( 0), 1, 1},
|
||||
//---------------- Pre-established trust lines ---------------------
|
||||
{"abe", reserve(env, 0) + 0 * f, 1, gwPreTrust, 1000, tecUNFUNDED_OFFER, f, USD( 0), 0, 0},
|
||||
{"bud", reserve(env, 0) + 1 * f, 1, gwPreTrust, 1000, tecUNFUNDED_OFFER, f, USD( 0), 0, 0},
|
||||
{"che", reserve(env, 0) + 2 * f, 0, gwPreTrust, 1000, tecINSUF_RESERVE_OFFER, f, USD( 0), 0, 0},
|
||||
{"dan", reserve(env, 0) + 2 * f, 1, gwPreTrust, 1000, tesSUCCESS, 2 * f, USD(0.00001), 0, 0},
|
||||
{"eli", XRP( 20) + reserve(env, 0) + 1 * f, 1000, gwPreTrust, 1000, tesSUCCESS, XRP(20) + 1 * f, USD( 20), 0, 0},
|
||||
{"fyn", reserve(env, 1) + 0 * f, 0, gwPreTrust, 1000, tesSUCCESS, f, USD( 0), 1, 1},
|
||||
{"gar", reserve(env, 1) + 0 * f, 1, gwPreTrust, 1000, tesSUCCESS, XRP( 1) + f, USD( 1), 1, 1},
|
||||
{"hal", reserve(env, 1) + 1 * f, 1, gwPreTrust, 1000, tesSUCCESS, XRP( 1) + f, USD( 1), 1, 1},
|
||||
|
||||
//---------------------Pre-established trust lines
|
||||
//-----------------------------
|
||||
{"abe",
|
||||
reserve(env, 0) + 0 * f,
|
||||
1,
|
||||
gwPreTrust,
|
||||
1000,
|
||||
tecUNFUNDED_OFFER,
|
||||
f,
|
||||
USD(0),
|
||||
0,
|
||||
0},
|
||||
{"bud",
|
||||
reserve(env, 0) + 1 * f,
|
||||
1,
|
||||
gwPreTrust,
|
||||
1000,
|
||||
tecUNFUNDED_OFFER,
|
||||
f,
|
||||
USD(0),
|
||||
0,
|
||||
0},
|
||||
{"che",
|
||||
reserve(env, 0) + 2 * f,
|
||||
0,
|
||||
gwPreTrust,
|
||||
1000,
|
||||
tecINSUF_RESERVE_OFFER,
|
||||
f,
|
||||
USD(0),
|
||||
0,
|
||||
0},
|
||||
{"dan",
|
||||
reserve(env, 0) + 2 * f,
|
||||
1,
|
||||
gwPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
2 * f,
|
||||
USD(0.00001),
|
||||
0,
|
||||
0},
|
||||
{"eli",
|
||||
XRP(20) + reserve(env, 0) + 1 * f,
|
||||
1000,
|
||||
gwPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(20) + 1 * f,
|
||||
USD(20),
|
||||
0,
|
||||
0},
|
||||
{"fyn",
|
||||
reserve(env, 1) + 0 * f,
|
||||
0,
|
||||
gwPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
f,
|
||||
USD(0),
|
||||
1,
|
||||
1},
|
||||
{"gar",
|
||||
reserve(env, 1) + 0 * f,
|
||||
1,
|
||||
gwPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(1) + f,
|
||||
USD(1),
|
||||
1,
|
||||
1},
|
||||
{"hal",
|
||||
reserve(env, 1) + 1 * f,
|
||||
1,
|
||||
gwPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(1) + f,
|
||||
USD(1),
|
||||
1,
|
||||
1},
|
||||
|
||||
{"ned",
|
||||
reserve(env, 1) + 0 * f,
|
||||
1,
|
||||
acctPreTrust,
|
||||
1000,
|
||||
tecUNFUNDED_OFFER,
|
||||
2 * f,
|
||||
USD(0),
|
||||
0,
|
||||
1},
|
||||
{"ole",
|
||||
reserve(env, 1) + 1 * f,
|
||||
1,
|
||||
acctPreTrust,
|
||||
1000,
|
||||
tecUNFUNDED_OFFER,
|
||||
2 * f,
|
||||
USD(0),
|
||||
0,
|
||||
1},
|
||||
{"pat",
|
||||
reserve(env, 1) + 2 * f,
|
||||
0,
|
||||
acctPreTrust,
|
||||
1000,
|
||||
tecUNFUNDED_OFFER,
|
||||
2 * f,
|
||||
USD(0),
|
||||
0,
|
||||
1},
|
||||
{"quy",
|
||||
reserve(env, 1) + 2 * f,
|
||||
1,
|
||||
acctPreTrust,
|
||||
1000,
|
||||
tecUNFUNDED_OFFER,
|
||||
2 * f,
|
||||
USD(0),
|
||||
0,
|
||||
1},
|
||||
{"ron",
|
||||
reserve(env, 1) + 3 * f,
|
||||
0,
|
||||
acctPreTrust,
|
||||
1000,
|
||||
tecINSUF_RESERVE_OFFER,
|
||||
2 * f,
|
||||
USD(0),
|
||||
0,
|
||||
1},
|
||||
{"syd",
|
||||
reserve(env, 1) + 3 * f,
|
||||
1,
|
||||
acctPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
3 * f,
|
||||
USD(0.00001),
|
||||
0,
|
||||
1},
|
||||
{"ted",
|
||||
XRP(20) + reserve(env, 1) + 2 * f,
|
||||
1000,
|
||||
acctPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(20) + 2 * f,
|
||||
USD(20),
|
||||
0,
|
||||
1},
|
||||
{"uli",
|
||||
reserve(env, 2) + 0 * f,
|
||||
0,
|
||||
acctPreTrust,
|
||||
1000,
|
||||
tecINSUF_RESERVE_OFFER,
|
||||
2 * f,
|
||||
USD(0),
|
||||
0,
|
||||
1},
|
||||
{"vic",
|
||||
reserve(env, 2) + 0 * f,
|
||||
1,
|
||||
acctPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(1) + 2 * f,
|
||||
USD(1),
|
||||
0,
|
||||
1},
|
||||
{"wes",
|
||||
reserve(env, 2) + 1 * f,
|
||||
0,
|
||||
acctPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
2 * f,
|
||||
USD(0),
|
||||
1,
|
||||
2},
|
||||
{"xan",
|
||||
reserve(env, 2) + 1 * f,
|
||||
1,
|
||||
acctPreTrust,
|
||||
1000,
|
||||
tesSUCCESS,
|
||||
XRP(1) + 2 * f,
|
||||
USD(1),
|
||||
1,
|
||||
2},
|
||||
{"ned", reserve(env, 1) + 0 * f, 1, acctPreTrust, 1000, tecUNFUNDED_OFFER, 2 * f, USD( 0), 0, 1},
|
||||
{"ole", reserve(env, 1) + 1 * f, 1, acctPreTrust, 1000, tecUNFUNDED_OFFER, 2 * f, USD( 0), 0, 1},
|
||||
{"pat", reserve(env, 1) + 2 * f, 0, acctPreTrust, 1000, tecUNFUNDED_OFFER, 2 * f, USD( 0), 0, 1},
|
||||
{"quy", reserve(env, 1) + 2 * f, 1, acctPreTrust, 1000, tecUNFUNDED_OFFER, 2 * f, USD( 0), 0, 1},
|
||||
{"ron", reserve(env, 1) + 3 * f, 0, acctPreTrust, 1000, tecINSUF_RESERVE_OFFER, 2 * f, USD( 0), 0, 1},
|
||||
{"syd", reserve(env, 1) + 3 * f, 1, acctPreTrust, 1000, tesSUCCESS, 3 * f, USD(0.00001), 0, 1},
|
||||
{"ted", XRP( 20) + reserve(env, 1) + 2 * f, 1000, acctPreTrust, 1000, tesSUCCESS, XRP(20) + 2 * f, USD( 20), 0, 1},
|
||||
{"uli", reserve(env, 2) + 0 * f, 0, acctPreTrust, 1000, tecINSUF_RESERVE_OFFER, 2 * f, USD( 0), 0, 1},
|
||||
{"vic", reserve(env, 2) + 0 * f, 1, acctPreTrust, 1000, tesSUCCESS, XRP( 1) + 2 * f, USD( 1), 0, 1},
|
||||
{"wes", reserve(env, 2) + 1 * f, 0, acctPreTrust, 1000, tesSUCCESS, 2 * f, USD( 0), 1, 2},
|
||||
{"xan", reserve(env, 2) + 1 * f, 1, acctPreTrust, 1000, tesSUCCESS, XRP( 1) + 2 * f, USD( 1), 1, 2},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
for (auto const& t : tests)
|
||||
{
|
||||
@@ -3226,203 +2887,29 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
TestData const tests[]{
|
||||
// acct pays XRP
|
||||
// acct fundXrp fundUSD gwGets gwPays
|
||||
// acctGets acctPays tec spentXrp
|
||||
// finalUSD offers owners takerGets takerPays
|
||||
{"ann",
|
||||
XRP(10) + reserve(env, 0) + 1 * f,
|
||||
USD(0),
|
||||
XRP(10),
|
||||
USD(5),
|
||||
USD(10),
|
||||
XRP(10),
|
||||
tecINSUF_RESERVE_OFFER,
|
||||
XRP(0) + (1 * f),
|
||||
USD(0),
|
||||
0,
|
||||
0},
|
||||
{"bev",
|
||||
XRP(10) + reserve(env, 1) + 1 * f,
|
||||
USD(0),
|
||||
XRP(10),
|
||||
USD(5),
|
||||
USD(10),
|
||||
XRP(10),
|
||||
tesSUCCESS,
|
||||
XRP(0) + (1 * f),
|
||||
USD(0),
|
||||
1,
|
||||
1,
|
||||
XRP(10),
|
||||
USD(10)},
|
||||
{"cam",
|
||||
XRP(10) + reserve(env, 0) + 1 * f,
|
||||
USD(0),
|
||||
XRP(10),
|
||||
USD(10),
|
||||
USD(10),
|
||||
XRP(10),
|
||||
tesSUCCESS,
|
||||
XRP(10) + (1 * f),
|
||||
USD(10),
|
||||
0,
|
||||
1},
|
||||
{"deb",
|
||||
XRP(10) + reserve(env, 0) + 1 * f,
|
||||
USD(0),
|
||||
XRP(10),
|
||||
USD(20),
|
||||
USD(10),
|
||||
XRP(10),
|
||||
tesSUCCESS,
|
||||
XRP(10) + (1 * f),
|
||||
USD(20),
|
||||
0,
|
||||
1},
|
||||
{"eve",
|
||||
XRP(10) + reserve(env, 0) + 1 * f,
|
||||
USD(0),
|
||||
XRP(10),
|
||||
USD(20),
|
||||
USD(5),
|
||||
XRP(5),
|
||||
tesSUCCESS,
|
||||
XRP(5) + (1 * f),
|
||||
USD(10),
|
||||
0,
|
||||
1},
|
||||
{"flo",
|
||||
XRP(10) + reserve(env, 0) + 1 * f,
|
||||
USD(0),
|
||||
XRP(10),
|
||||
USD(20),
|
||||
USD(20),
|
||||
XRP(20),
|
||||
tesSUCCESS,
|
||||
XRP(10) + (1 * f),
|
||||
USD(20),
|
||||
0,
|
||||
1},
|
||||
{"gay",
|
||||
XRP(20) + reserve(env, 1) + 1 * f,
|
||||
USD(0),
|
||||
XRP(10),
|
||||
USD(20),
|
||||
USD(20),
|
||||
XRP(20),
|
||||
tesSUCCESS,
|
||||
XRP(10) + (1 * f),
|
||||
USD(20),
|
||||
0,
|
||||
1},
|
||||
{"hye",
|
||||
XRP(20) + reserve(env, 2) + 1 * f,
|
||||
USD(0),
|
||||
XRP(10),
|
||||
USD(20),
|
||||
USD(20),
|
||||
XRP(20),
|
||||
tesSUCCESS,
|
||||
XRP(10) + (1 * f),
|
||||
USD(20),
|
||||
1,
|
||||
2,
|
||||
XRP(10),
|
||||
USD(10)},
|
||||
// acct fundXrp fundUSD gwGets gwPays acctGets acctPays tec spentXrp finalUSD offers owners takerGets takerPays
|
||||
{"ann", XRP(10) + reserve(env, 0) + 1 * f, USD( 0), XRP(10), USD( 5), USD(10), XRP(10), tecINSUF_RESERVE_OFFER, XRP( 0) + (1 * f), USD( 0), 0, 0},
|
||||
{"bev", XRP(10) + reserve(env, 1) + 1 * f, USD( 0), XRP(10), USD( 5), USD(10), XRP(10), tesSUCCESS, XRP( 0) + (1 * f), USD( 0), 1, 1, XRP(10), USD(10)},
|
||||
{"cam", XRP(10) + reserve(env, 0) + 1 * f, USD( 0), XRP(10), USD(10), USD(10), XRP(10), tesSUCCESS, XRP( 10) + (1 * f), USD(10), 0, 1},
|
||||
{"deb", XRP(10) + reserve(env, 0) + 1 * f, USD( 0), XRP(10), USD(20), USD(10), XRP(10), tesSUCCESS, XRP( 10) + (1 * f), USD(20), 0, 1},
|
||||
{"eve", XRP(10) + reserve(env, 0) + 1 * f, USD( 0), XRP(10), USD(20), USD( 5), XRP( 5), tesSUCCESS, XRP( 5) + (1 * f), USD(10), 0, 1},
|
||||
{"flo", XRP(10) + reserve(env, 0) + 1 * f, USD( 0), XRP(10), USD(20), USD(20), XRP(20), tesSUCCESS, XRP( 10) + (1 * f), USD(20), 0, 1},
|
||||
{"gay", XRP(20) + reserve(env, 1) + 1 * f, USD( 0), XRP(10), USD(20), USD(20), XRP(20), tesSUCCESS, XRP( 10) + (1 * f), USD(20), 0, 1},
|
||||
{"hye", XRP(20) + reserve(env, 2) + 1 * f, USD( 0), XRP(10), USD(20), USD(20), XRP(20), tesSUCCESS, XRP( 10) + (1 * f), USD(20), 1, 2, XRP(10), USD(10)},
|
||||
// acct pays USD
|
||||
{"meg",
|
||||
reserve(env, 1) + 2 * f,
|
||||
USD(10),
|
||||
USD(10),
|
||||
XRP(5),
|
||||
XRP(10),
|
||||
USD(10),
|
||||
tecINSUF_RESERVE_OFFER,
|
||||
XRP(0) + (2 * f),
|
||||
USD(10),
|
||||
0,
|
||||
1},
|
||||
{"nia",
|
||||
reserve(env, 2) + 2 * f,
|
||||
USD(10),
|
||||
USD(10),
|
||||
XRP(5),
|
||||
XRP(10),
|
||||
USD(10),
|
||||
tesSUCCESS,
|
||||
XRP(0) + (2 * f),
|
||||
USD(10),
|
||||
1,
|
||||
2,
|
||||
USD(10),
|
||||
XRP(10)},
|
||||
{"ova",
|
||||
reserve(env, 1) + 2 * f,
|
||||
USD(10),
|
||||
USD(10),
|
||||
XRP(10),
|
||||
XRP(10),
|
||||
USD(10),
|
||||
tesSUCCESS,
|
||||
XRP(-10) + (2 * f),
|
||||
USD(0),
|
||||
0,
|
||||
1},
|
||||
{"pam",
|
||||
reserve(env, 1) + 2 * f,
|
||||
USD(10),
|
||||
USD(10),
|
||||
XRP(20),
|
||||
XRP(10),
|
||||
USD(10),
|
||||
tesSUCCESS,
|
||||
XRP(-20) + (2 * f),
|
||||
USD(0),
|
||||
0,
|
||||
1},
|
||||
{"qui",
|
||||
reserve(env, 1) + 2 * f,
|
||||
USD(10),
|
||||
USD(20),
|
||||
XRP(40),
|
||||
XRP(10),
|
||||
USD(10),
|
||||
tesSUCCESS,
|
||||
XRP(-20) + (2 * f),
|
||||
USD(0),
|
||||
0,
|
||||
1},
|
||||
{"rae",
|
||||
reserve(env, 2) + 2 * f,
|
||||
USD(10),
|
||||
USD(5),
|
||||
XRP(5),
|
||||
XRP(10),
|
||||
USD(10),
|
||||
tesSUCCESS,
|
||||
XRP(-5) + (2 * f),
|
||||
USD(5),
|
||||
1,
|
||||
2,
|
||||
USD(5),
|
||||
XRP(5)},
|
||||
{"sue",
|
||||
reserve(env, 2) + 2 * f,
|
||||
USD(10),
|
||||
USD(5),
|
||||
XRP(10),
|
||||
XRP(10),
|
||||
USD(10),
|
||||
tesSUCCESS,
|
||||
XRP(-10) + (2 * f),
|
||||
USD(5),
|
||||
1,
|
||||
2,
|
||||
USD(5),
|
||||
XRP(5)},
|
||||
{"meg", reserve(env, 1) + 2 * f, USD(10), USD(10), XRP( 5), XRP(10), USD(10), tecINSUF_RESERVE_OFFER, XRP( 0) + (2 * f), USD(10), 0, 1},
|
||||
{"nia", reserve(env, 2) + 2 * f, USD(10), USD(10), XRP( 5), XRP(10), USD(10), tesSUCCESS, XRP( 0) + (2 * f), USD(10), 1, 2, USD(10), XRP(10)},
|
||||
{"ova", reserve(env, 1) + 2 * f, USD(10), USD(10), XRP(10), XRP(10), USD(10), tesSUCCESS, XRP(-10) + (2 * f), USD( 0), 0, 1},
|
||||
{"pam", reserve(env, 1) + 2 * f, USD(10), USD(10), XRP(20), XRP(10), USD(10), tesSUCCESS, XRP(-20) + (2 * f), USD( 0), 0, 1},
|
||||
{"qui", reserve(env, 1) + 2 * f, USD(10), USD(20), XRP(40), XRP(10), USD(10), tesSUCCESS, XRP(-20) + (2 * f), USD( 0), 0, 1},
|
||||
{"rae", reserve(env, 2) + 2 * f, USD(10), USD( 5), XRP( 5), XRP(10), USD(10), tesSUCCESS, XRP( -5) + (2 * f), USD( 5), 1, 2, USD( 5), XRP( 5)},
|
||||
{"sue", reserve(env, 2) + 2 * f, USD(10), USD( 5), XRP(10), XRP(10), USD(10), tesSUCCESS, XRP(-10) + (2 * f), USD( 5), 1, 2, USD( 5), XRP( 5)},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
auto const zeroUsd = USD(0);
|
||||
for (auto const& t : tests)
|
||||
{
|
||||
@@ -3976,46 +3463,17 @@ public:
|
||||
TER secondOfferTec; // tec code on second offer
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
TestData const tests[]{
|
||||
// acct fundXRP fundUSD fundEUR firstOfferTec
|
||||
// secondOfferTec
|
||||
{"ann",
|
||||
reserve(env, 3) + f * 4,
|
||||
USD(1000),
|
||||
EUR(1000),
|
||||
tesSUCCESS,
|
||||
tesSUCCESS},
|
||||
{"bev",
|
||||
reserve(env, 3) + f * 4,
|
||||
USD(1),
|
||||
EUR(1000),
|
||||
tesSUCCESS,
|
||||
tesSUCCESS},
|
||||
{"cam",
|
||||
reserve(env, 3) + f * 4,
|
||||
USD(1000),
|
||||
EUR(1),
|
||||
tesSUCCESS,
|
||||
tesSUCCESS},
|
||||
{"deb",
|
||||
reserve(env, 3) + f * 4,
|
||||
USD(0),
|
||||
EUR(1),
|
||||
tesSUCCESS,
|
||||
tecUNFUNDED_OFFER},
|
||||
{"eve",
|
||||
reserve(env, 3) + f * 4,
|
||||
USD(1),
|
||||
EUR(0),
|
||||
tecUNFUNDED_OFFER,
|
||||
tesSUCCESS},
|
||||
{"flo",
|
||||
reserve(env, 3) + 0,
|
||||
USD(1000),
|
||||
EUR(1000),
|
||||
tecINSUF_RESERVE_OFFER,
|
||||
tecINSUF_RESERVE_OFFER},
|
||||
// acct fundXRP fundUSD fundEUR firstOfferTec secondOfferTec
|
||||
{"ann", reserve(env, 3) + f * 4, USD(1000), EUR(1000), tesSUCCESS, tesSUCCESS},
|
||||
{"bev", reserve(env, 3) + f * 4, USD( 1), EUR(1000), tesSUCCESS, tesSUCCESS},
|
||||
{"cam", reserve(env, 3) + f * 4, USD(1000), EUR( 1), tesSUCCESS, tesSUCCESS},
|
||||
{"deb", reserve(env, 3) + f * 4, USD( 0), EUR( 1), tesSUCCESS, tecUNFUNDED_OFFER},
|
||||
{"eve", reserve(env, 3) + f * 4, USD( 1), EUR( 0), tecUNFUNDED_OFFER, tesSUCCESS},
|
||||
{"flo", reserve(env, 3) + 0, USD(1000), EUR(1000), tecINSUF_RESERVE_OFFER, tecINSUF_RESERVE_OFFER},
|
||||
};
|
||||
//clang-format on
|
||||
|
||||
for (auto const& t : tests)
|
||||
{
|
||||
@@ -4592,47 +4050,15 @@ public:
|
||||
std::vector<Actor> actors;
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
TestData const tests[]{
|
||||
// btcStart --------------------- actor[0]
|
||||
// --------------------- -------------------- actor[1]
|
||||
// -------------------
|
||||
{0,
|
||||
0,
|
||||
1,
|
||||
BTC(20),
|
||||
{{"ann", 0, drops(3899999999960), BTC(20.0), USD(3000)},
|
||||
{"abe", 0, drops(4099999999970), BTC(0), USD(750)}}}, // no BTC
|
||||
// xfer fee
|
||||
{0,
|
||||
1,
|
||||
0,
|
||||
BTC(20),
|
||||
{{"bev", 0, drops(4099999999960), BTC(7.5), USD(2000)},
|
||||
{"bob", 0, drops(3899999999970), BTC(10), USD(0)}}}, // no USD
|
||||
// xfer fee
|
||||
{0,
|
||||
0,
|
||||
0,
|
||||
BTC(20),
|
||||
{{"cam",
|
||||
0,
|
||||
drops(3999999999950),
|
||||
BTC(20.0),
|
||||
USD(2000)}}}, // no xfer fee
|
||||
// { 0, 0, 1, BTC( 5), { {"deb", 0, drops(3899999999960), BTC( 5.0),
|
||||
// USD(3000)}, {"dan", 0, drops(4099999999970), BTC( 0), USD(750)} }
|
||||
// }, // no BTC xfer fee
|
||||
{0,
|
||||
1,
|
||||
0,
|
||||
BTC(5),
|
||||
{{"eve", 1, drops(4039999999960), BTC(0.0), USD(2000)},
|
||||
{"eli", 1, drops(3959999999970), BTC(4), USD(0)}}}, // no USD
|
||||
// xfer fee
|
||||
// { 0, 0, 0, BTC( 5), { {"flo", 0, drops(3999999999950), BTC( 5.0),
|
||||
// USD(2000)} }
|
||||
// } // no xfer fee
|
||||
// btcStart --------------------- actor[0] --------------------- -------------------- actor[1] -------------------
|
||||
{0, 0, 1, BTC(20), {{"ann", 0, drops(3899999999960), BTC(20.0), USD(3000)}, {"abe", 0, drops(4099999999970), BTC( 0), USD(750)}}}, // no BTC xfer fee
|
||||
{0, 1, 0, BTC(20), {{"bev", 0, drops(4099999999960), BTC( 7.5), USD(2000)}, {"bob", 0, drops(3899999999970), BTC(10), USD( 0)}}}, // no USD xfer fee
|
||||
{0, 0, 0, BTC(20), {{"cam", 0, drops(3999999999950), BTC(20.0), USD(2000)} }}, // no xfer fee
|
||||
{0, 1, 0, BTC( 5), {{"deb", 1, drops(4039999999960), BTC( 0.0), USD(2000)}, {"dan", 1, drops(3959999999970), BTC( 4), USD( 0)}}}, // no USD xfer fee
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
for (auto const& t : tests)
|
||||
{
|
||||
@@ -4774,46 +4200,19 @@ public:
|
||||
std::vector<Actor> actors;
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
TestData const takerTests[]{
|
||||
// btcStart ------------------- actor[0]
|
||||
// -------------------- ------------------- actor[1]
|
||||
// --------------------
|
||||
{0,
|
||||
0,
|
||||
1,
|
||||
BTC(5),
|
||||
{{"deb", 0, drops(3899999999960), BTC(5), USD(3000)},
|
||||
{"dan", 0, drops(4099999999970), BTC(0), USD(750)}}}, // no BTC
|
||||
// xfer fee
|
||||
{0,
|
||||
0,
|
||||
0,
|
||||
BTC(5),
|
||||
{{"flo", 0, drops(3999999999950), BTC(5), USD(2000)}}} // no xfer
|
||||
// fee
|
||||
// btcStart ------------------- actor[0] -------------------- ------------------- actor[1] --------------------
|
||||
{0, 0, 1, BTC(5), {{"deb", 0, drops(3899999999960), BTC(5), USD(3000)}, {"dan", 0, drops(4099999999970), BTC(0), USD(750)}}}, // no BTC xfer fee
|
||||
{0, 0, 0, BTC(5), {{"flo", 0, drops(3999999999950), BTC(5), USD(2000)} }} // no xfer fee
|
||||
};
|
||||
|
||||
TestData const flowTests[]{
|
||||
// btcStart ------------------- actor[0]
|
||||
// -------------------- ------------------- actor[1]
|
||||
// --------------------
|
||||
{0,
|
||||
0,
|
||||
1,
|
||||
BTC(5),
|
||||
{{"gay", 1, drops(3949999999960), BTC(5), USD(2500)},
|
||||
{"gar",
|
||||
1,
|
||||
drops(4049999999970),
|
||||
BTC(0),
|
||||
USD(1375)}}}, // no BTC xfer fee
|
||||
{0,
|
||||
0,
|
||||
0,
|
||||
BTC(5),
|
||||
{{"hye", 2, drops(3999999999950), BTC(5), USD(2000)}}} // no xfer
|
||||
// fee
|
||||
// btcStart ------------------- actor[0] -------------------- ------------------- actor[1] --------------------
|
||||
{0, 0, 1, BTC(5), {{"gay", 1, drops(3949999999960), BTC(5), USD(2500)}, {"gar", 1, drops(4049999999970), BTC(0), USD(1375)}}}, // no BTC xfer fee
|
||||
{0, 0, 0, BTC(5), {{"hye", 2, drops(3999999999950), BTC(5), USD(2000)} }} // no xfer fee
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
// Pick the right tests.
|
||||
auto const& tests = features[featureFlowCross] ? flowTests : takerTests;
|
||||
|
||||
@@ -702,7 +702,6 @@ struct PayStrand_test : public beast::unit_test::suite
|
||||
true,
|
||||
false,
|
||||
env.app().logs().journal("Flow"));
|
||||
(void)ter;
|
||||
(void)_;
|
||||
BEAST_EXPECT(ter == tesSUCCESS);
|
||||
}
|
||||
@@ -719,12 +718,10 @@ struct PayStrand_test : public beast::unit_test::suite
|
||||
true,
|
||||
false,
|
||||
env.app().logs().journal("Flow"));
|
||||
(void)ter;
|
||||
(void)_;
|
||||
BEAST_EXPECT(ter == tesSUCCESS);
|
||||
}
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
Env env(*this, features);
|
||||
@@ -794,12 +791,16 @@ struct PayStrand_test : public beast::unit_test::suite
|
||||
B{XRP, USD},
|
||||
D{gw, bob, usdC});
|
||||
|
||||
// Path with XRP dst currency
|
||||
// Path with XRP dst currency.
|
||||
test(
|
||||
env,
|
||||
xrpIssue(),
|
||||
USD.issue(),
|
||||
STPath({ipe(XRP)}),
|
||||
STPath({STPathElement{
|
||||
STPathElement::typeCurrency,
|
||||
xrpAccount(),
|
||||
xrpCurrency(),
|
||||
xrpAccount()}}),
|
||||
tesSUCCESS,
|
||||
D{alice, gw, usdC},
|
||||
B{USD, XRP},
|
||||
@@ -854,7 +855,7 @@ struct PayStrand_test : public beast::unit_test::suite
|
||||
BEAST_EXPECT(r.first == temBAD_PATH);
|
||||
}
|
||||
{
|
||||
// The root account can't be the src
|
||||
// The root account can't be the src.
|
||||
auto r = toStrand(
|
||||
*env.current(),
|
||||
noAccount(),
|
||||
@@ -866,7 +867,7 @@ struct PayStrand_test : public beast::unit_test::suite
|
||||
true,
|
||||
false,
|
||||
flowJournal);
|
||||
BEAST_EXPECT(r.first == terNO_ACCOUNT);
|
||||
BEAST_EXPECT(r.first == temBAD_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1005,20 +1006,6 @@ struct PayStrand_test : public beast::unit_test::suite
|
||||
BEAST_EXPECT(ter == tesSUCCESS);
|
||||
BEAST_EXPECT(equal(strand, D{alice, gw, usdC}));
|
||||
}
|
||||
{
|
||||
// Check path with sendMax and node with correct sendMax already set
|
||||
Env env(*this, features);
|
||||
env.fund(XRP(10000), alice, bob, gw);
|
||||
env.trust(USD(1000), alice, bob);
|
||||
env.trust(EUR(1000), alice, bob);
|
||||
env(pay(gw, alice, EUR(100)));
|
||||
auto const path = STPath({STPathElement(
|
||||
STPathElement::typeAll,
|
||||
EUR.account,
|
||||
EUR.currency,
|
||||
EUR.account)});
|
||||
test(env, USD, EUR.issue(), path, tesSUCCESS);
|
||||
}
|
||||
|
||||
{
|
||||
// last step xrp from offer
|
||||
@@ -1029,7 +1016,6 @@ struct PayStrand_test : public beast::unit_test::suite
|
||||
|
||||
// alice -> USD/XRP -> bob
|
||||
STPath path;
|
||||
path.emplace_back(std::nullopt, USD.currency, USD.account.id());
|
||||
path.emplace_back(std::nullopt, xrpCurrency(), std::nullopt);
|
||||
|
||||
auto [ter, strand] = toStrand(
|
||||
|
||||
Reference in New Issue
Block a user