mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Squashed 'libjsqrc/ethereumjs/' changes from 5bd166c..7d6b35a
7d6b35a Merge branch 'master' into cpp 9b3a0f0 Merge branch 'event_hash' 9887972 version 63dcee6 ignore for maxcomplexity warning 8376bfa gulp a59f3a4 Merge pull request #85 from ethers/abiString 0dd6cc4 gulp 688faec Merge pull request #81 from ethers/arraySupport 64f6630 updated README.md 4f9aaec Merge pull request #94 from ethereum/signature 91321fb removed web3 dependency from abi.js 5c7d8a7 separated event signature 81b19cc event hash ea250e6 Merge commit 'be3bfb76bef1d1f113033cd9093e03a00066d5d1' into ethereumjs_timeout c08cea1 Improvement to AZ - confirmation disabler. Fix network crash. git-subtree-dir: libjsqrc/ethereumjs git-subtree-split: 7d6b35af1c2b59feae5a01c899fae68298d71211
This commit is contained in:
parent
0b6d06e5aa
commit
628a07d541
@ -29,7 +29,7 @@ describe('abi', function() {
|
||||
d[0].inputs = [
|
||||
{ type: "uint" }
|
||||
];
|
||||
|
||||
|
||||
// when
|
||||
var parser = abi.inputParser(d);
|
||||
|
||||
@ -37,7 +37,7 @@ describe('abi', function() {
|
||||
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
|
||||
assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
|
||||
assert.equal(
|
||||
parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
|
||||
parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
|
||||
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
||||
);
|
||||
assert.equal(
|
||||
@ -67,7 +67,7 @@ describe('abi', function() {
|
||||
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
|
||||
assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
|
||||
assert.equal(
|
||||
parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
|
||||
parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
|
||||
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
||||
);
|
||||
assert.equal(
|
||||
@ -80,7 +80,7 @@ describe('abi', function() {
|
||||
assert.equal(parser.test('3.9'), "0000000000000000000000000000000000000000000000000000000000000003");
|
||||
|
||||
});
|
||||
|
||||
|
||||
it('should parse input uint256', function() {
|
||||
|
||||
// given
|
||||
@ -97,7 +97,7 @@ describe('abi', function() {
|
||||
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
|
||||
assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
|
||||
assert.equal(
|
||||
parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
|
||||
parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
|
||||
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
||||
);
|
||||
assert.equal(
|
||||
@ -108,7 +108,7 @@ describe('abi', function() {
|
||||
assert.equal(parser.test(3.9), "0000000000000000000000000000000000000000000000000000000000000003");
|
||||
assert.equal(parser.test('0.1'), "0000000000000000000000000000000000000000000000000000000000000000");
|
||||
assert.equal(parser.test('3.9'), "0000000000000000000000000000000000000000000000000000000000000003");
|
||||
|
||||
|
||||
});
|
||||
|
||||
it('should parse input int', function() {
|
||||
@ -119,7 +119,7 @@ describe('abi', function() {
|
||||
d[0].inputs = [
|
||||
{ type: "int" }
|
||||
];
|
||||
|
||||
|
||||
// when
|
||||
var parser = abi.inputParser(d);
|
||||
|
||||
@ -130,7 +130,7 @@ describe('abi', function() {
|
||||
assert.equal(parser.test(-2), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe");
|
||||
assert.equal(parser.test(-16), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0");
|
||||
assert.equal(
|
||||
parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
|
||||
parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
|
||||
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
||||
);
|
||||
assert.equal(
|
||||
@ -162,7 +162,7 @@ describe('abi', function() {
|
||||
assert.equal(parser.test(-2), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe");
|
||||
assert.equal(parser.test(-16), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0");
|
||||
assert.equal(
|
||||
parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
|
||||
parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
|
||||
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
||||
);
|
||||
assert.equal(
|
||||
@ -177,7 +177,7 @@ describe('abi', function() {
|
||||
});
|
||||
|
||||
it('should parse input int256', function() {
|
||||
|
||||
|
||||
// given
|
||||
var d = clone(description);
|
||||
|
||||
@ -195,7 +195,7 @@ describe('abi', function() {
|
||||
assert.equal(parser.test(-2), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe");
|
||||
assert.equal(parser.test(-16), "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0");
|
||||
assert.equal(
|
||||
parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
|
||||
parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
|
||||
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
||||
);
|
||||
assert.equal(
|
||||
@ -206,11 +206,11 @@ describe('abi', function() {
|
||||
assert.equal(parser.test(3.9), "0000000000000000000000000000000000000000000000000000000000000003");
|
||||
assert.equal(parser.test('0.1'), "0000000000000000000000000000000000000000000000000000000000000000");
|
||||
assert.equal(parser.test('3.9'), "0000000000000000000000000000000000000000000000000000000000000003");
|
||||
|
||||
|
||||
});
|
||||
|
||||
it('should parse input bool', function() {
|
||||
|
||||
|
||||
// given
|
||||
var d = clone(description);
|
||||
|
||||
@ -235,14 +235,14 @@ describe('abi', function() {
|
||||
d[0].inputs = [
|
||||
{ type: "hash" }
|
||||
];
|
||||
|
||||
|
||||
// when
|
||||
var parser = abi.inputParser(d);
|
||||
|
||||
// then
|
||||
assert.equal(parser.test("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), "000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1");
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
it('should parse input hash256', function() {
|
||||
|
||||
@ -272,7 +272,7 @@ describe('abi', function() {
|
||||
|
||||
// when
|
||||
var parser = abi.inputParser(d);
|
||||
|
||||
|
||||
// then
|
||||
assert.equal(parser.test("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), "000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1");
|
||||
});
|
||||
@ -285,17 +285,17 @@ describe('abi', function() {
|
||||
d[0].inputs = [
|
||||
{ type: "address" }
|
||||
];
|
||||
|
||||
|
||||
// when
|
||||
var parser = abi.inputParser(d)
|
||||
|
||||
|
||||
// then
|
||||
assert.equal(parser.test("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), "000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1");
|
||||
|
||||
});
|
||||
|
||||
it('should parse input string', function () {
|
||||
|
||||
|
||||
// given
|
||||
var d = clone(description);
|
||||
|
||||
@ -308,8 +308,9 @@ describe('abi', function() {
|
||||
|
||||
// then
|
||||
assert.equal(
|
||||
parser.test('hello'),
|
||||
"000000000000000000000000000000000000000000000000000000000000000568656c6c6f000000000000000000000000000000000000000000000000000000"
|
||||
parser.test('hello'),
|
||||
"0000000000000000000000000000000000000000000000000000000000000005" +
|
||||
"68656c6c6f000000000000000000000000000000000000000000000000000000"
|
||||
);
|
||||
assert.equal(
|
||||
parser.test('world'),
|
||||
@ -317,8 +318,52 @@ describe('abi', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('should parse input int followed by a string', function () {
|
||||
|
||||
// given
|
||||
var d = clone(description);
|
||||
|
||||
d[0].inputs = [
|
||||
{ type: "int" },
|
||||
{ type: "string" }
|
||||
];
|
||||
|
||||
// when
|
||||
var parser = abi.inputParser(d);
|
||||
|
||||
// then
|
||||
assert.equal(
|
||||
parser.test(9, 'hello'),
|
||||
"0000000000000000000000000000000000000000000000000000000000000005" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000009" +
|
||||
"68656c6c6f000000000000000000000000000000000000000000000000000000"
|
||||
);
|
||||
});
|
||||
|
||||
it('should parse input string followed by an int', function () {
|
||||
|
||||
// given
|
||||
var d = clone(description);
|
||||
|
||||
d[0].inputs = [
|
||||
{ type: "string" },
|
||||
{ type: "int" }
|
||||
];
|
||||
|
||||
// when
|
||||
var parser = abi.inputParser(d);
|
||||
|
||||
// then
|
||||
assert.equal(
|
||||
parser.test('hello', 9),
|
||||
"0000000000000000000000000000000000000000000000000000000000000005" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000009" +
|
||||
"68656c6c6f000000000000000000000000000000000000000000000000000000"
|
||||
);
|
||||
});
|
||||
|
||||
it('should use proper method name', function () {
|
||||
|
||||
|
||||
// given
|
||||
var d = clone(description);
|
||||
d[0].name = 'helloworld(int)';
|
||||
@ -334,9 +379,9 @@ describe('abi', function() {
|
||||
assert.equal(parser.helloworld['int'](1), "0000000000000000000000000000000000000000000000000000000000000001");
|
||||
|
||||
});
|
||||
|
||||
|
||||
it('should parse multiple methods', function () {
|
||||
|
||||
|
||||
// given
|
||||
var d = [{
|
||||
name: "test",
|
||||
@ -356,14 +401,14 @@ describe('abi', function() {
|
||||
//then
|
||||
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
|
||||
assert.equal(
|
||||
parser.test2('hello'),
|
||||
parser.test2('hello'),
|
||||
"000000000000000000000000000000000000000000000000000000000000000568656c6c6f000000000000000000000000000000000000000000000000000000"
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
it('should parse input array of ints', function () {
|
||||
|
||||
|
||||
// given
|
||||
var d = clone(description);
|
||||
|
||||
@ -377,14 +422,91 @@ describe('abi', function() {
|
||||
// then
|
||||
assert.equal(
|
||||
parser.test([5, 6]),
|
||||
"0000000000000000000000000000000000000000000000000000000000000002" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000005" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000002" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000005" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000006"
|
||||
);
|
||||
});
|
||||
|
||||
it('should parse an array followed by an int', function () {
|
||||
|
||||
// given
|
||||
var d = clone(description);
|
||||
|
||||
d[0].inputs = [
|
||||
{ type: "int[]" },
|
||||
{ type: "int" }
|
||||
];
|
||||
|
||||
// when
|
||||
var parser = abi.inputParser(d);
|
||||
|
||||
// then
|
||||
assert.equal(
|
||||
parser.test([5, 6], 3),
|
||||
"0000000000000000000000000000000000000000000000000000000000000002" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000003" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000005" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000006"
|
||||
);
|
||||
});
|
||||
|
||||
it('should parse an int followed by an array', function () {
|
||||
|
||||
// given
|
||||
var d = clone(description);
|
||||
|
||||
d[0].inputs = [
|
||||
{ type: "int" },
|
||||
{ type: "int[]" }
|
||||
];
|
||||
|
||||
// when
|
||||
var parser = abi.inputParser(d);
|
||||
|
||||
// then
|
||||
assert.equal(
|
||||
parser.test(3, [5, 6]),
|
||||
"0000000000000000000000000000000000000000000000000000000000000002" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000003" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000005" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000006"
|
||||
);
|
||||
});
|
||||
|
||||
it('should parse mixture of arrays and ints', function () {
|
||||
|
||||
// given
|
||||
var d = clone(description);
|
||||
|
||||
d[0].inputs = [
|
||||
{ type: "int" },
|
||||
{ type: "int[]" },
|
||||
{ type: "int" },
|
||||
{ type: "int[]" }
|
||||
];
|
||||
|
||||
// when
|
||||
var parser = abi.inputParser(d);
|
||||
|
||||
// then
|
||||
assert.equal(
|
||||
parser.test(3, [5, 6, 1, 2], 7, [8, 9]),
|
||||
"0000000000000000000000000000000000000000000000000000000000000004" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000002" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000003" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000007" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000005" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000006" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000001" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000002" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000008" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000009"
|
||||
);
|
||||
});
|
||||
|
||||
it('should parse input real', function () {
|
||||
|
||||
|
||||
// given
|
||||
var d = clone(description);
|
||||
|
||||
@ -396,15 +518,15 @@ describe('abi', function() {
|
||||
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");
|
||||
|
||||
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);
|
||||
|
||||
@ -416,12 +538,11 @@ describe('abi', function() {
|
||||
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]), "0000000000000000000000000000000100000000000000000000000000000000");
|
||||
assert.equal(parser.test([2.125]), "0000000000000000000000000000000220000000000000000000000000000000");
|
||||
assert.equal(parser.test([8.5]), "0000000000000000000000000000000880000000000000000000000000000000");
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user