From af54832d2435ff4116c887effa09e4f276ac970c Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Mon, 19 Jan 2015 12:59:29 +0100 Subject: encoding real on input --- test/abi.parsers.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'test/abi.parsers.js') diff --git a/test/abi.parsers.js b/test/abi.parsers.js index 740d52eca..bbf10bcd3 100644 --- a/test/abi.parsers.js +++ b/test/abi.parsers.js @@ -380,6 +380,46 @@ 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() { -- cgit v1.2.3 From 6a58db66f7f42a49667bcc751418256441752279 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Mon, 19 Jan 2015 13:22:58 +0100 Subject: parsing real, ureal values on output --- test/abi.parsers.js | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'test/abi.parsers.js') diff --git a/test/abi.parsers.js b/test/abi.parsers.js index bbf10bcd3..e9613817b 100644 --- a/test/abi.parsers.js +++ b/test/abi.parsers.js @@ -419,7 +419,6 @@ describe('abi', function() { }); - }); describe('outputParser', function() { @@ -673,11 +672,51 @@ 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() { -- cgit v1.2.3