Skip to content

Commit

Permalink
test: add test for vaultsAPI.withdrawAllCollateral
Browse files Browse the repository at this point in the history
  • Loading branch information
bvotteler committed Mar 1, 2024
1 parent f3736c2 commit eceeac0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/integration/parachain/staging/sequential/vaults.partial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,27 @@ export const vaultsTests = () => {
}
});

// PRECONDITION: vault_2 must have some collateral in KSM or DOT
it("should be able to withdraw all collateral", async () => {
const interBtcAPI = new DefaultInterBtcApi(api, "regtest", vault_2, ESPLORA_BASE_PATH);
// const currencyTicker = collateralCurrency.ticker;
const collateralCurrency = getCorrespondingCollateralCurrenciesForTests(governanceCurrency)[0];
const accountId = newAccountId(api, vault_2.address);

const collateralAmountBefore = await interBtcAPI.vaults.getCollateral(accountId, collateralCurrency);

// method under test
await submitExtrinsic(interBtcAPI, await interBtcAPI.vaults.withdrawAllCollateral(collateralCurrency));

const collateralAmountAfter = await interBtcAPI.vaults.getCollateral(accountId, collateralCurrency);

const differenceAmount = collateralAmountBefore.sub(collateralAmountAfter);
expect(differenceAmount.toBig().toNumber()).toBeGreaterThan(0);

// replenish
await submitExtrinsic(interBtcAPI, interBtcAPI.vaults.depositCollateral(differenceAmount));
});

it("should getLiquidationCollateralThreshold", async () => {
for (const collateralCurrency of collateralCurrencies) {
const currencyTicker = collateralCurrency.ticker;
Expand Down

0 comments on commit eceeac0

Please sign in to comment.