From ee167e53d1637f43cb5538ff4f37b41f0b40afeb Mon Sep 17 00:00:00 2001
From: Marek Kotewicz <marek.kotewicz@gmail.com>
Date: Tue, 13 Jan 2015 15:42:56 +0100
Subject: test for parsing multiple methods description

---
 test/abi.parsers.js | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 80 insertions(+), 2 deletions(-)

(limited to 'test')

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");
+
+        });
+
     });
 });
 
-- 
cgit v1.2.3