From 187735c69ba73d9c3f520dc162d1fbeb4e6e8221 Mon Sep 17 00:00:00 2001 From: Sam MacPherson Date: Wed, 3 Jul 2024 17:39:13 +0900 Subject: [PATCH] finish tests --- test/MigrationActions.t.sol | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/MigrationActions.t.sol b/test/MigrationActions.t.sol index 8b526d5..4e1609c 100644 --- a/test/MigrationActions.t.sol +++ b/test/MigrationActions.t.sol @@ -396,3 +396,48 @@ contract MigrationActionsMigrateSDAISharesToSNSTTests is MigrationActionsBase { } } + +contract MigrationActionsDowngradeNSTToDAITests is MigrationActionsBase { + + function test_downgradeNSTToDAI_insufficientBalance_boundary() public { + nst.approve(address(actions), 100e18); + nst.mint(address(this), 100e18 - 1); + + vm.expectRevert(stdError.arithmeticError); + actions.downgradeNSTToDAI(receiver, 100e18); + + nst.mint(address(this), 1); + + actions.downgradeNSTToDAI(receiver, 100e18); + } + + function test_downgradeNSTToDAI_insufficientApproval_boundary() public { + nst.approve(address(actions), 100e18 - 1); + nst.mint(address(this), 100e18); + + vm.expectRevert(stdError.arithmeticError); + actions.downgradeNSTToDAI(receiver, 100e18); + + nst.approve(address(actions), 100e18); + + actions.downgradeNSTToDAI(receiver, 100e18); + } + + function test_downgradeNSTToDAI() public { + nst.approve(address(actions), 100e18); + nst.mint(address(this), 100e18); + + assertEq(dai.balanceOf(address(this)), 0); + assertEq(nst.balanceOf(address(this)), 100e18); + assertEq(dai.balanceOf(receiver), 0); + assertEq(nst.balanceOf(receiver), 0); + + actions.downgradeNSTToDAI(receiver, 100e18); + + assertEq(dai.balanceOf(address(this)), 0); + assertEq(nst.balanceOf(address(this)), 0); + assertEq(dai.balanceOf(receiver), 100e18); + assertEq(nst.balanceOf(receiver), 0); + } + +}