Skip to content

Commit 4ad3e9f

Browse files
committed
fixup! Update several unit tests to work with the new number rules
1 parent 3f87aeb commit 4ad3e9f

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

src/test/app/AMMClawback_test.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2425,7 +2425,10 @@ class AMMClawback_test : public beast::unit_test::suite
24252425
void
24262426
run() override
24272427
{
2428-
FeatureBitset const all = jtx::testable_amendments();
2428+
// For now, just disable SAV entirely, which locks in the small Number
2429+
// mantissas
2430+
FeatureBitset const all = jtx::testable_amendments() -
2431+
featureSingleAssetVault /* - featureLendingProtocol */;
24292432

24302433
testInvalidRequest();
24312434
testFeatureDisabled(all - featureAMMClawback);

src/test/app/AMM_test.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ struct AMM_test : public jtx::AMMTest
3434
NumberMantissaScaleGuard const sg_{ripple::MantissaRange::small};
3535

3636
private:
37+
FeatureBitset
38+
testable_amendments()
39+
{
40+
// For now, just disable SAV entirely, which locks in the small Number
41+
// mantissas
42+
return jtx::testable_amendments() -
43+
featureSingleAssetVault /* - featureLendingProtocol */;
44+
}
45+
3746
void
3847
testInstanceCreate()
3948
{
@@ -1368,8 +1377,8 @@ struct AMM_test : public jtx::AMMTest
13681377
{
13691378
testcase("Deposit");
13701379

1371-
using namespace jtx;
13721380
auto const all = testable_amendments();
1381+
using namespace jtx;
13731382

13741383
// Equal deposit: 1000000 tokens, 10% of the current pool
13751384
testAMM([&](AMM& ammAlice, Env& env) {
@@ -1487,7 +1496,9 @@ struct AMM_test : public jtx::AMMTest
14871496
});
14881497

14891498
// Single deposit: 100000 tokens worth of XRP
1490-
testAMM([&](AMM& ammAlice, Env&) {
1499+
testAMM([&](AMM& ammAlice, Env& env) {
1500+
BEAST_EXPECT(
1501+
!env.app().config().features.contains(featureSingleAssetVault));
14911502
ammAlice.deposit(carol, 100'000, XRP(205));
14921503
BEAST_EXPECT(ammAlice.expectBalances(
14931504
XRP(10'201), USD(10'000), IOUAmount{10'100'000, 0}));
@@ -1668,8 +1679,8 @@ struct AMM_test : public jtx::AMMTest
16681679
{
16691680
testcase("Invalid Withdraw");
16701681

1671-
using namespace jtx;
16721682
auto const all = testable_amendments();
1683+
using namespace jtx;
16731684

16741685
testAMM(
16751686
[&](AMM& ammAlice, Env& env) {
@@ -2248,8 +2259,8 @@ struct AMM_test : public jtx::AMMTest
22482259
{
22492260
testcase("Withdraw");
22502261

2251-
using namespace jtx;
22522262
auto const all = testable_amendments();
2263+
using namespace jtx;
22532264

22542265
// Equal withdrawal by Carol: 1000000 of tokens, 10% of the current
22552266
// pool
@@ -2669,8 +2680,8 @@ struct AMM_test : public jtx::AMMTest
26692680
testFeeVote()
26702681
{
26712682
testcase("Fee Vote");
2672-
using namespace jtx;
26732683
auto const all = testable_amendments();
2684+
using namespace jtx;
26742685

26752686
// One vote sets fee to 1%.
26762687
testAMM([&](AMM& ammAlice, Env& env) {
@@ -4846,12 +4857,12 @@ struct AMM_test : public jtx::AMMTest
48464857
testAmendment()
48474858
{
48484859
testcase("Amendment");
4849-
using namespace jtx;
48504860
FeatureBitset const all{testable_amendments()};
48514861
FeatureBitset const noAMM{all - featureAMM};
48524862
FeatureBitset const noNumber{all - fixUniversalNumber};
48534863
FeatureBitset const noAMMAndNumber{
48544864
all - featureAMM - fixUniversalNumber};
4865+
using namespace jtx;
48554866

48564867
for (auto const& feature : {noAMM, noNumber, noAMMAndNumber})
48574868
{
@@ -7037,7 +7048,7 @@ struct AMM_test : public jtx::AMMTest
70377048
{{xrpPool, iouPool}},
70387049
889,
70397050
std::nullopt,
7040-
{jtx::testable_amendments() | fixAMMv1_1});
7051+
{testable_amendments() | fixAMMv1_1});
70417052
}
70427053

70437054
void
@@ -7892,7 +7903,7 @@ struct AMM_test : public jtx::AMMTest
78927903
void
78937904
run() override
78947905
{
7895-
FeatureBitset const all{jtx::testable_amendments()};
7906+
FeatureBitset const all{testable_amendments()};
78967907
testInvalidInstance();
78977908
testInstanceCreate();
78987909
testInvalidDeposit(all);

src/test/basics/Number_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class Number_test : public beast::unit_test::suite
8181
caught = false;
8282
try
8383
{
84+
[[maybe_unused]]
8485
Number q =
8586
Number{false, minMantissa, 32767, Number::normalized{}} * 100;
8687
}

src/test/jtx/AMMTest.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ struct TestAMMArg
2121
std::optional<std::pair<STAmount, STAmount>> pool = std::nullopt;
2222
std::uint16_t tfee = 0;
2323
std::optional<jtx::ter> ter = std::nullopt;
24-
std::vector<FeatureBitset> features = {testable_amendments()};
24+
std::vector<FeatureBitset> features = {
25+
// For now, just disable SAV entirely, which locks in the small Number
26+
// mantissas
27+
jtx::testable_amendments() -
28+
featureSingleAssetVault /* - featureLendingProtocol */};
29+
2530
bool noLog = false;
2631
};
2732

0 commit comments

Comments
 (0)