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) {
...
@@ -210,7 +210,7 @@ function renderKnownTransaction (self, data, blockchain) {
var
obj
=
{
from
,
to
}
var
obj
=
{
from
,
to
}
var
txType
=
'knownTx'
var
txType
=
'knownTx'
var
tx
=
yo
`
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
)}
>
<div class="
${
css
.
log
}
" onclick=
${
e
=>
txDetails
(
e
,
tx
,
data
,
obj
)}
>
${
checkTxStatus
(
data
.
receipt
,
txType
)}
${
checkTxStatus
(
data
.
receipt
,
txType
)}
${
context
(
self
,
{
from
,
to
,
data
},
blockchain
)}
${
context
(
self
,
{
from
,
to
,
data
},
blockchain
)}
...
@@ -384,7 +384,8 @@ function txDetails (e, tx, data, obj) {
...
@@ -384,7 +384,8 @@ function txDetails (e, tx, data, obj) {
}
}
function
createTable
(
opts
)
{
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
)
{
if
(
!
opts
.
isCall
)
{
var
msg
=
''
var
msg
=
''
if
(
opts
.
status
!==
undefined
&&
opts
.
status
!==
null
)
{
if
(
opts
.
status
!==
undefined
&&
opts
.
status
!==
null
)
{
...
@@ -399,14 +400,14 @@ function createTable (opts) {
...
@@ -399,14 +400,14 @@ function createTable (opts) {
table
.
appendChild
(
yo
`
table
.
appendChild
(
yo
`
<tr class="
${
css
.
tr
}
">
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> status </td>
<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>`
)
</tr>`
)
}
}
var
transactionHash
=
yo
`
var
transactionHash
=
yo
`
<tr class="
${
css
.
tr
}
">
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> transaction hash </td>
<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
)}
${
copyToClipboard
(()
=>
opts
.
hash
)}
</td>
</td>
</tr>
</tr>
...
@@ -416,7 +417,7 @@ function createTable (opts) {
...
@@ -416,7 +417,7 @@ function createTable (opts) {
var
contractAddress
=
yo
`
var
contractAddress
=
yo
`
<tr class="
${
css
.
tr
}
">
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> contract address </td>
<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
)}
${
copyToClipboard
(()
=>
opts
.
contractAddress
)}
</td>
</td>
</tr>
</tr>
...
@@ -426,7 +427,7 @@ function createTable (opts) {
...
@@ -426,7 +427,7 @@ function createTable (opts) {
var
from
=
yo
`
var
from
=
yo
`
<tr class="
${
css
.
tr
}
">
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
${
css
.
tableTitle
}
"> from </td>
<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
)}
${
copyToClipboard
(()
=>
opts
.
from
)}
</td>
</td>
</tr>
</tr>
...
@@ -443,7 +444,7 @@ function createTable (opts) {
...
@@ -443,7 +444,7 @@ function createTable (opts) {
var
to
=
yo
`
var
to
=
yo
`
<tr class="
${
css
.
tr
}
">
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> to </td>
<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
)}
${
copyToClipboard
(()
=>
data
.
to
?
data
.
to
:
toHash
)}
</td>
</td>
</tr>
</tr>
...
@@ -453,7 +454,7 @@ function createTable (opts) {
...
@@ -453,7 +454,7 @@ function createTable (opts) {
var
gas
=
yo
`
var
gas
=
yo
`
<tr class="
${
css
.
tr
}
">
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> gas </td>
<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
)}
${
copyToClipboard
(()
=>
opts
.
gas
)}
</td>
</td>
</tr>
</tr>
...
@@ -468,7 +469,7 @@ function createTable (opts) {
...
@@ -468,7 +469,7 @@ function createTable (opts) {
table
.
appendChild
(
yo
`
table
.
appendChild
(
yo
`
<tr class="
${
css
.
tr
}
">
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> transaction cost </td>
<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
)}
${
copyToClipboard
(()
=>
opts
.
transactionCost
)}
</td>
</td>
</tr>`
)
</tr>`
)
...
@@ -478,7 +479,7 @@ function createTable (opts) {
...
@@ -478,7 +479,7 @@ function createTable (opts) {
table
.
appendChild
(
yo
`
table
.
appendChild
(
yo
`
<tr class="
${
css
.
tr
}
">
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> execution cost </td>
<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
)}
${
copyToClipboard
(()
=>
opts
.
executionCost
)}
</td>
</td>
</tr>`
)
</tr>`
)
...
@@ -487,7 +488,7 @@ function createTable (opts) {
...
@@ -487,7 +488,7 @@ function createTable (opts) {
var
hash
=
yo
`
var
hash
=
yo
`
<tr class="
${
css
.
tr
}
">
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> hash </td>
<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
)}
${
copyToClipboard
(()
=>
opts
.
hash
)}
</td>
</td>
</tr>
</tr>
...
@@ -497,7 +498,7 @@ function createTable (opts) {
...
@@ -497,7 +498,7 @@ function createTable (opts) {
var
input
=
yo
`
var
input
=
yo
`
<tr class="
${
css
.
tr
}
">
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> input </td>
<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
)}
${
copyToClipboard
(()
=>
opts
.
input
)}
</td>
</td>
</tr>
</tr>
...
@@ -508,7 +509,7 @@ function createTable (opts) {
...
@@ -508,7 +509,7 @@ function createTable (opts) {
var
inputDecoded
=
yo
`
var
inputDecoded
=
yo
`
<tr class="
${
css
.
tr
}
">
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> decoded input </td>
<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'
])}
${
copyToClipboard
(()
=>
opts
[
'decoded input'
])}
</td>
</td>
</tr>`
</tr>`
...
@@ -519,7 +520,7 @@ function createTable (opts) {
...
@@ -519,7 +520,7 @@ function createTable (opts) {
var
outputDecoded
=
yo
`
var
outputDecoded
=
yo
`
<tr class="
${
css
.
tr
}
">
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> decoded output </td>
<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'
])}
${
copyToClipboard
(()
=>
opts
[
'decoded output'
])}
</td>
</td>
</tr>`
</tr>`
...
@@ -533,7 +534,7 @@ function createTable (opts) {
...
@@ -533,7 +534,7 @@ function createTable (opts) {
var
logs
=
yo
`
var
logs
=
yo
`
<tr class="
${
css
.
tr
}
">
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> logs </td>
<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'
)}
${
JSON
.
stringify
(
stringified
,
null
,
'
\
t'
)}
${
copyToClipboard
(()
=>
JSON
.
stringify
(
stringified
,
null
,
'
\
t'
))}
${
copyToClipboard
(()
=>
JSON
.
stringify
(
stringified
,
null
,
'
\
t'
))}
${
copyToClipboard
(()
=>
JSON
.
stringify
(
opts
.
logs
.
raw
||
'0'
))}
${
copyToClipboard
(()
=>
JSON
.
stringify
(
opts
.
logs
.
raw
||
'0'
))}
...
@@ -546,7 +547,7 @@ function createTable (opts) {
...
@@ -546,7 +547,7 @@ function createTable (opts) {
val
=
yo
`
val
=
yo
`
<tr class="
${
css
.
tr
}
">
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> value </td>
<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`
)}
${
copyToClipboard
(()
=>
`
${
val
}
wei`
)}
</td>
</td>
</tr>
</tr>
...
...
test-browser/commands/testFunction.js
View file @
27705470
const
EventEmitter
=
require
(
'events'
)
const
EventEmitter
=
require
(
'events'
)
const
deepequal
=
require
(
'deep-equal'
)
class
TestFunction
extends
EventEmitter
{
/*
command
(
fnFullName
,
txHash
,
log
,
expectedInput
,
expectedReturn
,
expectedEvent
,
callback
)
{
Checks if any child elements of journal (console) contains a matching value.
this
.
api
.
waitForElementPresent
(
'.instance button[title="'
+
fnFullName
+
'"]'
)
*/
.
perform
(
function
(
client
,
done
)
{
class
testTransactionLog
extends
EventEmitter
{
client
.
execute
(
function
()
{
command
(
txHash
,
expectedValue
)
{
document
.
querySelector
(
'#runTabView'
).
scrollTop
=
document
.
querySelector
(
'#runTabView'
).
scrollHeight
const
browser
=
this
.
api
;
},
[],
function
()
{
browser
.
perform
(()
=>
{
if
(
expectedInput
)
{
const
result
=
parseTransactionLog
(
this
.
api
,
txHash
)
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
)
}
this
.
emit
(
'complete'
)
this
.
emit
(
'complete'
)
})
})
return
this
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 = {
...
@@ -25,6 +25,8 @@ module.exports = {
.
click
(
'#runTabView button[class^="instanceButton"]'
)
.
click
(
'#runTabView button[class^="instanceButton"]'
)
.
waitForElementPresent
(
'.instance:nth-of-type(2)'
)
.
waitForElementPresent
(
'.instance:nth-of-type(2)'
)
.
click
(
'.instance:nth-of-type(2) > div > button'
)
.
click
(
'.instance:nth-of-type(2) > div > button'
)
.
createContract
([
"0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3"
])
.
pause
(
100000
)
.
testFunction
(
'delegate - transact (not payable)'
,
'0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3'
,
.
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`
,
`[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
)
{
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