Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
8f6cd8f9
Unverified
Commit
8f6cd8f9
authored
Feb 27, 2018
by
yann300
Committed by
GitHub
Feb 27, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #702 from ethereum/fixFormatInputParam
Fix format input param
parents
00b36f63
8adb25cb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
0 deletions
+43
-0
txFormat.js
remix-lib/src/execution/txFormat.js
+2
-0
tests.js
remix-lib/test/tests.js
+1
-0
txFormat.js
remix-lib/test/txFormat.js
+40
-0
No files found.
remix-lib/src/execution/txFormat.js
View file @
8f6cd8f9
...
@@ -51,6 +51,8 @@ module.exports = {
...
@@ -51,6 +51,8 @@ module.exports = {
data
=
Buffer
.
from
(
dataHex
,
'hex'
)
data
=
Buffer
.
from
(
dataHex
,
'hex'
)
}
else
{
}
else
{
try
{
try
{
params
=
params
.
replace
(
/
(
^|,
\s
+|,
)(\d
+
)(\s
+,|,|$
)
/g
,
'$1"$2"$3'
)
// replace non quoted number by quoted number
params
=
params
.
replace
(
/
(
^|,
\s
+|,
)(
0
[
xX
][
0-9a-fA-F
]
+
)(\s
+,|,|$
)
/g
,
'$1"$2"$3'
)
// replace non quoted hex string by quoted hex string
funArgs
=
JSON
.
parse
(
'['
+
params
+
']'
)
funArgs
=
JSON
.
parse
(
'['
+
params
+
']'
)
}
catch
(
e
)
{
}
catch
(
e
)
{
callback
(
'Error encoding arguments: '
+
e
)
callback
(
'Error encoding arguments: '
+
e
)
...
...
remix-lib/test/tests.js
View file @
8f6cd8f9
...
@@ -2,3 +2,4 @@ require('./astwalker.js')
...
@@ -2,3 +2,4 @@ require('./astwalker.js')
require
(
'./eventManager.js'
)
require
(
'./eventManager.js'
)
require
(
'./sourceMappingDecoder.js'
)
require
(
'./sourceMappingDecoder.js'
)
require
(
'./util.js'
)
require
(
'./util.js'
)
require
(
'./txFormat.js'
)
remix-lib/test/txFormat.js
0 → 100644
View file @
8f6cd8f9
'use strict'
var
tape
=
require
(
'tape'
)
var
txFormat
=
require
(
'../src/execution/txFormat'
)
var
compiler
=
require
(
'solc'
)
var
compilerInput
=
require
(
'../src/helpers/compilerHelper'
).
compilerInput
var
context
tape
(
'ContractParameters - (TxFormat.buildData)'
,
function
(
t
)
{
var
output
=
compiler
.
compileStandardWrapper
(
compilerInput
(
uintContract
))
output
=
JSON
.
parse
(
output
)
var
contract
=
output
.
contracts
[
'test.sol'
][
'uintContractTest'
]
var
udapp
=
{
runTx
:
()
=>
{}
}
// fake
context
=
{
output
,
contract
,
udapp
}
var
bytecode
=
'6060604052341561000f57600080fd5b6101058061001e6000396000f300606060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680634b521953146044575b600080fd5b3415604e57600080fd5b608a600480803590602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050608c565b005b8260008190555081600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050505600a165627a7a72305820e2f31aca91b90c01fe46fd2de5b3788ba02f577f9858e6aae48800e29db122670029'
t
.
test
(
'(TxFormat.buildData)'
,
function
(
st
)
{
st
.
plan
(
3
)
testWithInput
(
st
,
'123123, "0xf7a10e525d4b168f45f74db1b61f63d3e7619ea8", "34"'
,
bytecode
+
'000000000000000000000000000000000000000000000000000000000001e0f3000000000000000000000000f7a10e525d4b168f45f74db1b61f63d3e7619ea80000000000000000000000000000000000000000000000000000000000000022'
)
testWithInput
(
st
,
'"123123" , 0xf7a10e525d4b168f45f74db1b61f63d3e7619ea8, 654 '
,
bytecode
+
'000000000000000000000000000000000000000000000000000000000001e0f3000000000000000000000000f7a10e525d4b168f45f74db1b61f63d3e7619ea8000000000000000000000000000000000000000000000000000000000000028e'
)
// parsing this as javascript number should overflow
testWithInput
(
st
,
'90071992547409910000, 0xf7a10e525d4b168f45f74db1b61f63d3e7619ea8, 0'
,
bytecode
+
'000000000000000000000000000000000000000000000004e1ffffffffffd8f0000000000000000000000000f7a10e525d4b168f45f74db1b61f63d3e7619ea80000000000000000000000000000000000000000000000000000000000000000'
)
})
})
function
testWithInput
(
st
,
params
,
expected
)
{
txFormat
.
buildData
(
'uintContractTest'
,
context
.
contract
,
context
.
output
.
contracts
,
true
,
context
.
contract
.
abi
[
0
],
params
,
context
.
udapp
,
(
error
,
data
)
=>
{
if
(
error
)
{
return
st
.
fails
(
error
)
}
console
.
log
(
data
)
st
.
equal
(
data
.
dataHex
,
expected
)
},
()
=>
{})
}
var
uintContract
=
`contract uintContractTest {
uint _tp;
address _ap;
function test(uint _t, address _a, uint _i) {
_tp = _t;
_ap = _a;
}
}`
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