Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Changes to imported contract do not cause importing contract to get recompiled #384

Closed
cryptophonic opened this issue Mar 29, 2017 · 1 comment

Comments

@cryptophonic
Copy link

Issue

When a parent contract imports and dynamically creates a child contract in code and the child contract gets incrementally changed, Truffle is not rebuilding the parent contract.

Steps to Reproduce

Ignoring obvious leaks in the following test code, create two simple contracts and the following migration:

Parent.sol

pragma solidity ^0.4.4;

import "./Child.sol";

contract Parent {

    address public child;

    function newChild(uint a, uint b) {
        child = new Child(a, b);
    }

    function doChildAction() constant returns (uint) {
        return Child(child).doAction();
    }

}

Child.sol

pragma solidity ^0.4.4;

contract Child {

    uint public a;
    uint public b;

    function Child(uint _a, uint _b) {
        a = _a;
        b = _b;
    }

    function doAction() constant returns (uint) {
        return a + b;
    }

}

2_deploy_contracts.js

var Parent = artifacts.require("./Parent.sol");
var Child = artifacts.require("./Child.sol");

module.exports = function(deployer) {
  deployer.deploy(Parent);
  deployer.deploy(Child);
};
  1. From the console, compile and migrate the contracts and create a child by calling Parent.newChild(10, 2). Verify that Parent.doChildAction() returns 12.

  2. In the source file Child.sol, change the doAction() code from 'return a+b' to 'return a-b'.

  3. Recompile from the console: "compile". Notice that only Child.sol gets rebuilt.

  4. 'migrate --reset' and repeat step 1. Verify that Parent.doChildAction() still returns 12.

Expected Behavior

  1. Step 3 should have recompiled Parent.sol since it needs the modified Child binary code for new.

  2. Step 4 should have returned 8, not 12.

Environment

  • Operating System: Linux Mint 17.2 (Ubuntu / Debian compatible)
  • Truffle version: v3.2.1
  • Ethereum client: EthereumJS TestRPC v3.0.3
  • npm version: 3.10.8
@tcoulter
Copy link
Contributor

This should be fixed in Truffle 3.4.3. Let us know if you run into any more errors. Thanks!

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

No branches or pull requests

2 participants