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
603c7902
Commit
603c7902
authored
Jan 14, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
next part of abi.js parsers tests and fixes
parent
b0a9bbf3
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
211 additions
and
21 deletions
+211
-21
ethereum.js
dist/ethereum.js
+6
-2
ethereum.js.map
dist/ethereum.js.map
+2
-2
ethereum.min.js
dist/ethereum.min.js
+1
-1
abi.js
lib/abi.js
+6
-2
abi.parsers.js
test/abi.parsers.js
+196
-14
No files found.
dist/ethereum.js
View file @
603c7902
...
...
@@ -111,7 +111,7 @@ var setupInputTypes = function () {
{
type
:
prefixedType
(
'string'
),
format
:
formatString
},
{
type
:
prefixedType
(
'real'
),
format
:
formatInt
},
{
type
:
prefixedType
(
'ureal'
),
format
:
formatInt
},
{
type
:
namedType
(
'address'
)
},
{
type
:
namedType
(
'address'
)
,
format
:
formatInt
},
{
type
:
namedType
(
'bool'
),
format
:
formatBool
}
];
};
...
...
@@ -173,6 +173,10 @@ var setupOutputTypes = function () {
return
web3
.
toAscii
(
value
);
};
var
formatAddress
=
function
(
value
)
{
return
"0x"
+
value
.
slice
(
value
.
length
-
40
,
value
.
length
);
};
return
[
{
type
:
prefixedType
(
'uint'
),
format
:
formatInt
},
{
type
:
prefixedType
(
'int'
),
format
:
formatInt
},
...
...
@@ -180,7 +184,7 @@ var setupOutputTypes = function () {
{
type
:
prefixedType
(
'string'
),
format
:
formatString
},
{
type
:
prefixedType
(
'real'
),
format
:
formatInt
},
{
type
:
prefixedType
(
'ureal'
),
format
:
formatInt
},
{
type
:
namedType
(
'address'
)
},
{
type
:
namedType
(
'address'
)
,
format
:
formatAddress
},
{
type
:
namedType
(
'bool'
),
format
:
formatBool
}
];
};
...
...
dist/ethereum.js.map
View file @
603c7902
This diff is collapsed.
Click to expand it.
dist/ethereum.min.js
View file @
603c7902
This diff is collapsed.
Click to expand it.
lib/abi.js
View file @
603c7902
...
...
@@ -110,7 +110,7 @@ var setupInputTypes = function () {
{
type
:
prefixedType
(
'string'
),
format
:
formatString
},
{
type
:
prefixedType
(
'real'
),
format
:
formatInt
},
{
type
:
prefixedType
(
'ureal'
),
format
:
formatInt
},
{
type
:
namedType
(
'address'
)
},
{
type
:
namedType
(
'address'
)
,
format
:
formatInt
},
{
type
:
namedType
(
'bool'
),
format
:
formatBool
}
];
};
...
...
@@ -172,6 +172,10 @@ var setupOutputTypes = function () {
return
web3
.
toAscii
(
value
);
};
var
formatAddress
=
function
(
value
)
{
return
"0x"
+
value
.
slice
(
value
.
length
-
40
,
value
.
length
);
};
return
[
{
type
:
prefixedType
(
'uint'
),
format
:
formatInt
},
{
type
:
prefixedType
(
'int'
),
format
:
formatInt
},
...
...
@@ -179,7 +183,7 @@ var setupOutputTypes = function () {
{
type
:
prefixedType
(
'string'
),
format
:
formatString
},
{
type
:
prefixedType
(
'real'
),
format
:
formatInt
},
{
type
:
prefixedType
(
'ureal'
),
format
:
formatInt
},
{
type
:
namedType
(
'address'
)
},
{
type
:
namedType
(
'address'
)
,
format
:
formatAddress
},
{
type
:
namedType
(
'bool'
),
format
:
formatBool
}
];
};
...
...
test/abi.parsers.js
View file @
603c7902
...
...
@@ -146,7 +146,7 @@ describe('abi', function() {
});
it
(
'should parse input hash'
,
function
()
{
/*
// given
var
d
=
clone
(
description
);
...
...
@@ -158,46 +158,61 @@ describe('abi', function() {
var
parser
=
abi
.
inputParser
(
d
);
// then
assert.equal(parser.test(
1), "000000000000000000000000000000000000000000000000000000000000000
1");
*/
assert
.
equal
(
parser
.
test
(
"0x407d73d8a49eeb85d32cf465507dd71d507100c1"
),
"000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c
1"
);
});
it
(
'should parse input hash
128
'
,
function
()
{
/*
it
(
'should parse input hash
256
'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
inputs
=
[
{ type: "hash
128
" }
{
type
:
"hash
256
"
}
];
// when
var
parser
=
abi
.
inputParser
(
d
);
// then
assert.equal(parser.test(
1), "000000000000000000000000000000000000000000000000000000000000000
1");
*/
assert
.
equal
(
parser
.
test
(
"0x407d73d8a49eeb85d32cf465507dd71d507100c1"
),
"000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c
1"
);
});
it
(
'should parse input hash'
,
function
()
{
/*
it
(
'should parse input hash160'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
inputs
=
[
{ type: "hash" }
{
type
:
"hash
160
"
}
];
// when
var
parser
=
abi
.
inputParser
(
d
);
// then
assert.equal(parser.test(1), "0000000000000000000000000000000000000000000000000000000000000001");
*/
assert
.
equal
(
parser
.
test
(
"0x407d73d8a49eeb85d32cf465507dd71d507100c1"
),
"000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
);
});
it
(
'should parse input address'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
inputs
=
[
{
type
:
"address"
}
];
// when
var
parser
=
abi
.
inputParser
(
d
)
// then
assert
.
equal
(
parser
.
test
(
"0x407d73d8a49eeb85d32cf465507dd71d507100c1"
),
"000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
);
});
it
(
'should parse input string'
,
function
()
{
it
(
'should parse input string'
,
function
()
{
// given
var
d
=
clone
(
description
);
...
...
@@ -272,7 +287,174 @@ describe('abi', function() {
assert
.
equal
(
parser
.
test
(
"0x776f726c64000000000000000000000000000000000000000000000000000000"
)[
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
);
});
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
);
});
it
(
'should parse output uint128'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'uinti128'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000000000000000000000000000000000000000000a"
)[
0
],
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
);
});
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
);
});
it
(
'should parse output int128'
,
function
()
{
// given
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
'inti128'
}
];
// when
var
parser
=
abi
.
outputParser
(
d
);
// then
assert
.
equal
(
parser
.
test
(
"0x0000000000000000000000000000000000000000000000000000000000000001"
)[
0
],
1
);
assert
.
equal
(
parser
.
test
(
"0x000000000000000000000000000000000000000000000000000000000000000a"
)[
0
],
10
);
});
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
:
'hash256'
}
];
// 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
...
...
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