0

1_initial_migration.js file:

const Globals = require("../globals.js");

const Migrations = artifacts.require("Migrations");
const Test = artifacts.require("Test");

module.exports = async function (deployer) {
    await deployer.deploy(Migrations);
    await deployer.deploy(Test);
    console.log("deployed migrations? ", Test.isDeployed());
    await Globals.initEnv(deployer);
}

globals.js file:

const Test = artifacts.require("Test");

module.exports.initEnv = async function (pDeployer) {
    console.log("deployed globals? ", Test.isDeployed());
}

When I run migration it shows:

deployed migrations?  true
deployed globals?  false

Error: Test has no network configuration for its current network id (1273553293564).

If I run test:

const Test = artifacts.require("Test");

contract("test", async accounts =>{
    before(async()=>{
        console.log("deployed test? ", Test.isDeployed());
    });
})

It shows:

deployed migrations?  true
deployed globals?  false
deployed test?  true

How can I make the init from the external file working? My goal is to make the entire environment setup in one file and call it in every test and exec.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.