Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Methods with same names in different contracts are getting merged #231

Closed
CSY54 opened this issue May 18, 2024 · 1 comment
Closed

Methods with same names in different contracts are getting merged #231

CSY54 opened this issue May 18, 2024 · 1 comment

Comments

@CSY54
Copy link

CSY54 commented May 18, 2024

I'm trying to deploy two contracts with a factory that have the same method name.
However, I found the gas report putting two methods with the same name from two different contracts into one entry.

By adding ./test/projects/options/test/differentContractWithSameMethodName.ts (code below)

// eslint-disable-next-line import/no-extraneous-dependencies
import { Contract } from "ethers";
import { ethers } from "hardhat";

describe("setValue", function () {
  let Factory;
  let VersionA;
  let VersionB;
  let factory: Contract;
  let versionA: Contract;
  let versionB: Contract;

  before(async function () {
    Factory = await ethers.getContractFactory("Factory");
    VersionA = await ethers.getContractFactory("VersionA");
    VersionB = await ethers.getContractFactory("VersionB");

    factory = await Factory.deploy();

    await factory.deployVersionA();
    versionA = VersionA.attach(await factory.versionA());

    await factory.deployVersionB();
    versionB = VersionB.attach(await factory.versionB());
  });

  it("Calling both versionA.setValue and versionB.setValue", async function () {
    await versionA.setValue();
    await versionB.setValue();
  });
});

running npx mocha test/integration/options.a.ts, and by commenting out the setValue(), I found

scenario output expected
not calling versionA.setValue() and versionB.setValue() (1, 1) (1, 1)
call versionA.setValue() only (2, 1) (2, 1)
call versionB.setValue() only (2, 1) (1, 2)
call both versionA.setValue() and versionB.setValue() (3, 1) (2, 2)

Note: The pair in output and expected field above means the # calls field from the output table of VersionA setValue() and VersionB setValue()

@cgewecke
Copy link
Owner

@CSY54 Thanks so much for reporting this and for your reproduction case - have patched the problem via #234 and published it in v2.2.0.

Hopefully this resolves the issue but just ping if not and I will re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants