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
380d9862
Commit
380d9862
authored
Jan 13, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests in progress, fixed utf characters conversion in toAscii
parent
9e0de57a
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
132 additions
and
26 deletions
+132
-26
ethereum.js
dist/ethereum.js
+2
-2
ethereum.js.map
dist/ethereum.js.map
+1
-1
ethereum.min.js
dist/ethereum.min.js
+1
-1
web3.js
lib/web3.js
+2
-2
abi.parsers.js
test/abi.parsers.js
+126
-20
No files found.
dist/ethereum.js
View file @
380d9862
...
...
@@ -823,12 +823,12 @@ var web3 = {
if
(
hex
.
substring
(
0
,
2
)
===
'0x'
)
i
=
2
;
for
(;
i
<
l
;
i
+=
2
)
{
var
code
=
hex
.
charCodeAt
(
i
);
var
code
=
parseInt
(
hex
.
substr
(
i
,
2
),
16
);
if
(
code
===
0
)
{
break
;
}
str
+=
String
.
fromCharCode
(
parseInt
(
hex
.
substr
(
i
,
2
),
16
)
);
str
+=
String
.
fromCharCode
(
code
);
}
return
str
;
...
...
dist/ethereum.js.map
View file @
380d9862
This diff is collapsed.
Click to expand it.
dist/ethereum.min.js
View file @
380d9862
This diff is collapsed.
Click to expand it.
lib/web3.js
View file @
380d9862
...
...
@@ -244,12 +244,12 @@ var web3 = {
if
(
hex
.
substring
(
0
,
2
)
===
'0x'
)
i
=
2
;
for
(;
i
<
l
;
i
+=
2
)
{
var
code
=
hex
.
charCodeAt
(
i
);
var
code
=
parseInt
(
hex
.
substr
(
i
,
2
),
16
);
if
(
code
===
0
)
{
break
;
}
str
+=
String
.
fromCharCode
(
parseInt
(
hex
.
substr
(
i
,
2
),
16
)
);
str
+=
String
.
fromCharCode
(
code
);
}
return
str
;
...
...
test/abi.parsers.js
View file @
380d9862
#
vim
:
et
var
assert
=
require
(
'assert'
);
var
abi
=
require
(
'../lib/abi.js'
);
var
clone
=
function
(
object
)
{
return
JSON
.
parse
(
JSON
.
stringify
(
object
));
};
var
description
=
[{
"name"
:
"test"
,
"inputs"
:
[{
"name"
:
"a"
,
"type"
:
"uint256"
}
],
"outputs"
:
[
{
"name"
:
"d"
,
"type"
:
"uint256"
}
]
}];
describe
(
'abi'
,
function
()
{
describe
(
'inputParser'
,
function
()
{
it
(
'should parse ...'
,
function
()
{
var
desc
=
[{
"name"
:
"multiply"
,
"inputs"
:
[
{
"name"
:
"a"
,
"type"
:
"uint256"
}
],
"outputs"
:
[
{
"name"
:
"d"
,
"type"
:
"uint256"
}
]
}];
var
iParser
=
abi
.
inputParser
(
desc
);
assert
.
equal
(
iParser
.
multiply
(
1
),
"0x000000000000000000000000000000000000000000000000000000000000000001"
);
it
(
'should parse input uint'
,
function
()
{
var
d
=
clone
(
description
);
d
[
0
].
inputs
=
[
{
type
:
"uint256"
}
];
var
parser
=
abi
.
inputParser
(
d
);
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
assert
.
equal
(
parser
.
test
(
10
),
"000000000000000000000000000000000000000000000000000000000000000a"
);
d
[
0
].
inputs
=
[
{
type
:
"uint128"
}
];
var
parser
=
abi
.
inputParser
(
d
);
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
assert
.
equal
(
parser
.
test
(
10
),
"000000000000000000000000000000000000000000000000000000000000000a"
);
d
[
0
].
inputs
=
[
{
type
:
"uint"
}
];
var
parser
=
abi
.
inputParser
(
d
);
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
assert
.
equal
(
parser
.
test
(
10
),
"000000000000000000000000000000000000000000000000000000000000000a"
);
});
it
(
'should parse input int'
,
function
()
{
var
d
=
clone
(
description
);
d
[
0
].
inputs
=
[
{
type
:
"int256"
}
];
var
parser
=
abi
.
inputParser
(
d
);
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
assert
.
equal
(
parser
.
test
(
10
),
"000000000000000000000000000000000000000000000000000000000000000a"
);
d
[
0
].
inputs
=
[
{
type
:
"int128"
}
];
var
parser
=
abi
.
inputParser
(
d
);
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
assert
.
equal
(
parser
.
test
(
10
),
"000000000000000000000000000000000000000000000000000000000000000a"
);
d
[
0
].
inputs
=
[
{
type
:
"int"
}
];
var
parser
=
abi
.
inputParser
(
d
);
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
assert
.
equal
(
parser
.
test
(
10
),
"000000000000000000000000000000000000000000000000000000000000000a"
);
});
it
(
'should parse input hash'
,
function
()
{
var
d
=
clone
(
description
);
d
[
0
].
inputs
=
[
{
type
:
"hash256"
}
];
var
parser
=
abi
.
inputParser
(
d
);
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
d
[
0
].
inputs
=
[
{
type
:
"hash128"
}
];
var
parser
=
abi
.
inputParser
(
d
);
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
d
[
0
].
inputs
=
[
{
type
:
"hash"
}
];
var
parser
=
abi
.
inputParser
(
d
);
assert
.
equal
(
parser
.
test
(
1
),
"0000000000000000000000000000000000000000000000000000000000000001"
);
});
it
(
'should parse input string'
,
function
()
{
var
d
=
clone
(
description
);
d
[
0
].
inputs
=
[
{
type
:
"string"
}
];
var
parser
=
abi
.
inputParser
(
d
);
assert
.
equal
(
parser
.
test
(
'hello'
),
"68656c6c6f000000000000000000000000000000000000000000000000000000"
);
assert
.
equal
(
parser
.
test
(
'world'
),
"776f726c64000000000000000000000000000000000000000000000000000000"
);
});
});
describe
(
'outputParser'
,
function
()
{
it
(
'parse ...'
,
function
()
{
var
d
=
clone
(
description
);
d
[
0
].
outputs
=
[
{
type
:
"string"
}
];
var
parser
=
abi
.
outputParser
(
d
);
assert
.
equal
(
parser
.
test
(
"0x68656c6c6f00000000000000000000000000000000000000000000000000000"
)[
0
],
'hello'
);
assert
.
equal
(
parser
.
test
(
"0x776f726c6400000000000000000000000000000000000000000000000000000"
)[
0
],
'world'
);
});
});
...
...
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