mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-26 05:27:19 +00:00
tests in progress, fixed utf characters conversion in toAscii
This commit is contained in:
parent
9e0de57a82
commit
380d9862c3
4
dist/ethereum.js
vendored
4
dist/ethereum.js
vendored
@ -823,12 +823,12 @@ var web3 = {
|
||||
if (hex.substring(0, 2) === '0x')
|
||||
i = 2;
|
||||
for(; i < l; i+=2) {
|
||||
var code = hex.charCodeAt(i);
|
||||
var code = parseInt(hex.substr(i, 2), 16);
|
||||
if(code === 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
|
||||
str += String.fromCharCode(code);
|
||||
}
|
||||
|
||||
return str;
|
||||
|
2
dist/ethereum.js.map
vendored
2
dist/ethereum.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/ethereum.min.js
vendored
2
dist/ethereum.min.js
vendored
File diff suppressed because one or more lines are too long
@ -244,12 +244,12 @@ var web3 = {
|
||||
if (hex.substring(0, 2) === '0x')
|
||||
i = 2;
|
||||
for(; i < l; i+=2) {
|
||||
var code = hex.charCodeAt(i);
|
||||
var code = parseInt(hex.substr(i, 2), 16);
|
||||
if(code === 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
|
||||
str += String.fromCharCode(code);
|
||||
}
|
||||
|
||||
return str;
|
||||
|
@ -1,35 +1,141 @@
|
||||
# vim: et
|
||||
|
||||
var assert = require('assert');
|
||||
var abi = require('../lib/abi.js');
|
||||
var clone = function (object) { return JSON.parse(JSON.stringify(object)); };
|
||||
|
||||
var description = [{
|
||||
"name": "test",
|
||||
"inputs": [{
|
||||
"name": "a",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "d",
|
||||
"type": "uint256"
|
||||
}
|
||||
]
|
||||
}];
|
||||
|
||||
describe('abi', function() {
|
||||
describe('inputParser', function() {
|
||||
it('should parse ...', function() {
|
||||
it('should parse input uint', function() {
|
||||
|
||||
var desc = [{
|
||||
"name": "multiply",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "a",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "d",
|
||||
"type": "uint256"
|
||||
}
|
||||
]
|
||||
}];
|
||||
var d = clone(description);
|
||||
|
||||
var iParser = abi.inputParser(desc);
|
||||
assert.equal(iParser.multiply(1), "0x000000000000000000000000000000000000000000000000000000000000000001");
|
||||
d[0].inputs = [
|
||||
{ type: "uint256" }
|
||||
];
|
||||
|
||||
var parser = abi.inputParser(d);
|
||||
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
|
||||
assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
|
||||
|
||||
d[0].inputs = [
|
||||
{ type: "uint128" }
|
||||
];
|
||||
|
||||
var parser = abi.inputParser(d);
|
||||
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
|
||||
assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
|
||||
|
||||
d[0].inputs = [
|
||||
{ type: "uint" }
|
||||
];
|
||||
|
||||
var parser = abi.inputParser(d);
|
||||
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
|
||||
assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
|
||||
|
||||
});
|
||||
|
||||
it('should parse input int', function() {
|
||||
|
||||
var d = clone(description);
|
||||
|
||||
d[0].inputs = [
|
||||
{ type: "int256" }
|
||||
];
|
||||
|
||||
var parser = abi.inputParser(d);
|
||||
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
|
||||
assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
|
||||
|
||||
d[0].inputs = [
|
||||
{ type: "int128" }
|
||||
];
|
||||
|
||||
var parser = abi.inputParser(d);
|
||||
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
|
||||
assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
|
||||
|
||||
d[0].inputs = [
|
||||
{ type: "int" }
|
||||
];
|
||||
|
||||
var parser = abi.inputParser(d);
|
||||
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
|
||||
assert.equal(parser.test(10), "000000000000000000000000000000000000000000000000000000000000000a");
|
||||
|
||||
});
|
||||
|
||||
it('should parse input hash', function() {
|
||||
|
||||
var d = clone(description);
|
||||
|
||||
d[0].inputs = [
|
||||
{ type: "hash256" }
|
||||
];
|
||||
|
||||
var parser = abi.inputParser(d);
|
||||
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
|
||||
|
||||
d[0].inputs = [
|
||||
{ type: "hash128" }
|
||||
];
|
||||
|
||||
var parser = abi.inputParser(d);
|
||||
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
|
||||
|
||||
d[0].inputs = [
|
||||
{ type: "hash" }
|
||||
];
|
||||
|
||||
var parser = abi.inputParser(d);
|
||||
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
|
||||
|
||||
});
|
||||
|
||||
it('should parse input string', function() {
|
||||
|
||||
var d = clone(description);
|
||||
|
||||
d[0].inputs = [
|
||||
{ type: "string" }
|
||||
];
|
||||
|
||||
var parser = abi.inputParser(d);
|
||||
assert.equal(parser.test('hello'), "68656c6c6f000000000000000000000000000000000000000000000000000000");
|
||||
assert.equal(parser.test('world'), "776f726c64000000000000000000000000000000000000000000000000000000");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('outputParser', function() {
|
||||
it('parse ...', function() {
|
||||
|
||||
var d = clone(description);
|
||||
|
||||
d[0].outputs = [
|
||||
{ type: "string" }
|
||||
];
|
||||
|
||||
var parser = abi.outputParser(d);
|
||||
assert.equal(parser.test("0x68656c6c6f00000000000000000000000000000000000000000000000000000")[0], 'hello');
|
||||
assert.equal(parser.test("0x776f726c6400000000000000000000000000000000000000000000000000000")[0], 'world');
|
||||
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user