Skip to content

Commit

Permalink
test(swap): snapshot offers
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Mar 12, 2024
1 parent 5ebd71c commit b0151da
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions contract/test/test-swap-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ test.serial('bootstrap and start contract', async t => {
});

/**
* @param {import('ava').ExecutionContext} t
* @param {*} wellKnown
* @param {MockWallet} wallet
* @param {Amount} beansAmount
Expand All @@ -56,6 +57,7 @@ test.serial('bootstrap and start contract', async t => {
* @param {boolean} [alicePays]
*/
const startAlice = async (
t,
wellKnown,
wallet,
beansAmount,
Expand Down Expand Up @@ -89,19 +91,22 @@ const startAlice = async (
proposal,
offerArgs: { addr: depositAddress },
};
t.snapshot(offerSpec, 'alice makes offer');

const updates = E(wallet.offers).executeOffer(offerSpec);
return updates;
};

/**
* @param {import('ava').ExecutionContext} t
* @param {*} wellKnown
* @param {MockWallet} wallet
* @param {Amount} beansAmount
* @param {Amount} cowsAmount
* @param {boolean} [jackPays]
*/
const startJack = async (
t,
wellKnown,
wallet,
beansAmount,
Expand Down Expand Up @@ -130,6 +135,7 @@ const startJack = async (
},
proposal,
};
t.snapshot(offerSpec, 'jack makes offer');

return E(wallet.offers).executeOffer(offerSpec);
};
Expand Down Expand Up @@ -198,7 +204,14 @@ test.serial('basic swap', async t => {
await mintBrandedPayment(fiveBeans.value),
);
const aliceSeat = seatLike(
await startAlice(wellKnown, wallet.alice, fiveBeans, cowAmount, addr.jack),
await startAlice(
t,
wellKnown,
wallet.alice,
fiveBeans,
cowAmount,
addr.jack,
),
);

const aliceResult = await E(aliceSeat).getOfferResult();
Expand All @@ -209,7 +222,7 @@ test.serial('basic swap', async t => {
await E(E.get(bldIssuerKit).mint).mintPayment(cowAmount),
);
const jackSeat = seatLike(
await startJack(wellKnown, wallet.jack, fiveBeans, cowAmount),
await startJack(t, wellKnown, wallet.jack, fiveBeans, cowAmount),
);

const jackPayouts = await jackSeat.getPayoutAmounts();
Expand Down

0 comments on commit b0151da

Please sign in to comment.