diff options
author | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-19 20:53:44 +0800 |
---|---|---|
committer | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-19 20:53:44 +0800 |
commit | 21e037c74fbc5aeba83d18a02f072b94d1a70542 (patch) | |
tree | b2b837142b3f3e39b737424d29044431bc6486f5 | |
parent | 819226c5036a22ad978a19026d4f427d6f77d98d (diff) | |
download | dexon-solidity-21e037c74fbc5aeba83d18a02f072b94d1a70542.tar dexon-solidity-21e037c74fbc5aeba83d18a02f072b94d1a70542.tar.gz dexon-solidity-21e037c74fbc5aeba83d18a02f072b94d1a70542.tar.bz2 dexon-solidity-21e037c74fbc5aeba83d18a02f072b94d1a70542.tar.lz dexon-solidity-21e037c74fbc5aeba83d18a02f072b94d1a70542.tar.xz dexon-solidity-21e037c74fbc5aeba83d18a02f072b94d1a70542.tar.zst dexon-solidity-21e037c74fbc5aeba83d18a02f072b94d1a70542.zip |
Squashed 'libjsqrc/ethereumjs/' changes from 823fb29..6a58db6
6a58db6 parsing real, ureal values on output
af54832 encoding real on input
86b417e fixes for autoprovider
git-subtree-dir: libjsqrc/ethereumjs
git-subtree-split: 6a58db66f7f42a49667bcc751418256441752279
-rw-r--r-- | abi.parsers.js | 83 |
1 files changed, 81 insertions, 2 deletions
diff --git a/abi.parsers.js b/abi.parsers.js index 740d52ec..e9613817 100644 --- a/abi.parsers.js +++ b/abi.parsers.js @@ -380,6 +380,45 @@ describe('abi', function() { ); }); + it('should parse input real', function () { + + // given + var d = clone(description); + + d[0].inputs = [ + { type: 'real' } + ]; + + // when + var parser = abi.inputParser(d); + + // then + assert.equal(parser.test([1]), "0000000000000000000000000000000100000000000000000000000000000000"); + assert.equal(parser.test([2.125]), "0000000000000000000000000000000220000000000000000000000000000000"); + assert.equal(parser.test([8.5]), "0000000000000000000000000000000880000000000000000000000000000000"); + assert.equal(parser.test([-1]), "ffffffffffffffffffffffffffffffff00000000000000000000000000000000"); + + }); + + it('should parse input ureal', function () { + + // given + var d = clone(description); + + d[0].inputs = [ + { type: 'ureal' } + ]; + + // when + var parser = abi.inputParser(d); + + // then + assert.equal(parser.test([1]), "0000000000000000000000000000000100000000000000000000000000000000"); + assert.equal(parser.test([2.125]), "0000000000000000000000000000000220000000000000000000000000000000"); + assert.equal(parser.test([8.5]), "0000000000000000000000000000000880000000000000000000000000000000"); + + }); + }); describe('outputParser', function() { @@ -633,12 +672,52 @@ describe('abi', function() { var parser = abi.outputParser(d); // then - assert.equal(parser.test("000000000000000000000000000000000000000000000000000000000000000001")[0], true); - assert.equal(parser.test("000000000000000000000000000000000000000000000000000000000000000000")[0], false); + assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], true); + assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000000")[0], false); }); + it('should parse output real', function() { + + // given + var d = clone(description); + + d[0].outputs = [ + { type: 'real' } + ]; + + // when + var parser = abi.outputParser(d); + + // then + assert.equal(parser.test("0x0000000000000000000000000000000100000000000000000000000000000000")[0], 1); + assert.equal(parser.test("0x0000000000000000000000000000000220000000000000000000000000000000")[0], 2.125); + assert.equal(parser.test("0x0000000000000000000000000000000880000000000000000000000000000000")[0], 8.5); + assert.equal(parser.test("0xffffffffffffffffffffffffffffffff00000000000000000000000000000000")[0], -1); + + }); + + it('should parse output ureal', function() { + + // given + var d = clone(description); + + d[0].outputs = [ + { type: 'ureal' } + ]; + + // when + var parser = abi.outputParser(d); + + // then + assert.equal(parser.test("0x0000000000000000000000000000000100000000000000000000000000000000")[0], 1); + assert.equal(parser.test("0x0000000000000000000000000000000220000000000000000000000000000000")[0], 2.125); + assert.equal(parser.test("0x0000000000000000000000000000000880000000000000000000000000000000")[0], 8.5); + + }); + + it('should parse multiple output strings', function() { // given |