Skip to content

Commit

Permalink
Address reviewer's feedback - add MPT unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gregtatcam committed Oct 21, 2024
1 parent b8f3b83 commit 5349827
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/test/app/MPToken_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,15 +768,20 @@ class MPToken_test : public beast::unit_test::suite
{
Env env{*this, features};

MPTTester mptAlice(env, alice, {.holders = {bob}});
MPTTester mptAlice(env, alice, {.holders = {bob, carol}});

mptAlice.create({.ownerCount = 1, .holderCount = 0});
auto const MPT = mptAlice["MPT"];

mptAlice.authorize({.account = bob});
mptAlice.authorize({.account = carol});

mptAlice.pay(alice, bob, -1, temBAD_AMOUNT);

mptAlice.pay(bob, carol, -1, temBAD_AMOUNT);

mptAlice.pay(bob, alice, -1, temBAD_AMOUNT);

env(pay(alice, bob, MPT(10)), sendmax(MPT(-1)), ter(temBAD_AMOUNT));
}

Expand Down Expand Up @@ -1189,6 +1194,36 @@ class MPToken_test : public beast::unit_test::suite
ter(tecPATH_PARTIAL));
}

// Pay maximum allowed amount
{
Env env{*this, features};

MPTTester mptAlice(env, alice, {.holders = {bob, carol}});

mptAlice.create(
{.maxAmt = maxMPTokenAmount,
.ownerCount = 1,
.holderCount = 0,
.flags = tfMPTCanTransfer});
auto const MPT = mptAlice["MPT"];

mptAlice.authorize({.account = bob});
mptAlice.authorize({.account = carol});

// issuer sends holder the max amount allowed
mptAlice.pay(alice, bob, maxMPTokenAmount);
BEAST_EXPECT(
mptAlice.checkMPTokenOutstandingAmount(maxMPTokenAmount));

// payment between the holders
mptAlice.pay(bob, carol, maxMPTokenAmount);
BEAST_EXPECT(
mptAlice.checkMPTokenOutstandingAmount(maxMPTokenAmount));
// holder pays back to the issuer
mptAlice.pay(carol, alice, maxMPTokenAmount);
BEAST_EXPECT(mptAlice.checkMPTokenOutstandingAmount(0));
}

// Issuer fails trying to send fund after issuance was destroyed
{
Env env{*this, features};
Expand Down

0 comments on commit 5349827

Please sign in to comment.