Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend liquidation visibility unit tests #12

Merged
merged 22 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0d0d493
Squashed commit of the following:
Jorge-Lopes Jan 31, 2024
9d45370
chore(liquidationVisibility): #4 add auctioneer wrapper and update se…
Jorge-Lopes Feb 1, 2024
b26f661
chore(liquidationVisibility): #4 add mock makeChainStorageNode
Jorge-Lopes Feb 1, 2024
575302c
chore(liquidationVisibility): #4 add tests for no vaults and rejected…
Jorge-Lopes Feb 1, 2024
4c4facd
chore(internal): create key-value pairs for Promise.allSettled values
anilhelvaci Feb 1, 2024
d269efd
fix(internal): make allValuesSettled a mapper for resolved promises a…
anilhelvaci Feb 1, 2024
f5c0f5b
fix(internal): fix doc
anilhelvaci Feb 1, 2024
84087c9
fix(liquidationVisibility): make sure promises are assigned in key-va…
anilhelvaci Feb 1, 2024
6d332b1
fix(liquidationVisibility): #4 add setBlockMakeChildNode method and u…
Jorge-Lopes Feb 1, 2024
6732555
fix(liquidationVisibility): #4 update import path
Jorge-Lopes Feb 1, 2024
e4a4c7b
chore(liquidationVisibility): #4 add liq-rejected-timestampStorageNod…
Jorge-Lopes Feb 1, 2024
031f791
fix(liquidationVisibility): #4 fix bug with at makeChildNode
Jorge-Lopes Feb 1, 2024
6f25fe3
fix(liquidationVisibility): #4 update test names and comments
Jorge-Lopes Feb 1, 2024
1e582d9
fix(liquidationVisibility): #4 lint fix
Jorge-Lopes Feb 1, 2024
9b7a81a
Merge remote-tracking branch 'origin/anil/10-fix-reject-order' into j…
Jorge-Lopes Feb 1, 2024
83b72cd
chore(liquidationVisibility): extend liq-rejected-timestampStorageNod…
Jorge-Lopes Feb 2, 2024
1ab4417
fix(liquidationVisibility): revert update made to package.json
Jorge-Lopes Feb 5, 2024
85be442
chore(liquidationVisibility): update snapshot generated by unit tests
Jorge-Lopes Feb 5, 2024
48aaa38
fix(liquidationVisibility): lint fix
Jorge-Lopes Feb 5, 2024
8b2dcd8
chore(liquidationVisibility) #4 test multiple vaultManagers
alexanderem49 Feb 8, 2024
82fd79d
fix(liquidationVisibility): #4 lint fix
alexanderem49 Feb 8, 2024
cdb3c19
Merge branch 'anil/develop' into jorge/unit-tests
Jorge-Lopes Feb 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions packages/inter-protocol/src/vaultFactory/vaultManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
NotifierShape,
RatioShape,
} from '@agoric/ertp';
import { makeTracer } from '@agoric/internal';
import { allValuesSettled, makeTracer } from '@agoric/internal';
import { makeStoredNotifier, observeNotifier } from '@agoric/notifier';
import { appendToStoredArray } from '@agoric/store/src/stores/store-utils.js';
import {
Expand Down Expand Up @@ -1385,21 +1385,16 @@ export const prepareVaultManagerKit = (
// we don't want those failures to prevent liquidation process from going forward.
// We don't handle the case where 'makeDeposit' rejects as liquidation depends on
// 'makeDeposit' being fulfilled.
await null;
const [
{ userSeatPromise, deposited },
const {
makeDeposit: { userSeatPromise, deposited },
liquidationVisibilityWriters,
auctionSchedule,
] = (
await Promise.allSettled([
makeDeposit,
} = await allValuesSettled({
makeDeposit,
liquidationVisibilityWriters:
helper.makeLiquidationVisibilityWriters(timestamp),
schedulesP,
])
)
.filter(result => result.status === 'fulfilled')
// @ts-expect-error
.map(result => result.value);
auctionSchedule: schedulesP,
});

void helper.writeLiqVisibility(liquidationVisibilityWriters, [
['writePreAuction', vaultData],
Expand Down
22 changes: 16 additions & 6 deletions packages/inter-protocol/test/liquidationVisibility/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,15 @@ export const assertVaultCurrentDebt = async (t, vault, debt) => {
);
};

export const assertVaultCollateral = async (t, vault, collateralValue) => {
export const assertVaultCollateral = async (
t,
vault,
collateralValue,
asset,
) => {
const collateralAmount = await E(vault).getCollateralAmount();

t.deepEqual(collateralAmount, t.context.aeth.make(collateralValue));
t.deepEqual(collateralAmount, asset.make(collateralValue));
};

export const assertMintedAmount = async (t, vaultSeat, wantMinted) => {
Expand All @@ -94,11 +99,16 @@ export const assertMintedProceeds = async (t, vaultSeat, wantMinted) => {
);
};

export const assertVaultLocked = async (t, vaultNotifier, lockedValue) => {
export const assertVaultLocked = async (
t,
vaultNotifier,
lockedValue,
asset,
) => {
const notification = await E(vaultNotifier).getUpdateSince();
const lockedAmount = notification.value.locked;

t.deepEqual(lockedAmount, t.context.aeth.make(lockedValue));
t.deepEqual(lockedAmount, asset.make(lockedValue));
};

export const assertVaultDebtSnapshot = async (t, vaultNotifier, wantMinted) => {
Expand Down Expand Up @@ -139,15 +149,15 @@ export const assertVaultFactoryRewardAllocation = async (
});
};

export const assertCollateralProceeds = async (t, seat, colWanted) => {
export const assertCollateralProceeds = async (t, seat, colWanted, issuer) => {
const { Collateral: withdrawnCol } = await E(seat).getFinalAllocation();
const proceeds4 = await E(seat).getPayouts();
t.deepEqual(withdrawnCol, colWanted);

const collateralWithdrawn = await proceeds4.Collateral;
t.truthy(
AmountMath.isEqual(
await E(t.context.aeth.issuer).getAmountOf(collateralWithdrawn),
await E(issuer).getAmountOf(collateralWithdrawn),
colWanted,
),
);
Expand Down
Loading
Loading