diff options
author | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-04-10 14:50:24 +0800 |
---|---|---|
committer | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-04-10 14:50:24 +0800 |
commit | 1efd3c26876cb05efcdce073b967088e01b9818b (patch) | |
tree | 146bc02d289dac69e91bde69189d8a6c188f8f73 /web3.eth.contract.js | |
parent | 3e4a9de0b0553230822d439ffd79022fb4839b94 (diff) | |
download | dexon-solidity-1efd3c26876cb05efcdce073b967088e01b9818b.tar dexon-solidity-1efd3c26876cb05efcdce073b967088e01b9818b.tar.gz dexon-solidity-1efd3c26876cb05efcdce073b967088e01b9818b.tar.bz2 dexon-solidity-1efd3c26876cb05efcdce073b967088e01b9818b.tar.lz dexon-solidity-1efd3c26876cb05efcdce073b967088e01b9818b.tar.xz dexon-solidity-1efd3c26876cb05efcdce073b967088e01b9818b.tar.zst dexon-solidity-1efd3c26876cb05efcdce073b967088e01b9818b.zip |
Squashed 'libjsqrc/ethereumjs/' changes from 73b9ed2..4def095
4def095 updated README.md
15b4dbd updated bower && package.json files
0ccc05a web3 in global namespace
ccc59d1 version 0.2.6
9c2c946 Merge branch 'web3' into develop
6763f34 tests for creating new contract with nondefault constructor, added missing files
2ef5efc fixed #70, creating contract with nondefault constructor
dbe4015 Merge branch 'master' into develop
48b351a add gasPrice test and fixed failing uncle tests
7f75f3e fixed gasPrice output
ddec629 fixed getUncle parameter count
1e89ef0 changed to eth_protocolVersion
6add9bd Merge pull request #151 from ethereum/develop
git-subtree-dir: libjsqrc/ethereumjs
git-subtree-split: 4def0958d35cb5b8d92d277423af4d435dd89f16
Diffstat (limited to 'web3.eth.contract.js')
-rw-r--r-- | web3.eth.contract.js | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/web3.eth.contract.js b/web3.eth.contract.js index 0f2fd864..a657545d 100644 --- a/web3.eth.contract.js +++ b/web3.eth.contract.js @@ -1,5 +1,7 @@ var assert = require('assert'); var contract = require('../lib/web3/contract.js'); +var FakeHttpProvider = require('./helpers/FakeHttpProvider'); +var web3 = require('../index'); describe('web3.eth.contract', function() { it('should create simple contract with one method from abi with explicit type name', function () { @@ -20,10 +22,11 @@ describe('web3.eth.contract', function() { } ] }]; + var address = '0x1234567890123456789012345678901234567890'; // when var Con = contract(description); - var myCon = new Con(null); + var myCon = new Con(address); // then assert.equal('function', typeof myCon.test); @@ -48,10 +51,11 @@ describe('web3.eth.contract', function() { } ] }]; + var address = '0x1234567890123456789012345678901234567890'; // when var Con = contract(description); - var myCon = new Con(null); + var myCon = new Con(address); // then assert.equal('function', typeof myCon.test); @@ -90,10 +94,11 @@ describe('web3.eth.contract', function() { } ] }]; + var address = '0x1234567890123456789012345678901234567890'; // when var Con = contract(description); - var myCon = new Con(null); + var myCon = new Con(address); // then assert.equal('function', typeof myCon.test); @@ -134,10 +139,11 @@ describe('web3.eth.contract', function() { } ] }]; + var address = '0x1234567890123456789012345678901234567890'; // when var Con = contract(description); - var myCon = new Con(null); + var myCon = new Con(address); // then assert.equal('function', typeof myCon.test); @@ -162,11 +168,11 @@ describe('web3.eth.contract', function() { } ] }]; - + var address = '0x1234567890123456789012345678901234567890'; // when var Con = contract(description); - var myCon = new Con(null); + var myCon = new Con(address); // then assert.equal('undefined', typeof myCon.test); @@ -191,11 +197,11 @@ describe('web3.eth.contract', function() { } ] }]; - + var address = '0x1234567890123456789012345678901234567890'; // when var Con = contract(description); - var myCon = new Con(null); + var myCon = new Con(address); // then assert.equal('function', typeof myCon.test); @@ -203,5 +209,32 @@ describe('web3.eth.contract', function() { }); + it('should create contract with nondefault constructor', function (done) { + var provider = new FakeHttpProvider(); + web3.setProvider(provider); + web3.reset(); // reset different polls + var address = '0x1234567890123456789012345678901234567890'; + var code = '0x31241231231123123123123121cf121212i123123123123123512312412512111111'; + var description = [{ + "name": "test", + "type": "constructor", + "inputs": [{ + "name": "a", + "type": "uint256" + } + ] + }]; + + provider.injectResult(address); + provider.injectValidation(function (payload) { + assert.equal(payload.jsonrpc, '2.0'); + assert.equal(payload.method, 'eth_sendTransaction'); + assert.equal(payload.params[0].data, code + '0000000000000000000000000000000000000000000000000000000000000002'); + done(); + }); + + var Con = contract(description); + var myCon = new Con(code, 2); + }); }); |