Skip to content

Support library linking in vm.getDeployedCode #6120

@alexanderhawl

Description

@alexanderhawl

Component

Forge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (6ac22df 2023-10-25T00:27:18.529420296Z)

What command(s) is the bug in?

forge test

Operating System

Linux

Describe the bug

I wanna use vm.etch to attach modified Aave v2 LendingPool.sol and ValidationLogic.sol to mainnet in fork environment. I downloaded the contracts of aave v2 in forge test file folder.

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import {Test, console2} from "forge-std/Test.sol";
import "./contracts/protocol/lendingpool/LendingPool.sol";

contract CounterTest is Test {
    string MAINNET_RPC_URL='https://rpc.ankr.com/eth';
address private constant LendingPoolLogic=0x085E34722e04567Df9E6d2c32e82fd74f3342e79;
LendingPool lp;
    
function setUp() public {
        vm.createSelectFork(MAINNET_RPC_URL);
lp=new LendingPool();
bytes memory lpcode =vm.getDeployedCode("LendingPool.sol");
        vm.etch(LendingPoolLogic,lpcode);
}
function testTest() public {}
     

The error message is
[FAIL. Reason: Setup failed: No deployed bytecode for contract. Is it abstract or unlinked?] setUp() (gas: 0)

I searched the issue, found the reason is the linking of library. Is there another way to attach modified LendingPool.sol in mainnet fork?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Completed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions