aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Kotewicz <marek.kotewicz@gmail.com>2015-01-16 18:28:46 +0800
committerMarek Kotewicz <marek.kotewicz@gmail.com>2015-01-16 18:28:46 +0800
commitf1295b506d11f79048bb86d96a7f28224f0dd04c (patch)
treea437b2b5db9eab00a1bf5b30bdd22c3258c08fb4
parentfbcc6d0d25d1a9e9eed5be22874e559a2bf49911 (diff)
downloadgo-tangerine-f1295b506d11f79048bb86d96a7f28224f0dd04c.tar.gz
go-tangerine-f1295b506d11f79048bb86d96a7f28224f0dd04c.tar.zst
go-tangerine-f1295b506d11f79048bb86d96a7f28224f0dd04c.zip
tests for bigintegers on input
-rw-r--r--test/abi.parsers.js50
1 files changed, 49 insertions, 1 deletions
diff --git a/test/abi.parsers.js b/test/abi.parsers.js
index 925324461..393c1e939 100644
--- a/test/abi.parsers.js
+++ b/test/abi.parsers.js
@@ -1,4 +1,5 @@
var assert = require('assert');
+var BigNumber = require('bignumber.js');
var abi = require('../lib/abi.js');
var clone = function (object) { return JSON.parse(JSON.stringify(object)); };
@@ -34,6 +35,14 @@ describe('abi', function() {
// then
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
+ assert.equal(
+ parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
+ "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ );
+ assert.equal(
+ parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
+ "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ );
});
@@ -52,6 +61,14 @@ describe('abi', function() {
// then
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
+ assert.equal(
+ parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
+ "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ );
+ assert.equal(
+ parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
+ "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ );
});
@@ -70,6 +87,14 @@ describe('abi', function() {
// then
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
+ assert.equal(
+ parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
+ "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ );
+ assert.equal(
+ parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
+ "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ );
});
@@ -91,7 +116,14 @@ describe('abi', function() {
assert.equal(parser.test(-1), "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
assert.equal(parser.test(-2), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe");
assert.equal(parser.test(-16), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0");
-
+ assert.equal(
+ parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
+ "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ );
+ assert.equal(
+ parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
+ "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ );
});
it('should parse input int128', function() {
@@ -112,6 +144,14 @@ describe('abi', function() {
assert.equal(parser.test(-1), "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
assert.equal(parser.test(-2), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe");
assert.equal(parser.test(-16), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0");
+ assert.equal(
+ parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
+ "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ );
+ assert.equal(
+ parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
+ "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ );
});
@@ -133,6 +173,14 @@ describe('abi', function() {
assert.equal(parser.test(-1), "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
assert.equal(parser.test(-2), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe");
assert.equal(parser.test(-16), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0");
+ assert.equal(
+ parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
+ "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ );
+ assert.equal(
+ parser.test(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16)),
+ "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+ );
});