From 56e59d814b60743c25ea02142adc179bb7198528 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 3 Aug 2015 21:01:15 -0400 Subject: [PATCH] get contract --- lib/chain_manager.js | 4 ++++ test/chain_manager.js | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/chain_manager.js b/lib/chain_manager.js index 41dd211a..517a22d5 100644 --- a/lib/chain_manager.js +++ b/lib/chain_manager.js @@ -42,5 +42,9 @@ ChainManager.prototype.addContract = function(contractName, code, address) { } } +ChainManager.prototype.getContract = function(code) { + return this.currentChain.contracts[sha3_256(code)]; +} + module.exports = ChainManager; diff --git a/test/chain_manager.js b/test/chain_manager.js index c1426612..83a63d8d 100644 --- a/test/chain_manager.js +++ b/test/chain_manager.js @@ -30,4 +30,15 @@ describe('embark.chain_manager', function() { }); + describe('#getContract', function() { + + it('should a contract in the chain', function() { + var contract = chainManager.getContract("123456"); + + assert.equal(contract.name, "Foo"); + assert.equal(contract.address, "0x123"); + }); + + }); + });