aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMarek Kotewicz <marek.kotewicz@gmail.com>2015-01-31 10:42:13 +0800
committerMarek Kotewicz <marek.kotewicz@gmail.com>2015-01-31 10:42:13 +0800
commit80c97ca21b168e7f94cae6333be5439b6db2fe1d (patch)
tree696457afc72310f7e58acce0c6f0e40035ed5817 /test
parent2491c99b37241b8770bca516d5641b2d00a7a660 (diff)
downloadgo-tangerine-80c97ca21b168e7f94cae6333be5439b6db2fe1d.tar
go-tangerine-80c97ca21b168e7f94cae6333be5439b6db2fe1d.tar.gz
go-tangerine-80c97ca21b168e7f94cae6333be5439b6db2fe1d.tar.bz2
go-tangerine-80c97ca21b168e7f94cae6333be5439b6db2fe1d.tar.lz
go-tangerine-80c97ca21b168e7f94cae6333be5439b6db2fe1d.tar.xz
go-tangerine-80c97ca21b168e7f94cae6333be5439b6db2fe1d.tar.zst
go-tangerine-80c97ca21b168e7f94cae6333be5439b6db2fe1d.zip
events
Diffstat (limited to 'test')
-rw-r--r--test/event.js80
1 files changed, 77 insertions, 3 deletions
diff --git a/test/event.js b/test/event.js
index 43f8dcf38..9edd93ae7 100644
--- a/test/event.js
+++ b/test/event.js
@@ -1,5 +1,6 @@
var assert = require('assert');
var event = require('../lib/event.js');
+var f = require('../lib/formatters.js');
describe('event', function () {
it('should create basic filter input object', function () {
@@ -7,9 +8,13 @@ describe('event', function () {
// given
var address = '0x012345';
var signature = '0x987654';
+ var e = {
+ name: 'Event',
+ inputs: [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"hash256","indexed":false}]
+ };
// when
- var impl = event(address, signature);
+ var impl = event(address, signature, e);
var result = impl();
// then
@@ -19,7 +24,7 @@ describe('event', function () {
});
- it('should create basic filter input object', function () {
+ it('should create filter input object with options', function () {
// given
var address = '0x012345';
@@ -30,9 +35,13 @@ describe('event', function () {
offset: 3,
max: 4
};
+ var e = {
+ name: 'Event',
+ inputs: [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"hash256","indexed":false}]
+ };
// when
- var impl = event(address, signature);
+ var impl = event(address, signature, e);
var result = impl({}, options);
// then
@@ -46,5 +55,70 @@ describe('event', function () {
});
+ it('should create filter input object with indexed params', function () {
+
+ // given
+ var address = '0x012345';
+ var signature = '0x987654';
+ var options = {
+ earliest: 1,
+ latest: 2,
+ offset: 3,
+ max: 4
+ };
+ var e = {
+ name: 'Event',
+ inputs: [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"hash256","indexed":false}]
+ };
+
+ // when
+ var impl = event(address, signature, e);
+ var result = impl({a: 4}, options);
+
+ // then
+ assert.equal(result.address, address);
+ assert.equal(result.topic.length, 2);
+ assert.equal(result.topic[0], signature);
+ assert.equal(result.topic[1], f.formatInputInt(4));
+ assert.equal(result.earliest, options.earliest);
+ assert.equal(result.latest, options.latest);
+ assert.equal(result.offset, options.offset);
+ assert.equal(result.max, options.max);
+
+ });
+
+ it('should create filter input object with an array of indexed params', function () {
+
+ // given
+ var address = '0x012345';
+ var signature = '0x987654';
+ var options = {
+ earliest: 1,
+ latest: 2,
+ offset: 3,
+ max: 4
+ };
+ var e = {
+ name: 'Event',
+ inputs: [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"hash256","indexed":false}]
+ };
+
+ // when
+ var impl = event(address, signature, e);
+ var result = impl({a: [4, 69]}, options);
+
+ // then
+ assert.equal(result.address, address);
+ assert.equal(result.topic.length, 2);
+ assert.equal(result.topic[0], signature);
+ assert.equal(result.topic[1][0], f.formatInputInt(4));
+ assert.equal(result.topic[1][1], f.formatInputInt(69));
+ assert.equal(result.earliest, options.earliest);
+ assert.equal(result.latest, options.latest);
+ assert.equal(result.offset, options.offset);
+ assert.equal(result.max, options.max);
+
+ });
+
});