Skip to content

Commit

Permalink
merged mint and burn test
Browse files Browse the repository at this point in the history
  • Loading branch information
Astodialo committed Nov 5, 2024
1 parent 8a23c0e commit ed3acee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
nodePackages.ts-node
nodePackages.pnpm

solc_0_8_13
(solc.mkDefault pkgs solc_0_8_13)
#solc_0_8_13
#(solc.mkDefault pkgs solc_0_8_13)

];

Expand Down
23 changes: 16 additions & 7 deletions test/Bread.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ contract BreadTest is Test {

vm.deal(admin, 10 ether);
}
function test_mint() public {
function test_mint_burn() public {
uint256 daiBefore = dai.balanceOf(signer);
uint256 breadBefore = bread.balanceOf(signer);

Expand Down Expand Up @@ -101,17 +101,26 @@ contract BreadTest is Test {
assertGt(breadFinal, breadAfter);
assertEq(breadFinal, breadAfter + (daiBeforeAdmin - daiAfterAdmin));
vm.stopPrank();

// burn
uint256 aDaiBalance = aDai.balanceOf(address(bread));
assertGt(aDaiBalance, 0);
emit log_uint(aDaiBalance);
}
function test_burn() public {
uint256 aDaiBalance = aDai.balanceOf(address(bread));
emit log_uint(aDaiBalance);
//assertGt(aDaiBalance, 0);

vm.prank(admin);
vm.expectRevert("Bread: cannot withdraw collateral");
bread.rescueToken(address(aDai), 1);

uint256 supplyBefore = bread.totalSupply();
uint256 burn_daiBefore = dai.balanceOf(admin);
vm.prank(signer);
bread.burn(supplyBefore, admin);
uint256 supplyAfter = bread.totalSupply();
uint256 burn_daiAfter = dai.balanceOf(admin);

assertGt(supplyBefore, supplyAfter);
assertEq(supplyAfter, 0);
assertGt(burn_daiAfter, burn_daiBefore);
assertEq(burn_daiAfter, burn_daiBefore + supplyBefore);
}
function test_protect_owner_functions() public {
vm.prank(signer);
Expand Down

0 comments on commit ed3acee

Please sign in to comment.