mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 19:48:13 +00:00
constants should be before (dynamic) string contents
This commit is contained in:
parent
8cf8b9e9d3
commit
4b9bc177f7
@ -75,6 +75,8 @@ var formatInput = function (inputs, params) {
|
||||
toAppendArrayContent += params[i].reduce(function (acc, curr) {
|
||||
return acc + formatter(curr);
|
||||
}, "");
|
||||
else if (inputs[i].type === 'string')
|
||||
toAppendArrayContent += formatter(params[i]);
|
||||
else
|
||||
toAppendConstant += formatter(params[i]);
|
||||
});
|
||||
|
@ -309,7 +309,8 @@ describe('abi', function() {
|
||||
// then
|
||||
assert.equal(
|
||||
parser.test('hello'),
|
||||
"000000000000000000000000000000000000000000000000000000000000000568656c6c6f000000000000000000000000000000000000000000000000000000"
|
||||
"0000000000000000000000000000000000000000000000000000000000000005" +
|
||||
"68656c6c6f000000000000000000000000000000000000000000000000000000"
|
||||
);
|
||||
assert.equal(
|
||||
parser.test('world'),
|
||||
@ -317,6 +318,50 @@ 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user