diff --git a/test/fifsregistrar_test.js b/test/fifsregistrar_test.js index 6926f75c..bb1f01dd 100755 --- a/test/fifsregistrar_test.js +++ b/test/fifsregistrar_test.js @@ -29,26 +29,16 @@ describe('FIFSRegistrar', function() { return utils.deployENSAsync(accounts[0]) .then(function(_ens) { ens = _ens; - return new Promise(function(resolve, reject) { - web3.eth.contract(JSON.parse(registrarCode.interface)).new( + return utils.promisifyContractFactory( + web3.eth.contract(JSON.parse(registrarCode.interface))) + .newAsync( ens.address, 0, { from: accounts[0], data: registrarCode.bytecode, gas: 4700000 - }, - function(err, contract) { - if (err) { - reject(err); - } else if (typeof contract.address !== "undefined") { - resolve(contract); - } else { - // There is to hope that reject or resolve is called - } }); - - }); }) .then(contract => { registrar = Promise.promisifyAll(contract); diff --git a/test/utils.js b/test/utils.js index c054a2db..f9499ce8 100755 --- a/test/utils.js +++ b/test/utils.js @@ -62,5 +62,24 @@ module.exports = { }); }, web3: web3, - TestRPC: TestRPC + TestRPC: TestRPC, + promisifyContractFactory: function(contractFactory) { + contractFactory.newAsync = function() { + var args = arguments; + return new Promise(function(resolve, reject) { + args[args.length] = function(err, contract) { + if (err) { + reject(err); + } else if (typeof contract.address !== "undefined") { + resolve(contract); + } else { + // There is to hope that reject or resolve is called + } + }; + args.length++; + contractFactory.new.apply(contractFactory, args); + }); + }; + return contractFactory; + } };