Skip to content

Commit

Permalink
Merge pull request #199 from Cyfrin/dev
Browse files Browse the repository at this point in the history
dev --> main
  • Loading branch information
solhosty authored Sep 10, 2024
2 parents 2133abd + 69c6ffe commit 4b34127
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ Pfeww! Great now we can test points 2 and 3 indicated above:
Add the following test in `FundMe.t.sol`:

```javascript
function testFundUpdatesFundDataStrucutre() public {
function testFundUpdatesFundDataStructure() public {
fundMe.fund{value: 10 ether}();
uint256 amountFunded = fundMe.getAddressToAmountFunded(msg.sender);
assertEq(amountFunded, 10 ether);
}
```

Run `forge test --mt testFundUpdatesFundDataStrucutre` in your terminal.
Run `forge test --mt testFundUpdatesFundDataStructure` in your terminal.

Aaaand it fails! Why does it fail? Let's try it again, but this time put `address(this)` instead of `msg.sender`. Now it passed, but we still don't quite get why.

Expand Down Expand Up @@ -93,25 +93,25 @@ To further increase the readability of our contract, let's avoid using a magic n
Back to our test, add the following test in `FundMe.t.sol`:

```javascript
function testFundUpdatesFundDataStrucutre() public {
function testFundUpdatesFundDataStructure() public {
vm.prank(alice);
fundMe.fund{value: SEND_VALUE}();
uint256 amountFunded = fundMe.getAddressToAmountFunded(alice);
assertEq(amountFunded, SEND_VALUE);
}
```

Finally, now let's run `forge test --mt testFundUpdatesFundDataStrucutre` again.
Finally, now let's run `forge test --mt testFundUpdatesFundDataStructure` again.

It fails ... again!

But why? Let's call `forge test --mt testFundUpdatesFundDataStrucutre -vvv` to get more information about where and why it fails.
But why? Let's call `forge test --mt testFundUpdatesFundDataStructure -vvv` to get more information about where and why it fails.

```
Ran 1 test for test/FundMe.t.sol:FundMeTest
[FAIL. Reason: EvmError: Revert] testFundUpdatesFundDataStrucutre() (gas: 16879)
[FAIL. Reason: EvmError: Revert] testFundUpdatesFundDataStructure() (gas: 16879)
Traces:
[16879] FundMeTest::testFundUpdatesFundDataStrucutre()
[16879] FundMeTest::testFundUpdatesFundDataStructure()
├─ [0] VM::prank(alice: [0x328809Bc894f92807417D2dAD6b7C998c1aFdac6])
│ └─ ← [Return]
├─ [0] FundMe::fund{value: 100000000000000000}()
Expand Down Expand Up @@ -141,7 +141,7 @@ Declare the `STARTING_BALANCE` as a constant variable up top:
uint256 constant STARTING_BALANCE = 10 ether;
```

Let's run `forge test --mt testFundUpdatesFundDataStrucutre` again.
Let's run `forge test --mt testFundUpdatesFundDataStructure` again.

And now it passes. Congratulations!

Expand Down

0 comments on commit 4b34127

Please sign in to comment.