get contract

This commit is contained in:
Iuri Matias 2015-08-03 21:01:15 -04:00
parent fab0df5c8b
commit 56e59d814b
2 changed files with 15 additions and 0 deletions

View File

@ -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; module.exports = ChainManager;

View File

@ -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");
});
});
}); });