aboutsummaryrefslogtreecommitdiffstats
path: root/test/abi.parsers.js
diff options
context:
space:
mode:
authorMarek Kotewicz <marek.kotewicz@gmail.com>2015-01-13 22:42:56 +0800
committerMarek Kotewicz <marek.kotewicz@gmail.com>2015-01-13 22:42:56 +0800
commitee167e53d1637f43cb5538ff4f37b41f0b40afeb (patch)
treeeaf85744aeb0c1ad91b6d9e7b6be8b663e8a5035 /test/abi.parsers.js
parent4056c046a7d1907bdb0c0682cd487538915fcdd2 (diff)
downloaddexon-ee167e53d1637f43cb5538ff4f37b41f0b40afeb.tar
dexon-ee167e53d1637f43cb5538ff4f37b41f0b40afeb.tar.gz
dexon-ee167e53d1637f43cb5538ff4f37b41f0b40afeb.tar.bz2
dexon-ee167e53d1637f43cb5538ff4f37b41f0b40afeb.tar.lz
dexon-ee167e53d1637f43cb5538ff4f37b41f0b40afeb.tar.xz
dexon-ee167e53d1637f43cb5538ff4f37b41f0b40afeb.tar.zst
dexon-ee167e53d1637f43cb5538ff4f37b41f0b40afeb.zip
test for parsing multiple methods description
Diffstat (limited to 'test/abi.parsers.js')
-rw-r--r--test/abi.parsers.js82
1 files changed, 80 insertions, 2 deletions
diff --git a/test/abi.parsers.js b/test/abi.parsers.js
index 8d0c2bc95..6a31c2173 100644
--- a/test/abi.parsers.js
+++ b/test/abi.parsers.js
@@ -196,8 +196,45 @@ describe('abi', function() {
assert.equal(parser.test('world'), "776f726c64000000000000000000000000000000000000000000000000000000");
});
- });
+ it('should use proper method name', function () {
+
+ // given
+ var d = clone(description);
+ d[0].name = 'helloworld';
+ d[0].inputs = [
+ { type: "int" }
+ ];
+ // when
+ var parser = abi.inputParser(d);
+
+ // then
+ assert.equal(parser.helloworld(1), "0000000000000000000000000000000000000000000000000000000000000001");
+
+ });
+
+ it('should parse multiple methods', function () {
+
+ // given
+ var d = [{
+ name: "test",
+ inputs: [{ type: "int" }],
+ outputs: [{ type: "int" }]
+ },{
+ name: "test2",
+ inputs: [{ type: "string" }],
+ outputs: [{ type: "string" }]
+ }];
+
+ // when
+ var parser = abi.inputParser(d);
+
+ //then
+ assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
+ assert.equal(parser.test2('hello'), "68656c6c6f000000000000000000000000000000000000000000000000000000");
+
+ });
+ });
describe('outputParser', function() {
it('should parse output string', function() {
@@ -218,7 +255,7 @@ describe('abi', function() {
});
- it('should parse multiplt output strings', function() {
+ it('should parse multiple output strings', function() {
// given
var d = clone(description);
@@ -236,6 +273,47 @@ describe('abi', function() {
assert.equal(parser.test("0x68656c6c6f000000000000000000000000000000000000000000000000000000776f726c64000000000000000000000000000000000000000000000000000000")[1], 'world');
});
+
+ it('should use proper method name', function () {
+
+ // given
+ var d = clone(description);
+ d[0].name = 'helloworld';
+ d[0].outputs = [
+ { type: "int" }
+ ];
+
+ // when
+ var parser = abi.outputParser(d);
+
+ // then
+ assert.equal(parser.helloworld("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
+
+ });
+
+
+ it('should parse multiple methods', function () {
+
+ // given
+ var d = [{
+ name: "test",
+ inputs: [{ type: "int" }],
+ outputs: [{ type: "int" }]
+ },{
+ name: "test2",
+ inputs: [{ type: "string" }],
+ outputs: [{ type: "string" }]
+ }];
+
+ // when
+ var parser = abi.outputParser(d);
+
+ //then
+ assert.equal(parser.test("0000000000000000000000000000000000000000000000000000000000000001")[0], 1);
+ assert.equal(parser.test2("0x68656c6c6f000000000000000000000000000000000000000000000000000000")[0], "hello");
+
+ });
+
});
});