diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d096e8f --- /dev/null +++ b/flake.lock @@ -0,0 +1,111 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "foundry": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1730625090, + "narHash": "sha256-lWfkkj+GEUM0UqYLD2Rx3zzILTL3xdmGJKGR4fwONpA=", + "owner": "shazow", + "repo": "foundry.nix", + "rev": "1c6a742bcbfd55a80de0e1f967a60174716a1560", + "type": "github" + }, + "original": { + "owner": "shazow", + "ref": "monthly", + "repo": "foundry.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1666753130, + "narHash": "sha256-Wff1dGPFSneXJLI2c0kkdWTgxnQ416KE6X4KnFkgPYQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f540aeda6f677354f1e7144ab04352f61aaa0118", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1730272153, + "narHash": "sha256-B5WRZYsRlJgwVHIV6DvidFN7VX7Fg9uuwkRW9Ha8z+w=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "foundry": "foundry", + "nixpkgs": "nixpkgs_2", + "utils": "utils" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/test/Bread.t.sol b/test/Bread.t.sol index cee7ada..9d20c36 100644 --- a/test/Bread.t.sol +++ b/test/Bread.t.sol @@ -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, @@ -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); } }