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 | 83505e61f35eae3b491d8223444459b2faec41f0 (patch) | |
tree | 6d4dda23d22c6645b4cbb0bd503911e4c4bbd267 /test/abi.parsers.js | |
parent | 2ce109eb53845ae4b3b8f025ab438f3436494a62 (diff) | |
parent | 6a58db66f7f42a49667bcc751418256441752279 (diff) | |
download | go-tangerine-83505e61f35eae3b491d8223444459b2faec41f0.tar go-tangerine-83505e61f35eae3b491d8223444459b2faec41f0.tar.gz go-tangerine-83505e61f35eae3b491d8223444459b2faec41f0.tar.bz2 go-tangerine-83505e61f35eae3b491d8223444459b2faec41f0.tar.lz go-tangerine-83505e61f35eae3b491d8223444459b2faec41f0.tar.xz go-tangerine-83505e61f35eae3b491d8223444459b2faec41f0.tar.zst go-tangerine-83505e61f35eae3b491d8223444459b2faec41f0.zip |
Merge commit '2b4d38b9bf059014596e1ab00c99dc2ad4ab3761' into ethereumjs
Diffstat (limited to 'test/abi.parsers.js')
-rw-r--r-- | test/abi.parsers.js | 83 |
1 files changed, 81 insertions, 2 deletions
diff --git a/test/abi.parsers.js b/test/abi.parsers.js index 740d52eca..e9613817b 100644 --- a/test/abi.parsers.js +++ b/test/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 |