From f0191909a247079c9746dcc003745feb67588e63 Mon Sep 17 00:00:00 2001 From: The3D Date: Fri, 25 Sep 2020 11:51:35 +0200 Subject: [PATCH] Added more setUseReserveAsCollateral() scenarios tests --- .../scenarios/set-use-as-collateral.json | 97 ++++++++++++++++++- test/scenario.spec.ts | 2 +- 2 files changed, 95 insertions(+), 4 deletions(-) diff --git a/test/helpers/scenarios/set-use-as-collateral.json b/test/helpers/scenarios/set-use-as-collateral.json index 614c8ddb..871a78b9 100644 --- a/test/helpers/scenarios/set-use-as-collateral.json +++ b/test/helpers/scenarios/set-use-as-collateral.json @@ -43,7 +43,7 @@ ] }, { - "description": "User 1 Deposits 2 ETH, disables ETH as collateral, borrows 400 DAI (revert expected)", + "description": "User 1 Deposits 2 WETH, disables WETH as collateral, borrows 400 DAI (revert expected)", "actions": [ { "name": "mint", @@ -96,7 +96,7 @@ ] }, { - "description": "User 1 enables ETH as collateral, borrows 400 DAI", + "description": "User 1 enables WETH as collateral, borrows 400 DAI", "actions": [ { "name": "setUseAsCollateral", @@ -120,7 +120,7 @@ ] }, { - "description": "User 1 disables ETH as collateral (revert expected)", + "description": "User 1 disables WETH as collateral (revert expected)", "actions": [ { "name": "setUseAsCollateral", @@ -134,6 +134,97 @@ "revertMessage": "User deposit is already being used as collateral" } ] + }, + { + "description": "User 1 Deposits 1000 LEND, disables WETH as collateral. Should revert as 1000 LEND are not enough to cover the debt (revert expected)", + "actions": [ + { + "name": "mint", + "args": { + "reserve": "LEND", + "amount": "1000", + "user": "1" + }, + "expected": "success" + }, + { + "name": "approve", + "args": { + "reserve": "LEND", + "user": "1" + }, + "expected": "success" + }, + { + "name": "deposit", + "args": { + "reserve": "LEND", + + "amount": "1000", + "user": "1" + }, + "expected": "success" + }, + { + "name": "setUseAsCollateral", + "args": { + "reserve": "WETH", + + "user": "1", + "useAsCollateral": "false" + }, + "expected": "revert" + } + ] + }, + { + "description": "User 1 Deposits 64000 more LEND (enough to cover the DAI debt), disables WETH as collateral", + "actions": [ + { + "name": "mint", + "args": { + "reserve": "LEND", + "amount": "64000", + "user": "1" + }, + "expected": "success" + }, + { + "name": "deposit", + "args": { + "reserve": "LEND", + + "amount": "64000", + "user": "1" + }, + "expected": "success" + }, + { + "name": "setUseAsCollateral", + "args": { + "reserve": "WETH", + + "user": "1", + "useAsCollateral": "false" + }, + "expected": "success" + } + ] + }, + { + "description": "User 1 disables LEND as collateral (revert expected)", + "actions": [ + { + "name": "setUseAsCollateral", + "args": { + "reserve": "LEND", + + "user": "1", + "useAsCollateral": "false" + }, + "expected": "User deposit is already being used as collateral" + } + ] } ] } diff --git a/test/scenario.spec.ts b/test/scenario.spec.ts index 54fe7433..3bff8c6b 100644 --- a/test/scenario.spec.ts +++ b/test/scenario.spec.ts @@ -10,7 +10,7 @@ import {executeStory} from './helpers/scenario-engine'; const scenarioFolder = './test/helpers/scenarios/'; -const selectedScenarios: string[] = []; +const selectedScenarios: string[] = ['set-use-as-collateral.json']; fs.readdirSync(scenarioFolder).forEach((file) => { if (selectedScenarios.length > 0 && !selectedScenarios.includes(file)) return;