Skip to content

Commit

Permalink
update redeem.dynamic int test
Browse files Browse the repository at this point in the history
  • Loading branch information
barrasso committed Apr 12, 2024
1 parent f6866d6 commit 9e28b00
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions test/integration/behaviors/redeem.dynamic.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ function itCanRedeem({ ctx }) {
describe('user redemption', () => {
let txn;
let sUSDBeforeRedemption;
let synth1Balance, synth2Balance;

before(async () => {
sUSDBeforeRedemption = await SynthsUSD.balanceOf(someUser.address);
synth1Balance = await SynthToRedeem1.balanceOf(someUser.address);
synth2Balance = await SynthToRedeem2.balanceOf(someUser.address);
});

before('when the user redeems all of their synths', async () => {
Expand All @@ -100,10 +104,14 @@ function itCanRedeem({ ctx }) {
});

it('then the total system debt is unchanged', async () => {
assert.bnEqual((await DebtCache.currentDebt()).debt, totalDebtBeforeRedemption);
assert.bnEqual(
await Issuer.totalIssuedSynths(toBytes32('sUSD'), true),
totalIssuedSynthsBeforeRedemption
/// use bnClose for slight variance in fork test
assert.bnClose(
(await DebtCache.currentDebt()).debt.toString(),
totalDebtBeforeRedemption.toString()
);
assert.bnClose(
(await Issuer.totalIssuedSynths(toBytes32('sUSD'), true)).toString(),
totalIssuedSynthsBeforeRedemption.toString()
);
});
it('then the user has no more synths', async () => {
Expand All @@ -119,7 +127,11 @@ function itCanRedeem({ ctx }) {
const { events } = await txn.wait();
const synthRedeemedEvents = events.filter(l => l.event === 'SynthRedeemed');

const expectedAmount = parseEther('990');
let totalValueRedeemedInsUSD = ethers.BigNumber.from(0);
const sUSDBalanceAfter = await SynthsUSD.balanceOf(someUser.address);
const expectedAmountofsUSD = sUSDBalanceAfter.sub(sUSDBeforeRedemption);

const synthBalances = [synth1Balance, synth2Balance];
const synthProxies = [SynthToRedeemProxy1.address, SynthToRedeemProxy2.address];

synthRedeemedEvents.forEach((event, index) => {
Expand All @@ -130,9 +142,13 @@ function itCanRedeem({ ctx }) {

assert.equal(synth, synthProxies[index]);
assert.equal(account, someUser.address);
assert.bnEqual(amountOfSynth, expectedAmount);
assert.bnEqual(amountInsUSD, expectedAmount);
assert.bnEqual(amountOfSynth, synthBalances[index]);

totalValueRedeemedInsUSD = totalValueRedeemedInsUSD.add(amountInsUSD);
});

assert.bnEqual(expectedAmountofsUSD, totalValueRedeemedInsUSD);
assert.bnEqual(sUSDBalanceAfter, sUSDBeforeRedemption.add(totalValueRedeemedInsUSD));
});
});
});
Expand Down

0 comments on commit 9e28b00

Please sign in to comment.