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
2203ab4f
Commit
2203ab4f
authored
Apr 23, 2020
by
aniket-engg
Committed by
Aniket
Apr 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
invalid tuple input throws error
parent
f55409e4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
2 deletions
+45
-2
txFormat.js
remix-lib/src/execution/txFormat.js
+9
-1
traceManager.js
remix-lib/test/traceManager.js
+0
-1
txFormat.js
remix-lib/test/txFormat.js
+36
-0
No files found.
remix-lib/src/execution/txFormat.js
View file @
2203ab4f
...
...
@@ -401,8 +401,12 @@ module.exports = {
endQuoteIndex
=
true
i
=
j
}
// Throw error if end of params string is arrived but couldn't get end quote
if
(
!
endQuoteIndex
&&
j
===
params
.
length
-
1
)
{
throw
new
Error
(
'invalid params'
)
}
}
}
else
if
(
params
.
charAt
(
i
)
===
'['
)
{
// If a
array
opening bracket is received
}
else
if
(
params
.
charAt
(
i
)
===
'['
)
{
// If a
n array/struct
opening bracket is received
startIndex
=
-
1
let
bracketCount
=
1
let
j
...
...
@@ -413,6 +417,10 @@ module.exports = {
}
else
if
(
params
.
charAt
(
j
)
===
']'
)
{
// // Decrease count if an array closing bracket is received (To handle nested array)
bracketCount
--
}
// Throw error if end of params string is arrived but couldn't get end of tuple
if
(
bracketCount
!==
0
&&
j
===
params
.
length
-
1
)
{
throw
new
Error
(
'invalid tuple params'
)
}
}
// If bracketCount = 0, it means complete array/nested array parsed, push it to the arguments list
args
.
push
(
JSON
.
parse
(
params
.
substring
(
i
,
j
)))
...
...
remix-lib/test/traceManager.js
View file @
2203ab4f
...
...
@@ -309,7 +309,6 @@ tape('TraceManager', function (t) {
t
.
test
(
'TraceManager.getReturnValue'
,
function
(
st
)
{
traceManager
.
getReturnValue
(
108
,
function
(
error
,
result
)
{
console
.
log
(
'result------->'
,
result
)
if
(
error
)
{
st
.
fail
(
error
)
}
else
{
...
...
remix-lib/test/txFormat.js
View file @
2203ab4f
...
...
@@ -125,6 +125,28 @@ function testWithNestedArrayInput (st, params, expected) {
},
()
=>
{},
()
=>
{})
}
tape
(
'abiEncoderV2InvalidTuple - (TxFormat.buildData) - should throw error for invalid tuple value'
,
function
(
t
)
{
let
output
=
compiler
.
compile
(
compilerInput
(
abiEncoderV2InvalidTuple
))
output
=
JSON
.
parse
(
output
)
let
contract
=
output
.
contracts
[
'test.sol'
][
'test'
]
context
=
{
output
,
contract
}
t
.
test
(
'(TxFormat.buildData)'
,
function
(
st
)
{
st
.
plan
(
4
)
testInvalidTupleInput
(
st
,
'[11, 12, "13"'
)
testInvalidTupleInput
(
st
,
'[11, 12, 13'
)
testInvalidTupleInput
(
st
,
'[11, 12, "13'
)
testInvalidTupleInput
(
st
,
'[11, 12, 13"'
)
})
})
function
testInvalidTupleInput
(
st
,
params
)
{
txFormat
.
buildData
(
'abiEncoderV2InvalidTuple'
,
context
.
contract
,
context
.
output
.
contracts
,
true
,
context
.
contract
.
abi
[
2
],
params
,
(
error
,
data
)
=>
{
if
(
error
)
{
return
st
.
ok
(
error
.
includes
(
'Error encoding arguments: Error: invalid tuple params'
),
'should fail because of invalid tuple input'
)
}
},
()
=>
{},
()
=>
{})
}
/* tape *********************************************************** */
tape
(
'ContractParameters - (TxFormat.buildData) - link Libraries'
,
function
(
t
)
{
...
...
@@ -411,6 +433,20 @@ contract test {
mm.b = 133;
return mm;
}
function t2 (p memory _p) public {}
}`
const
abiEncoderV2InvalidTuple
=
`pragma experimental ABIEncoderV2;
contract test {
struct p {
uint a;
uint b;
string s;
}
function t2 (p memory _p) public {}
}`
const
abiEncoderV2ArrayOfTuple
=
`pragma experimental ABIEncoderV2;
...
...
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