From 633ee84b10826c72d6eccb28397b2b21614dea72 Mon Sep 17 00:00:00 2001 From: 0xbigz <83473873+0xbigz@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:22:39 -0400 Subject: [PATCH] bigz/fix-ts-tests-2 --- test-scripts/single-anchor-test.sh | 2 +- tests/liquidateSpotSocialLoss.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test-scripts/single-anchor-test.sh b/test-scripts/single-anchor-test.sh index ac5711ff4..dd2195166 100644 --- a/test-scripts/single-anchor-test.sh +++ b/test-scripts/single-anchor-test.sh @@ -4,7 +4,7 @@ if [ "$1" != "--skip-build" ] cp target/idl/drift.json sdk/src/idl/ fi -test_files=(liquidityProvider.ts) +test_files=(liquidateSpotSocialLoss.ts) for test_file in ${test_files[@]}; do ANCHOR_TEST_FILE=${test_file} anchor test --skip-build || exit 1; diff --git a/tests/liquidateSpotSocialLoss.ts b/tests/liquidateSpotSocialLoss.ts index b2f8c9336..97678292c 100644 --- a/tests/liquidateSpotSocialLoss.ts +++ b/tests/liquidateSpotSocialLoss.ts @@ -307,21 +307,25 @@ describe('liquidate spot w/ social loss', () => { ) ); - const depositAmountBefore = getTokenAmount( + const dep1 = getTokenAmount( spotMarket1Before.depositBalance, spotMarket1Before, SpotBalanceType.DEPOSIT - ).sub(borrowDecrease); + ); + const depositAmountBefore = dep1.sub(borrowDecrease); const currentDepositAmount = getTokenAmount( spotMarket1.depositBalance, spotMarket1, SpotBalanceType.DEPOSIT ); + console.log(currentDepositAmount.toString(), depositAmountBefore.toString(), '(', dep1.toString(), ')'); const interestOfUpdate = currentDepositAmount.sub(depositAmountBefore); console.log('interestOfUpdate:', interestOfUpdate.toString()); - assert(interestOfUpdate.eq(ZERO)); + assert(interestOfUpdate.lte(ZERO)); + assert(interestOfUpdate.gte(new BN(-1))); + }); it('resolve bankruptcy', async () => {