Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase test coverage #4971

Merged
merged 29 commits into from
Apr 18, 2024
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c7e0da5
Add coverage
thejohnfreeman Mar 27, 2024
c210ad4
Suppress warning: unused variable 'index'
HowardHinnant Mar 28, 2024
779b381
Remove unused code.
HowardHinnant Mar 28, 2024
c688be6
Tests for AMMBid::preflight()
mtrippled Mar 28, 2024
f6b1f68
Test comparison of issued assets to cover STIssue.h.
mtrippled Mar 29, 2024
a8c0884
Increase unit tests coverage
Bronek Mar 25, 2024
48ce399
update test coverage for AMMDeposit
mvadari Mar 26, 2024
faad55f
remove unreachable lines from codecov
mvadari Mar 27, 2024
8975ddf
Fix formatting
thejohnfreeman Mar 29, 2024
7f151fa
Disable wandalen/wretry for codecov upload
Bronek Apr 2, 2024
87c8acd
AMMBid unit test: burn all LP tokens
ckeshava Apr 3, 2024
51eaed5
Edit comments
thejohnfreeman Apr 3, 2024
61d007e
Consolidate disabled amendment tests
thejohnfreeman Apr 4, 2024
a504e86
Convert most bid tests to use BidArg
thejohnfreeman Apr 4, 2024
43a251c
Try to convert last bid tests
thejohnfreeman Apr 4, 2024
2088454
Format code
thejohnfreeman Apr 4, 2024
242b7ec
Finish bid tests
thejohnfreeman Apr 5, 2024
b8fdf58
Merge branch 'ckeshava/burnTest'
thejohnfreeman Apr 5, 2024
1fa1581
Merge burn tests and eliminate non-BidArg overload
thejohnfreeman Apr 5, 2024
e13b7e5
Merge upstream 'develop'
thejohnfreeman Apr 5, 2024
c6128d1
Fix formatting
thejohnfreeman Apr 5, 2024
fcb4bdb
Address comments
thejohnfreeman Apr 11, 2024
7ffdb33
Codecov coverage reporting fixes
Bronek Apr 3, 2024
803033e
Enable github annotations
Bronek Apr 12, 2024
0a308af
Set expected range and codecov rounding
Bronek Apr 12, 2024
bfa41d8
Merge bkozicki/feature/codecov-improvements
thejohnfreeman Apr 12, 2024
62485c5
Merge upstream 'develop'
thejohnfreeman Apr 18, 2024
3fedf64
Forgot return type specifier
thejohnfreeman Apr 18, 2024
20e69b2
Merge upstream 'develop'
thejohnfreeman Apr 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 75 additions & 23 deletions src/test/app/AMM_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2410,6 +2410,58 @@ struct AMM_test : public jtx::AMMTest
using namespace jtx;
using namespace std::chrono;

// burn all the LPTokens through a AMMBid transaction
{
Env env(*this);
fund(env, gw, {alice}, XRP(2'000), {USD(2'000)});
AMM amm(env, gw, XRP(1'000), USD(1'000), false, 1'000);

// auction slot is owned by the creator of the AMM i.e. gw
BEAST_EXPECT(amm.expectAuctionSlot(100, 0, IOUAmount{0}));

// gw attempts to burn all her LPTokens through a bid transaction
// this transaction fails because AMMBid transaction can not burn
// all the outstanding LPTokens
amm.bid(BidArg{
.account = gw,
.bidMin = 1'000'000,
.err = ter(tecAMM_INVALID_TOKENS)});
}

// burn all the LPTokens through a AMMBid transaction
{
Env env(*this);
fund(env, gw, {alice}, XRP(2'000), {USD(2'000)});
AMM amm(env, gw, XRP(1'000), USD(1'000), false, 1'000);

// auction slot is owned by the creator of the AMM i.e. gw
BEAST_EXPECT(amm.expectAuctionSlot(100, 0, IOUAmount{0}));

// gw burns all but one of her LPTokens through a bid transaction
// this transaction suceeds because the bid price is less than
// the total outstanding LPToken balance
amm.bid(BidArg{
.account = gw,
.bidMin = STAmount{amm.lptIssue(), UINT64_C(999'999)},
.err = ter(tesSUCCESS)});

// gw must posses the auction slot
thejohnfreeman marked this conversation as resolved.
Show resolved Hide resolved
thejohnfreeman marked this conversation as resolved.
Show resolved Hide resolved
BEAST_EXPECT(amm.expectAuctionSlot(100, 0, IOUAmount{999'999}));

// 999'999 tokens are burned, only 1 LPToken is in vogue
thejohnfreeman marked this conversation as resolved.
Show resolved Hide resolved
thejohnfreeman marked this conversation as resolved.
Show resolved Hide resolved
BEAST_EXPECT(
amm.expectBalances(XRP(1'000), USD(1'000), IOUAmount{1}));

// gw posses only one LPToken in her balance
BEAST_EXPECT(Number{amm.getLPTokensBalance(gw)} == 1);

// gw attempts to burn the last of her LPTokens in an AMMBid
// transaction. This transaction fails because it would burn all
// the remaining LPTokens
amm.bid(BidArg{
.account = gw, .bidMin = 1, .err = ter(tecAMM_INVALID_TOKENS)});
}

testAMM([&](AMM& ammAlice, Env& env) {
// Invalid flags
ammAlice.bid(
Expand Down Expand Up @@ -5088,30 +5140,30 @@ struct AMM_test : public jtx::AMMTest
void
testCore()
{
testInvalidInstance();
testInstanceCreate();
testInvalidDeposit();
testDeposit();
testInvalidWithdraw();
testWithdraw();
testInvalidFeeVote();
testFeeVote();
// testInvalidInstance();
thejohnfreeman marked this conversation as resolved.
Show resolved Hide resolved
// testInstanceCreate();
// testInvalidDeposit();
// testDeposit();
// testInvalidWithdraw();
// testWithdraw();
// testInvalidFeeVote();
// testFeeVote();
thejohnfreeman marked this conversation as resolved.
Show resolved Hide resolved
testInvalidBid();
testBid();
testInvalidAMMPayment();
testBasicPaymentEngine();
testAMMTokens();
testAmendment();
testFlags();
testRippling();
testAMMAndCLOB();
testTradingFee();
testAdjustedTokens();
testAutoDelete();
testClawback();
testAMMID();
testSelection();
testFixDefaultInnerObj();
// testBid();
// testInvalidAMMPayment();
// testBasicPaymentEngine();
// testAMMTokens();
// testAmendment();
// testFlags();
// testRippling();
// testAMMAndCLOB();
// testTradingFee();
// testAdjustedTokens();
// testAutoDelete();
// testClawback();
// testAMMID();
// testSelection();
// testFixDefaultInnerObj();
thejohnfreeman marked this conversation as resolved.
Show resolved Hide resolved
}

void
Expand Down