Skip to content

Commit

Permalink
lilalo
Browse files Browse the repository at this point in the history
  • Loading branch information
Astodialo committed Nov 4, 2024
1 parent 9dc85f3 commit f97ce9f
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 9 deletions.
111 changes: 111 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 37 additions & 9 deletions test/Bread.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ contract BreadTest is Test {
IERC20 public dai;
IERC20 public aDai;
address public constant admin =
0x23b4f73FB31e89B27De17f9c5DE2660cc1FB0CdF;
0x6A148b997e6651237F2fCfc9E30330a6480519f0;
address public constant signer =
0x4B5BaD436CcA8df3bD39A095b84991fAc9A226F1;
address public constant DAI_HOLDER =
0x0405e31AB5C379BCB710D34e500E009bbB79f584;
0x5Fc0c8BeACfD0a0259B656eabcfE5b39fDe834cc;
EIP173Proxy public breadProxy;
Bread public bread;

function setUp() public {
emit log("Setup...");
vm.startPrank(admin);
address breadAddress = address(
new Bread(
0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063,
Expand All @@ -31,26 +33,52 @@ contract BreadTest is Test {
0x929EC64c34a17401F460460D4B9390518E5B473e
)
);
emit log("Contract deploed...");

breadProxy = new EIP173Proxy(
breadAddress,
address(this),
bytes("")
);

emit log("Proxy deploed...");

vm.stopPrank();
bread = Bread(address(breadProxy));
vm.startPrank(admin);
bread.initialize("Breadchain Stablecoin", "BREAD");
vm.stopPrank();

dai = IERC20(0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063);
aDai = IERC20(0x82E64f49Ed5EC1bC6e43DAD4FC8Af9bb3A2312EE);

emit log("DAI and aDAI addresses set");
// get some DAI from some acct
vm.startPrank(DAI_HOLDER);
dai.transfer(admin, dai.balanceOf(DAI_HOLDER)/4);
dai.transfer(signer, dai.balanceOf(DAI_HOLDER)/4);
uint256 daiHolderBalance = dai.balanceOf(DAI_HOLDER);
emit log_uint(daiHolderBalance);
dai.transfer(admin, daiHolderBalance/4);
dai.transfer(signer, daiHolderBalance/4);
emit log_uint(dai.balanceOf(admin));
emit log_uint(dai.balanceOf(signer));
vm.stopPrank();

vm.deal(signer, 10 ether);
vm.startPrank(signer);
(bool sent, ) = admin.call{value: 10 ether}("");
require(sent, "ETH transfer failed");
vm.stopPrank();
vm.deal(admin, 10 ether);
}
function test_mint() public {
uint256 daiBefore = dai.balanceOf(signer);
uint256 breadBefore = bread.balanceOf(signer);

vm.prank(signer);
dai.approve(address(bread), daiBefore / 10);
bread.mint(daiBefore / 10, signer);

uint256 daiAfter = dai.balanceOf(signer);
uint256 breadAfter = bread.balanceOf(signer);

assertEq(breadBefore, 0);
assertGt(daiBefore, daiAfter);
assertGt(breadAfter, breadBefore);
assertEq(breadAfter, daiBefore - daiAfter);
}
}

0 comments on commit f97ce9f

Please sign in to comment.