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
27705470
Commit
27705470
authored
Feb 19, 2020
by
ioedeveloper
Committed by
yann300
Apr 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change testFunction assertion test
parent
1e4ce4a7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
62 deletions
+67
-62
txLogger.js
src/app/ui/txLogger.js
+17
-16
testFunction.js
test-browser/commands/testFunction.js
+48
-46
ballot.js
test-browser/tests/ballot.js
+2
-0
No files found.
src/app/ui/txLogger.js
View file @
27705470
...
...
@@ -210,7 +210,7 @@ function renderKnownTransaction (self, data, blockchain) {
var
obj
=
{
from
,
to
}
var
txType
=
'knownTx'
var
tx
=
yo
`
<span id="tx
${
data
.
tx
.
hash
}
">
<span id="tx
${
data
.
tx
.
hash
}
"
data-id="txLogger
${
data
.
tx
.
hash
}
"
>
<div class="
${
css
.
log
}
" onclick=
${
e
=>
txDetails
(
e
,
tx
,
data
,
obj
)}
>
${
checkTxStatus
(
data
.
receipt
,
txType
)}
${
context
(
self
,
{
from
,
to
,
data
},
blockchain
)}
...
...
@@ -384,7 +384,8 @@ function txDetails (e, tx, data, obj) {
}
function
createTable
(
opts
)
{
var
table
=
yo
`<table class="
${
css
.
txTable
}
" id="txTable"></table>`
console
.
log
(
'opts: '
,
opts
)
var
table
=
yo
`<table class="
${
css
.
txTable
}
" id="txTable" data-id="txLoggerTable
${
opts
.
hash
}
"></table>`
if
(
!
opts
.
isCall
)
{
var
msg
=
''
if
(
opts
.
status
!==
undefined
&&
opts
.
status
!==
null
)
{
...
...
@@ -399,14 +400,14 @@ function createTable (opts) {
table
.
appendChild
(
yo
`
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> status </td>
<td class="
${
css
.
td
}
">
${
opts
.
status
}${
msg
}
</td>
<td class="
${
css
.
td
}
"
data-id="txLoggerTableStatus
${
opts
.
hash
}
"
>
${
opts
.
status
}${
msg
}
</td>
</tr>`
)
}
var
transactionHash
=
yo
`
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> transaction hash </td>
<td class="
${
css
.
td
}
">
${
opts
.
hash
}
<td class="
${
css
.
td
}
"
data-id="txLoggerTableHash
${
opts
.
hash
}
"
>
${
opts
.
hash
}
${
copyToClipboard
(()
=>
opts
.
hash
)}
</td>
</tr>
...
...
@@ -416,7 +417,7 @@ function createTable (opts) {
var
contractAddress
=
yo
`
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> contract address </td>
<td class="
${
css
.
td
}
">
${
opts
.
contractAddress
}
<td class="
${
css
.
td
}
"
data-id="txLoggerTableContractAddress
${
opts
.
hash
}
"
>
${
opts
.
contractAddress
}
${
copyToClipboard
(()
=>
opts
.
contractAddress
)}
</td>
</tr>
...
...
@@ -426,7 +427,7 @@ function createTable (opts) {
var
from
=
yo
`
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
${
css
.
tableTitle
}
"> from </td>
<td class="
${
css
.
td
}
">
${
opts
.
from
}
<td class="
${
css
.
td
}
"
data-id="txLoggerTableFrom
${
opts
.
hash
}
"
>
${
opts
.
from
}
${
copyToClipboard
(()
=>
opts
.
from
)}
</td>
</tr>
...
...
@@ -443,7 +444,7 @@ function createTable (opts) {
var
to
=
yo
`
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> to </td>
<td class="
${
css
.
td
}
">
${
toHash
}
<td class="
${
css
.
td
}
"
data-id="txLoggerTableTo
${
opts
.
hash
}
"
>
${
toHash
}
${
copyToClipboard
(()
=>
data
.
to
?
data
.
to
:
toHash
)}
</td>
</tr>
...
...
@@ -453,7 +454,7 @@ function createTable (opts) {
var
gas
=
yo
`
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> gas </td>
<td class="
${
css
.
td
}
">
${
opts
.
gas
}
gas
<td class="
${
css
.
td
}
"
data-id="txLoggerTableGas
${
opts
.
hash
}
"
>
${
opts
.
gas
}
gas
${
copyToClipboard
(()
=>
opts
.
gas
)}
</td>
</tr>
...
...
@@ -468,7 +469,7 @@ function createTable (opts) {
table
.
appendChild
(
yo
`
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> transaction cost </td>
<td class="
${
css
.
td
}
">
${
opts
.
transactionCost
}
gas
${
callWarning
}
<td class="
${
css
.
td
}
"
data-id="txLoggerTableTransactionCost
${
opts
.
hash
}
"
>
${
opts
.
transactionCost
}
gas
${
callWarning
}
${
copyToClipboard
(()
=>
opts
.
transactionCost
)}
</td>
</tr>`
)
...
...
@@ -478,7 +479,7 @@ function createTable (opts) {
table
.
appendChild
(
yo
`
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> execution cost </td>
<td class="
${
css
.
td
}
">
${
opts
.
executionCost
}
gas
${
callWarning
}
<td class="
${
css
.
td
}
"
data-id="txLoggerTableExecutionHash
${
opts
.
hash
}
"
>
${
opts
.
executionCost
}
gas
${
callWarning
}
${
copyToClipboard
(()
=>
opts
.
executionCost
)}
</td>
</tr>`
)
...
...
@@ -487,7 +488,7 @@ function createTable (opts) {
var
hash
=
yo
`
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> hash </td>
<td class="
${
css
.
td
}
">
${
opts
.
hash
}
<td class="
${
css
.
td
}
"
data-id="txLoggerTableHash
${
opts
.
hash
}
"
>
${
opts
.
hash
}
${
copyToClipboard
(()
=>
opts
.
hash
)}
</td>
</tr>
...
...
@@ -497,7 +498,7 @@ function createTable (opts) {
var
input
=
yo
`
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> input </td>
<td class="
${
css
.
td
}
">
${
helper
.
shortenHexData
(
opts
.
input
)}
<td class="
${
css
.
td
}
"
data-id="txLoggerTableInput
${
opts
.
hash
}
"
>
${
helper
.
shortenHexData
(
opts
.
input
)}
${
copyToClipboard
(()
=>
opts
.
input
)}
</td>
</tr>
...
...
@@ -508,7 +509,7 @@ function createTable (opts) {
var
inputDecoded
=
yo
`
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> decoded input </td>
<td class="
${
css
.
td
}
">
${
opts
[
'decoded input'
]}
<td class="
${
css
.
td
}
"
data-id="txLoggerTableDecodedInput
${
opts
.
hash
}
"
>
${
opts
[
'decoded input'
]}
${
copyToClipboard
(()
=>
opts
[
'decoded input'
])}
</td>
</tr>`
...
...
@@ -519,7 +520,7 @@ function createTable (opts) {
var
outputDecoded
=
yo
`
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> decoded output </td>
<td class="
${
css
.
td
}
" id="decodedoutput" >
${
opts
[
'decoded output'
]}
<td class="
${
css
.
td
}
" id="decodedoutput"
data-id="txLoggerTableDecodedOutput
${
opts
.
hash
}
"
>
${
opts
[
'decoded output'
]}
${
copyToClipboard
(()
=>
opts
[
'decoded output'
])}
</td>
</tr>`
...
...
@@ -533,7 +534,7 @@ function createTable (opts) {
var
logs
=
yo
`
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> logs </td>
<td class="
${
css
.
td
}
" id="logs">
<td class="
${
css
.
td
}
" id="logs"
data-id="txLoggerTableLogs
${
opts
.
hash
}
"
>
${
JSON
.
stringify
(
stringified
,
null
,
'
\
t'
)}
${
copyToClipboard
(()
=>
JSON
.
stringify
(
stringified
,
null
,
'
\
t'
))}
${
copyToClipboard
(()
=>
JSON
.
stringify
(
opts
.
logs
.
raw
||
'0'
))}
...
...
@@ -546,7 +547,7 @@ function createTable (opts) {
val
=
yo
`
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> value </td>
<td class="
${
css
.
td
}
">
${
val
}
wei
<td class="
${
css
.
td
}
"
data-id="txLoggerTableValue
${
opts
.
hash
}
"
>
${
val
}
wei
${
copyToClipboard
(()
=>
`
${
val
}
wei`
)}
</td>
</tr>
...
...
test-browser/commands/testFunction.js
View file @
27705470
const
EventEmitter
=
require
(
'events'
)
const
deepequal
=
require
(
'deep-equal'
)
class
TestFunction
extends
EventEmitter
{
command
(
fnFullName
,
txHash
,
log
,
expectedInput
,
expectedReturn
,
expectedEvent
,
callback
)
{
this
.
api
.
waitForElementPresent
(
'.instance button[title="'
+
fnFullName
+
'"]'
)
.
perform
(
function
(
client
,
done
)
{
client
.
execute
(
function
()
{
document
.
querySelector
(
'#runTabView'
).
scrollTop
=
document
.
querySelector
(
'#runTabView'
).
scrollHeight
},
[],
function
()
{
if
(
expectedInput
)
{
client
.
setValue
(
'#runTabView input[title="'
+
expectedInput
.
types
+
'"]'
,
expectedInput
.
values
,
function
()
{})
}
done
()
})
})
.
click
(
'.instance button[title="'
+
fnFullName
+
'"]'
)
.
pause
(
500
)
.
waitForElementPresent
(
'#main-panel div[class^="terminal"] span[id="tx'
+
txHash
+
'"]'
)
.
assert
.
containsText
(
'#main-panel div[class^="terminal"] span[id="tx'
+
txHash
+
'"] span'
,
log
)
.
click
(
'#main-panel div[class^="terminal"] span[id="tx'
+
txHash
+
'"] div[class^="log"]'
)
.
perform
(
function
(
client
,
done
)
{
if
(
expectedReturn
)
{
client
.
getText
(
'#main-panel div[class^="terminal"] span[id="tx'
+
txHash
+
'"] table[class^="txTable"] #decodedoutput'
,
(
result
)
=>
{
console
.
log
(
result
)
var
equal
=
deepequal
(
JSON
.
parse
(
result
.
value
),
JSON
.
parse
(
expectedReturn
))
if
(
!
equal
)
{
client
.
assert
.
fail
(
'expected '
+
expectedReturn
+
' got '
+
result
.
value
,
'info about error'
,
''
)
}
})
}
done
()
})
.
perform
((
client
,
done
)
=>
{
if
(
expectedEvent
)
{
client
.
getText
(
'#main-panel div[class^="terminal"] span[id="tx'
+
txHash
+
'"] table[class^="txTable"] #logs'
,
(
result
)
=>
{
console
.
log
(
result
)
var
equal
=
deepequal
(
JSON
.
parse
(
result
.
value
),
JSON
.
parse
(
expectedEvent
))
if
(
!
equal
)
{
client
.
assert
.
fail
(
'expected '
+
expectedEvent
+
' got '
+
result
.
value
,
'info about error'
,
''
)
}
})
}
done
()
if
(
callback
)
{
callback
.
call
(
this
.
api
)
}
/*
Checks if any child elements of journal (console) contains a matching value.
*/
class
testTransactionLog
extends
EventEmitter
{
command
(
txHash
,
expectedValue
)
{
const
browser
=
this
.
api
;
browser
.
perform
(()
=>
{
const
result
=
parseTransactionLog
(
this
.
api
,
txHash
)
this
.
emit
(
'complete'
)
})
return
this
}
}
module
.
exports
=
TestFunction
function
parseTransactionLog
(
browser
,
txHash
){
const
logs
=
{
status
:
''
,
'transaction hash'
:
''
,
'contract address'
:
''
,
from
:
''
,
to
:
''
,
gas
:
''
,
'transaction cost'
:
''
,
'execution cost'
:
''
,
hash
:
''
,
input
:
''
,
'decoded input'
:
''
,
'decoded output'
:
''
,
logs
:
''
,
value
:
''
}
browser
.
waitForElementVisible
(
'txLoggerTable'
+
txHash
)
.
getText
(
`*[data-id="txLoggerTableStatus
${
txHash
}
"]`
,
(
result
)
=>
logs
.
status
=
result
)
.
getText
(
`*[data-id="txLoggerTableTransactionHash
${
txHash
}
"]`
,
(
result
)
=>
logs
[
'transaction hash'
]
=
result
)
.
getText
(
`*[data-id="txLoggerTableContractAddress
${
txHash
}
"]`
,
(
result
)
=>
logs
[
'contract address'
]
=
result
)
.
getText
(
`*[data-id="txLoggerTableFrom
${
txHash
}
"]`
,
(
result
)
=>
logs
.
from
=
result
)
.
getText
(
`*[data-id="txLoggerTableTo
${
txHash
}
"]`
,
(
result
)
=>
logs
.
to
=
result
)
.
getText
(
`*[data-id="txLoggerTableGas
${
txHash
}
"]`
,
(
result
)
=>
logs
.
gas
=
result
)
.
getText
(
`*[data-id="txLoggerTableTransactionCost
${
txHash
}
"]`
,
(
result
)
=>
logs
[
'transaction cost'
]
=
result
)
.
getText
(
`*[data-id="txLoggerTableExecutionCost
${
txHash
}
"]`
,
(
result
)
=>
logs
[
'execution cost'
]
=
result
)
.
getText
(
`*[data-id="txLoggerTableHash
${
txHash
}
"]`
,
(
result
)
=>
logs
.
hash
=
result
)
.
getText
(
`*[data-id="txLoggerTableInput
${
txHash
}
"]`
,
(
result
)
=>
logs
.
input
=
result
)
.
getText
(
`*[data-id="txLoggerTableDecodedInput
${
txHash
}
"]`
,
(
result
)
=>
logs
[
'decoded input'
]
=
result
)
.
getText
(
`*[data-id="txLoggerTableDecodedOutput
${
txHash
}
"]`
,
(
result
)
=>
logs
[
'decoded output'
]
=
result
)
.
getText
(
`*[data-id="txLoggerTableDecodedLogs
${
txHash
}
"]`
,
(
result
)
=>
logs
.
logs
=
result
)
.
getText
(
`*[data-id="txLoggerTableDecodedLogs
${
txHash
}
"]`
,
(
result
)
=>
logs
.
value
=
result
)
return
logs
;
}
module
.
exports
=
testFunction
\ No newline at end of file
test-browser/tests/ballot.js
View file @
27705470
...
...
@@ -25,6 +25,8 @@ module.exports = {
.
click
(
'#runTabView button[class^="instanceButton"]'
)
.
waitForElementPresent
(
'.instance:nth-of-type(2)'
)
.
click
(
'.instance:nth-of-type(2) > div > button'
)
.
createContract
([
"0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3"
])
.
pause
(
100000
)
.
testFunction
(
'delegate - transact (not payable)'
,
'0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3'
,
`[vm]\nfrom:0xca3...a733c\nto:Ballot.delegate(address) 0x692...77b3a\nvalue:0 wei\ndata:0x5c1...4d2db\nlogs:0\nhash:0x41f...c31b3`
,
{
types
:
'address to'
,
values
:
'"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'
},
null
,
null
)
...
...
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