Skip to content

Commit

Permalink
test: repair test
Browse files Browse the repository at this point in the history
The verifications for metrics updates were misplaced. Added interest
  • Loading branch information
Chris-Hibbert authored and dckc committed Aug 19, 2024
1 parent d0a3bbc commit ae42f73
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ Generated by [AVA](https://avajs.dev).
compoundedInterest: {
denominator: {
brand: Object @Alleged: IST brand {},
value: 100000000000000000000n,
value: 857701650301172500n,
},
numerator: {
brand: Object @Alleged: IST brand {},
value: 101967213114754098360n,
value: 874574469651359500n,
},
},
interestRate: {
Expand Down Expand Up @@ -387,11 +387,11 @@ Generated by [AVA](https://avajs.dev).
interest: {
denominator: {
brand: Object @Alleged: IST brand {},
value: 100000000000000000000n,
value: 857701650301172500n,
},
numerator: {
brand: Object @Alleged: IST brand {},
value: 101967213114754098360n,
value: 874574469651359500n,
},
},
},
Expand All @@ -413,11 +413,11 @@ Generated by [AVA](https://avajs.dev).
interest: {
denominator: {
brand: Object @Alleged: IST brand {},
value: 100000000000000000000n,
value: 857701650301172500n,
},
numerator: {
brand: Object @Alleged: IST brand {},
value: 101967213114754098360n,
value: 874574469651359500n,
},
},
},
Expand Down
Binary file not shown.
46 changes: 23 additions & 23 deletions packages/inter-protocol/test/vaultFactory/vaultFactory.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,13 @@ test('manager notifiers, with snapshot', async t => {
}),
);
({ vault } = await E(vaultSeat).getOfferResult());
totalCollateral += ENOUGH;
totalDebt += DEBT2;
await m.assertChange({
numActiveVaults: 4,
totalCollateral: { value: totalCollateral },
totalDebt: { value: totalDebt },
});

trace('6. Loan interest');
vaultSeat = await E(services.zoe).offer(
Expand All @@ -1851,18 +1858,21 @@ test('manager notifiers, with snapshot', async t => {
}),
);
({ vault } = await E(vaultSeat).getOfferResult());
totalCollateral += ENOUGH;
totalDebt += DEBT2;
totalCollateral += AMPLE;
totalDebt += DEBT1;
await m.assertChange({
numActiveVaults: 4,
numActiveVaults: 5,
totalCollateral: { value: totalCollateral },
totalDebt: { value: totalDebt },
});
m.addDebt(DEBT2);

await manualTimer.tickN(5);
// This is interest for a single vault.
const interestAccrued = (await E(vault).getCurrentDebt()).value - DEBT1;
m.addDebt(interestAccrued);
t.is(interestAccrued, 9n);

t.is(interestAccrued, 9n); // interest on OPEN1 for 5 periods
totalDebt += 30n; // interest on 270_000 for 5 periods

trace('7. make another loan to trigger a publish');
vaultSeat = await E(services.zoe).offer(
Expand All @@ -1876,10 +1886,10 @@ test('manager notifiers, with snapshot', async t => {
}),
);
({ vault } = await E(vaultSeat).getOfferResult());
totalCollateral += AMPLE;
totalDebt += DEBT1;
totalCollateral += ENOUGH;
totalDebt += DEBT2;
await m.assertChange({
numActiveVaults: 5,
numActiveVaults: 6,
totalCollateral: { value: totalCollateral },
totalDebt: { value: totalDebt },
});
Expand All @@ -1898,11 +1908,10 @@ test('manager notifiers, with snapshot', async t => {
}),
);
({ vault } = await E(vaultSeat).getOfferResult());
totalCollateral += ENOUGH;
totalDebt += DEBT2 + 30n; // XXX ??
m.addDebt(DEBT2);
totalCollateral += AMPLE;
totalDebt += DEBT1;
await m.assertChange({
numActiveVaults: 6,
numActiveVaults: 7,
totalCollateral: { value: totalCollateral },
totalDebt: { value: totalDebt },
});
Expand All @@ -1925,20 +1934,11 @@ test('manager notifiers, with snapshot', async t => {
}),
);
await E(vaultOpSeat).getOfferResult();
totalCollateral += AMPLE;
totalDebt += DEBT1;
await m.assertChange({
numActiveVaults: 7,
totalDebt: { value: totalDebt },
totalCollateral: { value: totalCollateral },
});

totalCollateral += given.value;
totalDebt += WANT_EXTRA + 20n; // magic number is fees

totalDebt += WANT_EXTRA + 20n;
await m.assertChange({
totalCollateral: { value: totalCollateral },
totalDebt: { value: totalDebt },
totalCollateral: { value: totalCollateral },
});

trace('10. Close vault');
Expand Down

0 comments on commit ae42f73

Please sign in to comment.