Check every state for withdraw eligibility
@@ -680,8 +680,16 @@ describe("DepositUtils", async function() {
await restoreSnapshot()
})
- it("Correctly withdraws withdrawable balance at end-state", async () => {
- await testDeposit.setState(states.LIQUIDATED)
+ it("Correctly withdraws withdrawable balance at end-states", async () => {
+ const endStates = [
+ states.LIQUIDATED,
+ states.REDEEMED,
+ states.FAILED_SETUP
+ ]
+
+ for(let i = 0; i < endStates.length; i++){
+ await createSnapshot()
+ await testDeposit.setState(endStates[i])
const value = new BN(web3.utils.toWei("0.1"))
const beneficiary = accounts[1]
const initialBalance = await web3.eth.getBalance(beneficiary)
@@ -697,15 +705,32 @@ describe("DepositUtils", async function() {
expect(withdrawable).to.eq.BN(0)
expect(finalBalance).to.gt.BN(initialBalance)
+ await restoreSnapshot()
+ }
})
it("Reverts if not in end-state", async () => {
- await testDeposit.setState(states.ACTIVE)
+ const notEndStates = [
+ states.START,
+ states.AWAITING_SIGNER_SETUP,
+ states.AWAITING_BTC_FUNDING_PROOF,
+ states.ACTIVE,
+ states.AWAITING_WITHDRAWAL_SIGNATURE,
+ states.AWAITING_WITHDRAWAL_PROOF,
+ states.COURTESY_CALL,
+ states.FRAUD_LIQUIDATION_IN_PROGRESS,
+ states.LIQUIDATION_IN_PROGRESS
+ ]
+
+ for(let i = 0; i < notEndStates.length; i++){
+
+ await testDeposit.setState(notEndStates[i])
await expectRevert(
testDeposit.withdrawFunds(),
- "Contact not yet terminated",
+ "Contract not yet terminated",
)
+ }
})
it("Reverts if there is no available balance", async () => {
await testDeposit.setState(states.LIQUIDATED)
