@@ -5,7 +5,7 @@ import {Test} from "forge-std/Test.sol";
55import {SecureBank} from "../src/security.sol " ;
66import {AttackContract} from "../src/Attack.sol " ;
77
8- contract SecureBankTest is Test {
8+ contract AttackContractTest is Test {
99 SecureBank bank;
1010 AttackContract attack;
1111 address user1;
@@ -23,24 +23,14 @@ contract SecureBankTest is Test {
2323 bank.deposit {value: 10 ether }();
2424 }
2525
26- function testDepositAndWithdraw () public {
27- uint256 beforeBalance = user1.balance;
28- vm.prank (user1);
29- bank.withdraw (5 ether);
30- uint256 afterBalance = user1.balance;
31-
32- assertGt (afterBalance, beforeBalance);
33- assertEq (bank.balances (user1), 5 ether);
34- }
35-
36- function testRevertsReentrancyGuard () public {
26+ function testAttackReverts () public {
3727 vm.deal (attacker, 1 ether);
3828 vm.prank (attacker);
39- vm.expectRevert ("No reentrancy " );
29+ vm.expectRevert ("Transfer failed " );
4030 attack.attack {value: 1 ether }();
4131 }
4232
43- function testFundsIntactAfterAttack () public {
33+ function testFundsSafe () public {
4434 vm.deal (attacker, 1 ether);
4535 vm.prank (attacker);
4636 try attack.attack {value: 1 ether }() {} catch {}
@@ -49,7 +39,7 @@ contract SecureBankTest is Test {
4939 assertGe (bankBalance, 10 ether);
5040 }
5141
52- function testDepositAndWithdraw () public {
42+ function testWithdrawWorks () public {
5343 uint256 beforeBalance = user1.balance;
5444 vm.prank (user1);
5545 bank.withdraw (5 ether);
@@ -59,7 +49,7 @@ contract SecureBankTest is Test {
5949 assertEq (bank.balances (user1), 5 ether);
6050 }
6151
62- function testRejectsWithdraw () public {
52+ function testOverdraftFails () public {
6353 vm.prank (user1);
6454 vm.expectRevert ("Insufficient balance " );
6555 bank.withdraw (999 ether);
0 commit comments