8

I made my custom library and try to using on my own project.
Below is the 2_deploy_contracts.js

module.exports =  async(deployer, netowrk) => {
await deployer.deploy(OptionStorage, ownerAddress);
await deployer.deploy(LDerivativeFactory);
await deployer.link(LDerivativeFactory, DerivativeFactory);
await deployer.deploy(DerivativeFactory, OptionStorage.address, XToken);
};

and in test cases, I am trying to use it as

beforeEach(async () => {
    optionStorage = await OptionStorage.new(owner);
    //library = await Library.new();
    //DerivativeFactory.link('LDerivativeFactory',library.address);
    derivativeFactory = await DerivativeFactory.new(optionStorage.address, quoteToken.address, { from : owner, gas : 50000 });
});

but in running the test cases I am facing the error

Error: DerivativeFactory contains unresolved libraries. You must deploy and link the following libraries before you can deploy a new version of DerivativeFactory: LDerivativeFactory

How to resolve it? I try to link in the test cases as well then I ended up with different error

Error: Error: base fee exceeds gas limit

Any help is admirable

4
  • 2
    modify your qus in more detail. Like which class is inherit and what is library class? Feb 12, 2018 at 13:26
  • Truffle have some issues using async/await in migrations scripts github.com/trufflesuite/truffle/issues/501. Perhaps in your case that causes problems in your tests.
    – Ismael
    Feb 13, 2018 at 17:09
  • @Ismael I don't think so it gets deployed by using async/await but not work with test cases but when I try with .then() it throw the error in deployment itself Error: VM Exception while processing transaction: revert Feb 14, 2018 at 8:03
  • @Ismael you are right when I debug both tx (one from async and from .then()) both give me no source code found the error. I don't understand why? at the end of the day, both ways are not helping me. Feb 14, 2018 at 8:11

1 Answer 1

11

You should use the recommended fix in issue #501, the problem that it causes is that the truffle's artifacts are not updated in the right order.

async function doDeploy(deployer, network) {
    await deployer.deploy(OptionStorage, ownerAddress);
    await deployer.deploy(LDerivativeFactory);
    await deployer.link(LDerivativeFactory, DerivativeFactory);
    await deployer.deploy(DerivativeFactory, OptionStorage.address, XToken);
}


module.exports = (deployer, network) => {
    deployer.then(async () => {
        await doDeploy(deployer, network);
    });
};

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.