I have two Contracts - a contract with a single constructor argument (ContractB), and a launcher that deploys new instances (Launcher).
Using Truffle for testing how can I link the contracts without deploying contract B, given that contract B will return an error if deployed without prams
Error: ContractB contract constructor expected 1 arguments, received 0
Here is the link to Git repository
deploy_contracts.js
var Launcher = artifacts.require("./Launcher.sol");
var ContractB = artifacts.require("./ContractB.sol");
module.exports = function(deployer) {
deployer.deploy(ContractB);
deployer.link(ContractB, Launcher);
deployer.deploy(Launcher);
};
Test File
var Launcher = artifacts.require("./Launcher.sol");
contract('Launcher', function(accounts) {
it("Launcher Deploy", function() {
return Launcher.deployed().then(function(instance) {
console.log(instance)
})
});
});
Launcher.sol
pragma solidity ^0.4.18;
import "./ContractB.sol";
contract launcher {
function launch() public returns(address) {
ContractB contractLocation = new ContractB(msg.sender);
return(contractLocation);
}
}
ContractB.sol
pragma solidity ^0.4.18;
contract ContractB {
address public owner;
constructor(address addr) public {
owner = addr;
}
function get() public view returns(address) {
return(owner);
}
}