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
247b20e4
Commit
247b20e4
authored
May 17, 2018
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for abiV2 coder
parent
6ed62de4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
txFormat.js
remix-lib/test/txFormat.js
+43
-0
No files found.
remix-lib/test/txFormat.js
View file @
247b20e4
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
var
tape
=
require
(
'tape'
)
var
tape
=
require
(
'tape'
)
var
txFormat
=
require
(
'../src/execution/txFormat'
)
var
txFormat
=
require
(
'../src/execution/txFormat'
)
var
txHelper
=
require
(
'../src/execution/txHelper'
)
var
txHelper
=
require
(
'../src/execution/txHelper'
)
var
util
=
require
(
'../src/util'
)
var
compiler
=
require
(
'solc'
)
var
compiler
=
require
(
'solc'
)
var
compilerInput
=
require
(
'../src/helpers/compilerHelper'
).
compilerInput
var
compilerInput
=
require
(
'../src/helpers/compilerHelper'
).
compilerInput
var
executionContext
=
require
(
'../src/execution/execution-context'
)
var
executionContext
=
require
(
'../src/execution/execution-context'
)
...
@@ -161,6 +162,28 @@ tape('test fallback function', function (t) {
...
@@ -161,6 +162,28 @@ tape('test fallback function', function (t) {
})
})
})
})
tape
(
'test abiEncoderV2'
,
function
(
t
)
{
var
functionId
=
'0x56d89238'
var
encodedData
=
'0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000042ed123b0bd8203c2700000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000090746573745f737472696e675f746573745f737472696e675f746573745f737472696e675f746573745f737472696e675f746573745f737472696e675f746573745f737472696e675f746573745f737472696e675f746573745f737472696e675f746573745f737472696e675f746573745f737472696e675f746573745f737472696e675f746573745f737472696e675f00000000000000000000000000000000'
var
value1
=
'1'
var
value2
=
'1234567890123456789543'
var
value3
=
'test_string_test_string_test_string_test_string_test_string_test_string_test_string_test_string_test_string_test_string_test_string_test_string_'
var
decodedData
=
`[
${
value1
}
,
${
value2
}
, "
${
value3
}
"], 23`
t
.
test
(
'(abiEncoderV2)'
,
function
(
st
)
{
st
.
plan
(
2
)
var
output
=
compiler
.
compileStandardWrapper
(
compilerInput
(
abiEncoderV2
))
output
=
JSON
.
parse
(
output
)
var
contract
=
output
.
contracts
[
'test.sol'
][
'test'
]
txFormat
.
encodeFunctionCall
(
decodedData
,
contract
.
abi
[
0
],
(
error
,
encoded
)
=>
{
console
.
log
(
error
)
st
.
equal
(
encoded
.
dataHex
,
functionId
+
encodedData
.
replace
(
'0x'
,
''
))
})
var
decoded
=
txFormat
.
decodeResponse
(
util
.
hexToIntArray
(
encodedData
),
contract
.
abi
[
0
])
console
.
log
(
decoded
)
st
.
equal
(
decoded
[
0
],
`tuple(uint256,uint256,string):
${
value1
}
,
${
value2
}
,
${
value3
}
`
)
})
})
var
uintContract
=
`contract uintContractTest {
var
uintContract
=
`contract uintContractTest {
uint _tp;
uint _tp;
address _ap;
address _ap;
...
@@ -208,3 +231,23 @@ contract fallbackFunctionContract {
...
@@ -208,3 +231,23 @@ contract fallbackFunctionContract {
function () {}
function () {}
}`
}`
var
abiEncoderV2
=
`pragma experimental ABIEncoderV2;
contract test {
struct p {
uint a;
uint b;
string s;
}
function t (p _p, uint _i) returns (p) {
return _p;
}
function t () returns (p) {
p mm;
mm.a = 123;
mm.b = 133;
return mm;
}
}`
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