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
fdcc1af4
Commit
fdcc1af4
authored
Feb 03, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clearing tests
parent
4a54b8c4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
465 additions
and
442 deletions
+465
-442
abi.inputParser.js
test/abi.inputParser.js
+0
-438
abi.outputParser.js
test/abi.outputParser.js
+461
-0
db.methods.js
test/db.methods.js
+1
-1
eth.methods.js
test/eth.methods.js
+1
-1
shh.methods.js
test/shh.methods.js
+1
-1
test.utils.js
test/test.utils.js
+0
-0
web3.methods.js
test/web3.methods.js
+1
-1
No files found.
test/abi.
parsers
.js
→
test/abi.
inputParser
.js
View file @
fdcc1af4
...
...
@@ -423,443 +423,5 @@ describe('abi', function() {
});
});
describe
(
'outputParser'
,
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
(
"0x"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"68656c6c6f000000000000000000000000000000000000000000000000000000"
)[
0
],
'hello'
);
assert
.
equal
(
parser
.
test
(
"0x"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"776f726c64000000000000000000000000000000000000000000000000000000"
)[
0
],
'world'
);
});
it
(
'should parse output uint'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'uint'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000000000000000000000000000000000000000000a"
)[
0
],
10
);
assert
.
equal
(
parser
.
test
(
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
)[
0
].
toString
(
10
),
new
BigNumber
(
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
,
16
).
toString
(
10
)
);
assert
.
equal
(
parser
.
test
(
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
)[
0
].
toString
(
10
),
new
BigNumber
(
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
,
16
).
toString
(
10
)
);
});
it
(
'should parse output uint256'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'uint256'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000000000000000000000000000000000000000000a"
)[
0
],
10
);
assert
.
equal
(
parser
.
test
(
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
)[
0
].
toString
(
10
),
new
BigNumber
(
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
,
16
).
toString
(
10
)
);
assert
.
equal
(
parser
.
test
(
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
)[
0
].
toString
(
10
),
new
BigNumber
(
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
,
16
).
toString
(
10
)
);
});
it
(
'should parse output uint128'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'uint128'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000000000000000000000000000000000000000000a"
)[
0
],
10
);
assert
.
equal
(
parser
.
test
(
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
)[
0
].
toString
(
10
),
new
BigNumber
(
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
,
16
).
toString
(
10
)
);
assert
.
equal
(
parser
.
test
(
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
)[
0
].
toString
(
10
),
new
BigNumber
(
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
,
16
).
toString
(
10
)
);
});
it
(
'should parse output int'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'int'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000000000000000000000000000000000000000000a"
)[
0
],
10
);
assert
.
equal
(
parser
.
test
(
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
)[
0
],
-
1
);
assert
.
equal
(
parser
.
test
(
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
)[
0
],
-
16
);
});
it
(
'should parse output int256'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'int256'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000000000000000000000000000000000000000000a"
)[
0
],
10
);
assert
.
equal
(
parser
.
test
(
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
)[
0
],
-
1
);
assert
.
equal
(
parser
.
test
(
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
)[
0
],
-
16
);
});
it
(
'should parse output int128'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'int128'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000000000000000000000000000000000000000000a"
)[
0
],
10
);
assert
.
equal
(
parser
.
test
(
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
)[
0
],
-
1
);
assert
.
equal
(
parser
.
test
(
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
)[
0
],
-
16
);
});
it
(
'should parse output hash'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'hash'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
)[
0
],
"0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
);
});
it
(
'should parse output hash256'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'hash256'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
)[
0
],
"0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
);
});
it
(
'should parse output hash160'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'hash160'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
)[
0
],
"0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
);
// TODO shouldnt' the expected hash be shorter?
});
it
(
'should parse output address'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'address'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
)[
0
],
"0x407d73d8a49eeb85d32cf465507dd71d507100c1"
);
});
it
(
'should parse output bool'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'bool'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
true
);
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000000"
)[
0
],
false
);
});
it
(
'should parse output real'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'real'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000100000000000000000000000000000000"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000220000000000000000000000000000000"
)[
0
],
2.125
);
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000880000000000000000000000000000000"
)[
0
],
8.5
);
assert
.
equal
(
parser
.
test
(
"0xffffffffffffffffffffffffffffffff00000000000000000000000000000000"
)[
0
],
-
1
);
});
it
(
'should parse output ureal'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'ureal'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000100000000000000000000000000000000"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000220000000000000000000000000000000"
)[
0
],
2.125
);
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000880000000000000000000000000000000"
)[
0
],
8.5
);
});
it
(
'should parse multiple output strings'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
"string"
},
{
type
:
"string"
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"68656c6c6f000000000000000000000000000000000000000000000000000000"
+
"776f726c64000000000000000000000000000000000000000000000000000000"
)[
0
],
'hello'
);
assert
.
equal
(
parser
.
test
(
"0x"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"68656c6c6f000000000000000000000000000000000000000000000000000000"
+
"776f726c64000000000000000000000000000000000000000000000000000000"
)[
1
],
'world'
);
});
it
(
'should use proper method name'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
name
=
'helloworld(int)'
;
d
[
0
].
outputs
=
[
{
type
:
"int"
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
helloworld
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
helloworld
[
'int'
](
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
});
it
(
'should parse multiple methods'
,
function
()
{
// given
var
d
=
[{
name
:
"test"
,
type
:
"function"
,
inputs
:
[{
type
:
"int"
}],
outputs
:
[{
type
:
"int"
}]
},{
name
:
"test2"
,
type
:
"function"
,
inputs
:
[{
type
:
"string"
}],
outputs
:
[{
type
:
"string"
}]
}];
// when
var
parser
=
abi
.
outputParser
(
d
);
//then
assert
.
equal
(
parser
.
test
(
"0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
test2
(
"0x"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"68656c6c6f000000000000000000000000000000000000000000000000000000"
)[
0
],
"hello"
);
});
it
(
'should parse output array'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'int[]'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x"
+
"0000000000000000000000000000000000000000000000000000000000000002"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"0000000000000000000000000000000000000000000000000000000000000006"
)[
0
][
0
],
5
);
assert
.
equal
(
parser
.
test
(
"0x"
+
"0000000000000000000000000000000000000000000000000000000000000002"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"0000000000000000000000000000000000000000000000000000000000000006"
)[
0
][
1
],
6
);
});
it
(
'should parse 0x value'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'int'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x"
)[
0
],
0
);
});
it
(
'should parse 0x value'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'uint'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x"
)[
0
],
0
);
});
});
});
test/abi.outputParser.js
0 → 100644
View file @
fdcc1af4
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
));
};
var
description
=
[{
"name"
:
"test"
,
"type"
:
"function"
,
"inputs"
:
[{
"name"
:
"a"
,
"type"
:
"uint256"
}
],
"outputs"
:
[
{
"name"
:
"d"
,
"type"
:
"uint256"
}
]
}];
describe
(
'abi'
,
function
()
{
describe
(
'outputParser'
,
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
(
"0x"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"68656c6c6f000000000000000000000000000000000000000000000000000000"
)[
0
],
'hello'
);
assert
.
equal
(
parser
.
test
(
"0x"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"776f726c64000000000000000000000000000000000000000000000000000000"
)[
0
],
'world'
);
});
it
(
'should parse output uint'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'uint'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000000000000000000000000000000000000000000a"
)[
0
],
10
);
assert
.
equal
(
parser
.
test
(
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
)[
0
].
toString
(
10
),
new
BigNumber
(
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
,
16
).
toString
(
10
)
);
assert
.
equal
(
parser
.
test
(
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
)[
0
].
toString
(
10
),
new
BigNumber
(
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
,
16
).
toString
(
10
)
);
});
it
(
'should parse output uint256'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'uint256'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000000000000000000000000000000000000000000a"
)[
0
],
10
);
assert
.
equal
(
parser
.
test
(
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
)[
0
].
toString
(
10
),
new
BigNumber
(
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
,
16
).
toString
(
10
)
);
assert
.
equal
(
parser
.
test
(
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
)[
0
].
toString
(
10
),
new
BigNumber
(
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
,
16
).
toString
(
10
)
);
});
it
(
'should parse output uint128'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'uint128'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000000000000000000000000000000000000000000a"
)[
0
],
10
);
assert
.
equal
(
parser
.
test
(
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
)[
0
].
toString
(
10
),
new
BigNumber
(
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
,
16
).
toString
(
10
)
);
assert
.
equal
(
parser
.
test
(
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
)[
0
].
toString
(
10
),
new
BigNumber
(
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
,
16
).
toString
(
10
)
);
});
it
(
'should parse output int'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'int'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000000000000000000000000000000000000000000a"
)[
0
],
10
);
assert
.
equal
(
parser
.
test
(
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
)[
0
],
-
1
);
assert
.
equal
(
parser
.
test
(
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
)[
0
],
-
16
);
});
it
(
'should parse output int256'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'int256'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000000000000000000000000000000000000000000a"
)[
0
],
10
);
assert
.
equal
(
parser
.
test
(
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
)[
0
],
-
1
);
assert
.
equal
(
parser
.
test
(
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
)[
0
],
-
16
);
});
it
(
'should parse output int128'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'int128'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000000000000000000000000000000000000000000a"
)[
0
],
10
);
assert
.
equal
(
parser
.
test
(
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
)[
0
],
-
1
);
assert
.
equal
(
parser
.
test
(
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
)[
0
],
-
16
);
});
it
(
'should parse output hash'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'hash'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
)[
0
],
"0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
);
});
it
(
'should parse output hash256'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'hash256'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
)[
0
],
"0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
);
});
it
(
'should parse output hash160'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'hash160'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
)[
0
],
"0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
);
// TODO shouldnt' the expected hash be shorter?
});
it
(
'should parse output address'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'address'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
)[
0
],
"0x407d73d8a49eeb85d32cf465507dd71d507100c1"
);
});
it
(
'should parse output bool'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'bool'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
true
);
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000000"
)[
0
],
false
);
});
it
(
'should parse output real'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'real'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000100000000000000000000000000000000"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000220000000000000000000000000000000"
)[
0
],
2.125
);
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000880000000000000000000000000000000"
)[
0
],
8.5
);
assert
.
equal
(
parser
.
test
(
"0xffffffffffffffffffffffffffffffff00000000000000000000000000000000"
)[
0
],
-
1
);
});
it
(
'should parse output ureal'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'ureal'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000100000000000000000000000000000000"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000220000000000000000000000000000000"
)[
0
],
2.125
);
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000880000000000000000000000000000000"
)[
0
],
8.5
);
});
it
(
'should parse multiple output strings'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
"string"
},
{
type
:
"string"
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"68656c6c6f000000000000000000000000000000000000000000000000000000"
+
"776f726c64000000000000000000000000000000000000000000000000000000"
)[
0
],
'hello'
);
assert
.
equal
(
parser
.
test
(
"0x"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"68656c6c6f000000000000000000000000000000000000000000000000000000"
+
"776f726c64000000000000000000000000000000000000000000000000000000"
)[
1
],
'world'
);
});
it
(
'should use proper method name'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
name
=
'helloworld(int)'
;
d
[
0
].
outputs
=
[
{
type
:
"int"
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
helloworld
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
helloworld
[
'int'
](
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
});
it
(
'should parse multiple methods'
,
function
()
{
// given
var
d
=
[{
name
:
"test"
,
type
:
"function"
,
inputs
:
[{
type
:
"int"
}],
outputs
:
[{
type
:
"int"
}]
},{
name
:
"test2"
,
type
:
"function"
,
inputs
:
[{
type
:
"string"
}],
outputs
:
[{
type
:
"string"
}]
}];
// when
var
parser
=
abi
.
outputParser
(
d
);
//then
assert
.
equal
(
parser
.
test
(
"0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
test2
(
"0x"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"68656c6c6f000000000000000000000000000000000000000000000000000000"
)[
0
],
"hello"
);
});
it
(
'should parse output array'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'int[]'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x"
+
"0000000000000000000000000000000000000000000000000000000000000002"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"0000000000000000000000000000000000000000000000000000000000000006"
)[
0
][
0
],
5
);
assert
.
equal
(
parser
.
test
(
"0x"
+
"0000000000000000000000000000000000000000000000000000000000000002"
+
"0000000000000000000000000000000000000000000000000000000000000005"
+
"0000000000000000000000000000000000000000000000000000000000000006"
)[
0
][
1
],
6
);
});
it
(
'should parse 0x value'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'int'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x"
)[
0
],
0
);
});
it
(
'should parse 0x value'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'uint'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x"
)[
0
],
0
);
});
});
});
test/db.methods.js
View file @
fdcc1af4
var
assert
=
require
(
'assert'
);
var
web3
=
require
(
'../index.js'
);
var
u
=
require
(
'./utils.js'
);
var
u
=
require
(
'./
test.
utils.js'
);
describe
(
'web3'
,
function
()
{
describe
(
'db'
,
function
()
{
...
...
test/eth.methods.js
View file @
fdcc1af4
var
assert
=
require
(
'assert'
);
var
web3
=
require
(
'../index.js'
);
var
u
=
require
(
'./utils.js'
);
var
u
=
require
(
'./
test.
utils.js'
);
describe
(
'web3'
,
function
()
{
describe
(
'eth'
,
function
()
{
...
...
test/shh.methods.js
View file @
fdcc1af4
var
assert
=
require
(
'assert'
);
var
web3
=
require
(
'../index.js'
);
var
u
=
require
(
'./utils.js'
);
var
u
=
require
(
'./
test.
utils.js'
);
describe
(
'web3'
,
function
()
{
describe
(
'shh'
,
function
()
{
...
...
test/utils.js
→
test/
test.
utils.js
View file @
fdcc1af4
File moved
test/web3.methods.js
View file @
fdcc1af4
var
assert
=
require
(
'assert'
);
var
web3
=
require
(
'../index.js'
);
var
u
=
require
(
'./utils.js'
);
var
u
=
require
(
'./
test.
utils.js'
);
describe
(
'web3'
,
function
()
{
u
.
methodExists
(
web3
,
'sha3'
);
...
...
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