foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.33k stars 1.76k forks source link

`DAPP_TEST_ADDRESS` assigns address to `msg.sender`, not `address(this` #1018

Closed lucas-manuel closed 1 year ago

lucas-manuel commented 2 years ago

Component

Forge

Have you ensured that all of these are up to date?

What version of Foundry are you on?

forge 0.1.0 (77882ab 2022-03-22T00:21:29.105530+00:00)

What command(s) is the bug in?

forge test

Operating System

macOS (M1)

Describe the bug

In test.sh at line 23, DAPP_TEST_ADDRESS is used. This is in a refactor from dapptools to foundry where the contract test address itself needs to be a certain address to interact with permissioned mainnet contracts.

It can be seen on lines 100 and 101 that msg.sender and address(this) are logged, and produce the following output:

    ├─ emit log_named_address(key: "msg.sender         ", val: 0xa6ccb9483e3e7a737e3a4f5b72a1ce51838ba122)
    ├─ emit log_named_address(key: "address(this)      ", val: 0xb8df2f8992e3855c99db39a7fce7aaeacb347c49)

0xa6ccb9483e3e7a737e3a4f5b72a1ce51838ba122 is the desired value for address(this).

I believe it is because of this line here: https://github.com/gakonst/foundry/blob/0cde8701496dff9f28c9025fc8c8721ba55ece7c/config/src/lib.rs#L1040

lucas-manuel commented 1 year ago

Close-able? @mds1