Skip to content

Commit 56e59d8

Browse files
committed
get contract
1 parent fab0df5 commit 56e59d8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/chain_manager.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,9 @@ ChainManager.prototype.addContract = function(contractName, code, address) {
4242
}
4343
}
4444

45+
ChainManager.prototype.getContract = function(code) {
46+
return this.currentChain.contracts[sha3_256(code)];
47+
}
48+
4549
module.exports = ChainManager;
4650

test/chain_manager.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,15 @@ describe('embark.chain_manager', function() {
3030

3131
});
3232

33+
describe('#getContract', function() {
34+
35+
it('should a contract in the chain', function() {
36+
var contract = chainManager.getContract("123456");
37+
38+
assert.equal(contract.name, "Foo");
39+
assert.equal(contract.address, "0x123");
40+
});
41+
42+
});
43+
3344
});

0 commit comments

Comments
 (0)