1

I'm trying to test a contract that wrote and compiled, and I need to use another deployed contract to test it. I am writing a test for a specific contract and trying to invoke another deployed contract:

contract('Vault', accounts => {
  it('should be able to see the other contract.', async () => {
    const instance = await Vault.deployed()
    const owner = await instance.admin.call()
    assert.equal(owner, accounts[0], `contract owner was not ${accounts[0]}`)
    console.log(await HumanStandardTokenFactory.deployed())
})

which should work, but it I get the error:

Error: HumanStandardTokenFactory has not been deployed to detected network (network/artifact mismatch).

I am using the new truffle develop command instead of TestRPC. When I run migrate, I can see the addresses of all the contracts being populated properly. I installed the contract through EthPM. In the truffle console I can even type:

truffle(develop)> HumanStandardTokenFactory.deployed().then(instance => console.log(instance.address))
0x82d50ad3c1091866e258fd0f1a7cc9674609d254

I'm thinking this has something to do with the "clean-room" environment, but everyone else seems to have gotten past this issue. My migration file is as follows:

const Vault = artifacts.require('./Vault.sol')
const HumanStandardTokenFactory = artifacts.require(
  'tokens/HumanStandardTokenFactory'
)

module.exports = function (deployer) {
  deployer.deploy(HumanStandardTokenFactory)
  deployer.deploy(Vault)
}

Is there any way I can get the deployed version of this contract into my tests?

  • With truffle I'd first try removing the build/ folder. And make a deploy again. It just happened too many times that a broken artifact caused tests failures. – Ismael Nov 16 '17 at 0:41
  • 1. Do you see HumanStandardTokenFactory.json in your build folder? 2. Do you see "Compiling HumanStandardTokenFactory.." in your console output when you run test? – ulu Jan 23 '18 at 12:47
  • @ulu yes to both. I got around it by manually deploying the contracts as part of the test setup. – rhlsthrm Jan 24 '18 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.