Skip to content

Commit

Permalink
Extend AMM/MPT test framework to facilitate MPT/DEX unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gregtatcam committed Mar 10, 2025
1 parent 4801609 commit 7ea2b50
Show file tree
Hide file tree
Showing 16 changed files with 12,692 additions and 57 deletions.
5 changes: 5 additions & 0 deletions include/xrpl/protocol/MPTIssue.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ class MPTIssue

MPTIssue(std::uint32_t sequence, AccountID const& account);

operator MPTID const&() const
{
return mptID_;
}

AccountID const&
getIssuer() const;

Expand Down
9 changes: 9 additions & 0 deletions include/xrpl/protocol/STAmount.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ class STAmount final : public STBase, public CountedObject<STAmount>
template <AssetType A>
STAmount(A const& asset, int mantissa, int exponent = 0);

template <AssetType A>
STAmount(A const& asset, Number const& n);

// Legacy support for new-style amounts
STAmount(IOUAmount const& amount, Issue const& issue);
STAmount(XRPAmount const& amount);
Expand Down Expand Up @@ -374,6 +377,12 @@ STAmount::STAmount(A const& asset, int mantissa, int exponent)
{
}

template <AssetType A>
STAmount::STAmount(A const& asset, Number const& n)
: STAmount(asset, n.mantissa(), n.exponent())
{
}

// Legacy support for new-style amounts
inline STAmount::STAmount(IOUAmount const& amount, Issue const& issue)
: mAsset(issue)
Expand Down
4 changes: 2 additions & 2 deletions src/test/app/AMMExtended_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ struct AMMExtended_test : public jtx::AMMTest
Env env = pathTestEnv();
env.fund(XRP(100'000'250), alice);
fund(env, gw, {carol, bob}, {USD(100)}, Fund::All);
fund(env, gw, {alice}, {USD(100)}, Fund::IOUOnly);
fund(env, gw, {alice}, {USD(100)}, Fund::TokenOnly);
AMM ammCarol(env, carol, XRP(100), USD(100));

STPathSet st;
Expand Down Expand Up @@ -3961,7 +3961,7 @@ struct AMMExtended_test : public jtx::AMMTest
bob,
{alice, gw},
{BobUSD(100), BobEUR(100)},
Fund::IOUOnly);
Fund::TokenOnly);

AMM ammBobXRP_USD(env, bob, XRP(100), BobUSD(100));
env(offer(gw, XRP(100), USD(100)), txflags(tfPassive));
Expand Down
Loading

0 comments on commit 7ea2b50

Please sign in to comment.