Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
4056c046
Commit
4056c046
authored
Jan 13, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests...
parent
1428dcee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
110 additions
and
10 deletions
+110
-10
abi.parsers.js
test/abi.parsers.js
+110
-10
No files found.
test/abi.parsers.js
View file @
4056c046
...
...
@@ -21,29 +21,53 @@ describe('abi', function() {
describe
(
'inputParser'
,
function
()
{
it
(
'should parse input uint'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
inputs
=
[
{
type
:
"uint
256
"
}
{
type
:
"uint"
}
];
// when
var
parser
=
abi
.
inputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
assert
.
equal
(
parser
.
test
(
10
),
"000000000000000000000000000000000000000000000000000000000000000a"
);
});
it
(
'should parse input uint128'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
inputs
=
[
{
type
:
"uint128"
}
];
// when
var
parser
=
abi
.
inputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
assert
.
equal
(
parser
.
test
(
10
),
"000000000000000000000000000000000000000000000000000000000000000a"
);
});
it
(
'should parse input uint'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
inputs
=
[
{
type
:
"uint"
}
{
type
:
"uint
256
"
}
];
// when
var
parser
=
abi
.
inputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
assert
.
equal
(
parser
.
test
(
10
),
"000000000000000000000000000000000000000000000000000000000000000a"
);
...
...
@@ -51,70 +75,123 @@ describe('abi', function() {
it
(
'should parse input int'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
inputs
=
[
{
type
:
"int
256
"
}
{
type
:
"int"
}
];
// when
var
parser
=
abi
.
inputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
assert
.
equal
(
parser
.
test
(
10
),
"000000000000000000000000000000000000000000000000000000000000000a"
);
});
it
(
'should parse input int128'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
inputs
=
[
{
type
:
"int128"
}
];
// when
var
parser
=
abi
.
inputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
assert
.
equal
(
parser
.
test
(
10
),
"000000000000000000000000000000000000000000000000000000000000000a"
);
});
it
(
'should parse input int256'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
inputs
=
[
{
type
:
"int"
}
{
type
:
"int
256
"
}
];
// when
var
parser
=
abi
.
inputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
assert
.
equal
(
parser
.
test
(
10
),
"000000000000000000000000000000000000000000000000000000000000000a"
);
});
it
(
'should parse input hash'
,
function
()
{
/*
// given
var d = clone(description);
d[0].inputs = [
{
type
:
"hash
256
"
}
{ type: "hash" }
];
// when
var parser = abi.inputParser(d);
// then
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
*/
});
it
(
'should parse input hash128'
,
function
()
{
/*
// given
var d = clone(description);
d[0].inputs = [
{ type: "hash128" }
];
// when
var parser = abi.inputParser(d);
// then
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
*/
});
it
(
'should parse input hash'
,
function
()
{
/*
// given
var d = clone(description);
d[0].inputs = [
{ type: "hash" }
];
// when
var parser = abi.inputParser(d);
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
// then
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
*/
});
it
(
'should parse input string'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
inputs
=
[
{
type
:
"string"
}
];
// when
var
parser
=
abi
.
inputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
'hello'
),
"68656c6c6f000000000000000000000000000000000000000000000000000000"
);
assert
.
equal
(
parser
.
test
(
'world'
),
"776f726c64000000000000000000000000000000000000000000000000000000"
);
});
...
...
@@ -123,17 +200,40 @@ describe('abi', function() {
describe
(
'outputParser'
,
function
()
{
it
(
'parse ...'
,
function
()
{
it
(
'should parse output string'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
"string"
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x68656c6c6f000000000000000000000000000000000000000000000000000000"
)[
0
],
'hello'
);
assert
.
equal
(
parser
.
test
(
"0x776f726c64000000000000000000000000000000000000000000000000000000"
)[
0
],
'world'
);
});
it
(
'should parse multiplt output strings'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
"string"
},
{
type
:
"string"
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
assert
.
equal
(
parser
.
test
(
"0x68656c6c6f00000000000000000000000000000000000000000000000000000"
)[
0
],
'hello'
);
assert
.
equal
(
parser
.
test
(
"0x776f726c6400000000000000000000000000000000000000000000000000000"
)[
0
],
'world'
);
// then
assert
.
equal
(
parser
.
test
(
"0x68656c6c6f000000000000000000000000000000000000000000000000000000776f726c64000000000000000000000000000000000000000000000000000000"
)[
0
],
'hello'
);
assert
.
equal
(
parser
.
test
(
"0x68656c6c6f000000000000000000000000000000000000000000000000000000776f726c64000000000000000000000000000000000000000000000000000000"
)[
1
],
'world'
);
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment