Displaying contract address instead of contract name in Terminal #3594
Replies: 1 comment 5 replies
-
@chainflash I guess you can see the names if you just run // SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import {Test} from "forge-std/Test.sol";
import {VRFCoordinatorV2_5Mock} from "@chainlink/contracts/src/v0.8/vrf/mocks/VRFCoordinatorV2_5Mock.sol";
import {CodeConstants} from "script/HelperConfig.s.sol";
contract ContractForkTest is Test, CodeConstants {
VRFCoordinatorV2_5Mock public coordinator;
function setUp() public {
// Deploy the contract locally on the forked chain
coordinator = new VRFCoordinatorV2_5Mock(MOCK_BASE_FEE, MOCK_GAS_PRICE_LINK, MOCK_WEI_PER_UNIT_LINK);
}
function testExample() public {
// Interact with your contract as usual
// Foundry will now use the local artifact metadata
// to display a friendly name in error messages.
coordinator.fundSubscription(1, 2);
}
} This is failing as we haven't setup subscritpions and all the jazz but if you now run
You will indeed see the name [⠊] Compiling...
No files changed, compilation skipped
Ran 1 test for test/unit/RaffleFork.t.sol:ContractForkTest
[FAIL: InvalidSubscription()] testExample() (gas: 8637)
Traces:
[5229375] ContractForkTest::setUp()
├─ [5161739] → new VRFCoordinatorV2_5Mock@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f
│ ├─ emit ConfigSet()
│ └─ ← [Return] 25411 bytes of code
└─ ← [Stop]
[8637] ContractForkTest::testExample()
├─ [2978] VRFCoordinatorV2_5Mock::fundSubscription(1, 2)
│ └─ ← [Revert] InvalidSubscription()
└─ ← [Revert] InvalidSubscription()
Suite result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 2.48s (126.99µs CPU time)
Ran 1 test suite in 4.30s (2.48s CPU time): 0 tests passed, 1 failed, 0 skipped (1 total tests)
Failing tests:
Encountered 1 failing test in test/unit/RaffleFork.t.sol:ContractForkTest
[FAIL: InvalidSubscription()] testExample() (gas: 8637)
Encountered a total of 1 failing tests, 0 tests succeeded so basically Instead of interacting with an externally deployed instance, deploy the contract as part of your test on the forked chain. This way, the deployment is done using your local artifacts and Foundry can map the address back to the contract name. |
Beta Was this translation helpful? Give feedback.
-
When Patrick checks the error in the terminal it shows the contract name like this:
but for me only the contract address is displayed and I have to manually look up the name for this address:
I tried:
Adding include_contract_names = true in foundry.toml
running forge clean && forge build
testing with forge test --fork-url $SEPOLIA_RPC_URL -vvvvv
running foundryup
But the issue persists. Any solutions?
Beta Was this translation helpful? Give feedback.
All reactions