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

Use deployments.fixture repeatedly #528

Open
cody6299 opened this issue Mar 29, 2024 · 1 comment
Open

Use deployments.fixture repeatedly #528

cody6299 opened this issue Mar 29, 2024 · 1 comment

Comments

@cody6299
Copy link

cody6299 commented Mar 29, 2024

Here is my question for simple:
I have two deploy script, let's say deployA and deployB, to deploy two contracts, let's say contractA, and contractB.
and the deployB.js will use contractA.
and a test script, use deployments.fixture respectively to test the deploy scripts.

deployA.js:

module.exports = async function ({ ethers, getNamedAccounts, deployments, getChainId, getUnnamedAccounts }) {
    const { deploy, get, log } = deployments;
    const { deployer } = await getNamedAccounts();
    await deploy('contractA', {
        from: deployer, args: [], log: true, skipIfAlreadyDeployed: true,
    });
};

module.exports.tags = ['deployA', '1'];
module.exports.dependencies = [];

deployB.js

module.exports = async function ({ ethers, getNamedAccounts, deployments, getChainId, getUnnamedAccounts }) {
    const { deploy, get, log } = deployments;
    const { deployer } = await getNamedAccounts();
    let contractA = await deployments.getOrNull('contractA');
     console.log('here we get contractA  ' + (contrtactA != null));
    await deploy('contractB', {
        from: deployer, args: [], log: true, skipIfAlreadyDeployed: true,
    });
};

module.exports.tags = ['deployB, '1'];
module.exports.dependencies = [];

test.js

describe("Test", () => {
    before(async function () {
    });

    beforeEach(async function () {
    });

    it("DeployA", async function() {
        await deployments.fixture(["deployA"]);
    });
    it("DeployB", async function() {
        let contractA = await deployments.getOrNull('contractA');
        console.log('here we get contractA  ' + (contrtactA != null));
        await deployments.fixture(["deployB"]);
    });
});

The question is:

the output of test.js is:

  • have we get contractA true

the output of deployB.js is:

  • have we get contractA false

I'm just curious, why I can't get contractA in deployB.js. what's internal mechanism.

Of course, this is just a test, deploy work correctly when I deploy it.

@wighawag
Copy link
Owner

deployments.fixture revert back and execute the deploy script
so whatever was available before is reset

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