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
2544d2c9
Commit
2544d2c9
authored
Jan 28, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests for abi.filters
parent
ea7c2fc6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
1 deletion
+59
-1
abi.js
lib/abi.js
+10
-1
abi.filters.js
test/abi.filters.js
+49
-0
No files found.
lib/abi.js
View file @
2544d2c9
...
...
@@ -73,6 +73,14 @@ var filterFunctions = function (json) {
});
};
/// Filters all events form input abi
/// @returns abi array with filtered objects of type 'event'
var
filterEvents
=
function
(
json
)
{
return
json
.
filter
(
function
(
current
)
{
return
current
.
type
===
'event'
;
});
};
/// @param string string to be padded
/// @param number of characters that result string should have
/// @param sign, by default 0
...
...
@@ -414,6 +422,7 @@ module.exports = {
methodDisplayName
:
methodDisplayName
,
methodTypeName
:
methodTypeName
,
getMethodWithName
:
getMethodWithName
,
filterFunctions
:
filterFunctions
filterFunctions
:
filterFunctions
,
filterEvents
:
filterEvents
};
test/abi.filters.js
0 → 100644
View file @
2544d2c9
var
assert
=
require
(
'assert'
);
var
abi
=
require
(
'../lib/abi.js'
);
describe
(
'abi'
,
function
()
{
it
(
'should filter functions and events from input array properly'
,
function
()
{
// given
var
description
=
[{
"name"
:
"test"
,
"type"
:
"function"
,
"inputs"
:
[{
"name"
:
"a"
,
"type"
:
"uint256"
}
],
"outputs"
:
[
{
"name"
:
"d"
,
"type"
:
"uint256"
}
],
},
{
"name"
:
"test2"
,
"type"
:
"event"
,
"inputs"
:
[{
"name"
:
"a"
,
"type"
:
"uint256"
}
],
"outputs"
:
[
{
"name"
:
"d"
,
"type"
:
"uint256"
}
]
}];
// when
var
events
=
abi
.
filterEvents
(
description
);
var
functions
=
abi
.
filterFunctions
(
description
);
// then
assert
.
equal
(
events
.
length
,
1
);
assert
.
equal
(
events
[
0
].
name
,
'test2'
);
assert
.
equal
(
functions
.
length
,
1
);
assert
.
equal
(
functions
[
0
].
name
,
'test'
);
});
});
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