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
dbb71b17
Commit
dbb71b17
authored
Aug 18, 2021
by
aniket-engg
Committed by
Aniket
Aug 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hhlogs in unit testing plugin
parent
7a852929
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
49 deletions
+56
-49
test-tab.js
apps/remix-ide/src/app/tabs/test-tab.js
+1
-0
runTestSources.ts
libs/remix-tests/src/runTestSources.ts
+3
-2
testRunner.ts
libs/remix-tests/src/testRunner.ts
+51
-47
types.ts
libs/remix-tests/src/types.ts
+1
-0
No files found.
apps/remix-ide/src/app/tabs/test-tab.js
View file @
dbb71b17
...
...
@@ -180,6 +180,7 @@ module.exports = class TestTab extends ViewPlugin {
}
testCallback
(
result
,
runningTests
)
{
console
.
log
(
'result in testCallback'
,
result
)
this
.
testsOutput
.
hidden
=
false
if
(
result
.
type
===
'contract'
)
{
this
.
testSuite
=
result
.
value
...
...
libs/remix-tests/src/runTestSources.ts
View file @
dbb71b17
...
...
@@ -5,7 +5,7 @@ import { deployAll } from './deployer'
import
{
runTest
}
from
'./testRunner'
import
Web3
from
'web3'
import
{
Provider
}
from
'@remix-project/remix-simulator'
import
{
Provider
,
extend
}
from
'@remix-project/remix-simulator'
import
{
FinalResult
,
SrcIfc
,
compilationInterface
,
ASTInterface
,
Options
,
TestResultInterface
,
AstNode
,
CompilerConfiguration
...
...
@@ -17,6 +17,7 @@ const createWeb3Provider = async function () {
const
provider
:
any
=
new
Provider
()
await
provider
.
init
()
web3
.
setProvider
(
provider
)
extend
(
web3
)
return
web3
}
...
...
@@ -102,7 +103,7 @@ export async function runTestSources (contractSources: SrcIfc, compilerConfig: C
async
.
eachOfLimit
(
contractsToTest
,
1
,
(
contractName
:
string
,
index
:
string
|
number
,
cb
:
ErrorCallback
)
=>
{
const
fileAST
:
AstNode
=
sourceASTs
[
contracts
[
contractName
][
'filename'
]]
runTest
(
contractName
,
contracts
[
contractName
],
contractsToTestDetails
[
index
],
fileAST
,
{
accounts
},
_testCallback
,
(
err
,
result
)
=>
{
runTest
(
contractName
,
contracts
[
contractName
],
contractsToTestDetails
[
index
],
fileAST
,
{
accounts
,
web3
},
_testCallback
,
(
err
,
result
)
=>
{
if
(
err
)
{
return
cb
(
err
)
}
...
...
libs/remix-tests/src/testRunner.ts
View file @
dbb71b17
...
...
@@ -217,7 +217,7 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
const
isJSONInterfaceAvailable
=
testObject
&&
testObject
.
options
&&
testObject
.
options
.
jsonInterface
if
(
!
isJSONInterfaceAvailable
)
{
return
resultsCallback
(
new
Error
(
'Contract interface not available'
),
{
passingNum
,
failureNum
,
timePassed
})
}
const
runList
:
RunListInterface
[]
=
createRunList
(
testObject
.
options
.
jsonInterface
,
fileAST
,
testName
)
const
web3
=
new
Web3
()
const
web3
=
opts
.
web3
||
new
Web3
()
const
accts
:
TestResultInterface
=
{
type
:
'accountList'
,
value
:
opts
.
accounts
...
...
@@ -284,59 +284,63 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
sendParams
.
gas
=
10000000
*
8
method
.
send
(
sendParams
).
on
(
'receipt'
,
(
receipt
)
=>
{
try
{
const
time
:
number
=
(
Date
.
now
()
-
startTime
)
/
1000.0
const
assertionEventHashes
=
assertionEvents
.
map
(
e
=>
Web3
.
utils
.
sha3
(
e
.
name
+
'('
+
e
.
params
.
join
()
+
')'
))
let
testPassed
=
false
for
(
const
i
in
receipt
.
events
)
{
let
events
=
receipt
.
events
[
i
]
if
(
!
Array
.
isArray
(
events
))
events
=
[
events
]
for
(
const
event
of
events
)
{
const
eIndex
=
assertionEventHashes
.
indexOf
(
event
.
raw
.
topics
[
0
])
// event name topic will always be at index 0
if
(
eIndex
>=
0
)
{
const
testEvent
=
web3
.
eth
.
abi
.
decodeParameters
(
assertionEvents
[
eIndex
].
params
,
event
.
raw
.
data
)
if
(
!
testEvent
[
0
])
{
const
assertMethod
=
testEvent
[
2
]
if
(
assertMethod
===
'ok'
)
{
// for 'Assert.ok' method
testEvent
[
3
]
=
'false'
testEvent
[
4
]
=
'true'
web3
.
eth
.
getHHLogsForTx
(
receipt
.
transactionHash
).
then
((
hhLogs
)
=>
{
const
time
:
number
=
(
Date
.
now
()
-
startTime
)
/
1000.0
const
assertionEventHashes
=
assertionEvents
.
map
(
e
=>
Web3
.
utils
.
sha3
(
e
.
name
+
'('
+
e
.
params
.
join
()
+
')'
))
let
testPassed
=
false
for
(
const
i
in
receipt
.
events
)
{
let
events
=
receipt
.
events
[
i
]
if
(
!
Array
.
isArray
(
events
))
events
=
[
events
]
for
(
const
event
of
events
)
{
const
eIndex
=
assertionEventHashes
.
indexOf
(
event
.
raw
.
topics
[
0
])
// event name topic will always be at index 0
if
(
eIndex
>=
0
)
{
const
testEvent
=
web3
.
eth
.
abi
.
decodeParameters
(
assertionEvents
[
eIndex
].
params
,
event
.
raw
.
data
)
if
(
!
testEvent
[
0
])
{
const
assertMethod
=
testEvent
[
2
]
if
(
assertMethod
===
'ok'
)
{
// for 'Assert.ok' method
testEvent
[
3
]
=
'false'
testEvent
[
4
]
=
'true'
}
const
location
=
getAssertMethodLocation
(
fileAST
,
testName
,
func
.
name
,
assertMethod
)
const
resp
:
TestResultInterface
=
{
type
:
'testFailure'
,
value
:
changeCase
.
sentenceCase
(
func
.
name
),
filename
:
testObject
.
filename
,
time
:
time
,
errMsg
:
testEvent
[
1
],
context
:
testName
,
assertMethod
,
returned
:
testEvent
[
3
],
expected
:
testEvent
[
4
],
location
,
hhLogs
}
testCallback
(
undefined
,
resp
)
failureNum
+=
1
timePassed
+=
time
return
next
()
}
const
location
=
getAssertMethodLocation
(
fileAST
,
testName
,
func
.
name
,
assertMethod
)
const
resp
:
TestResultInterface
=
{
type
:
'testFailure'
,
value
:
changeCase
.
sentenceCase
(
func
.
name
),
filename
:
testObject
.
filename
,
time
:
time
,
errMsg
:
testEvent
[
1
],
context
:
testName
,
assertMethod
,
returned
:
testEvent
[
3
],
expected
:
testEvent
[
4
],
location
}
testCallback
(
undefined
,
resp
)
failureNum
+=
1
timePassed
+=
time
return
next
()
testPassed
=
true
}
testPassed
=
true
}
}
}
if
(
testPassed
)
{
const
resp
:
TestResultInterface
=
{
type
:
'testPass'
,
value
:
changeCase
.
sentenceCase
(
func
.
name
),
filename
:
testObject
.
filename
,
time
:
time
,
context
:
testName
if
(
testPassed
)
{
const
resp
:
TestResultInterface
=
{
type
:
'testPass'
,
value
:
changeCase
.
sentenceCase
(
func
.
name
),
filename
:
testObject
.
filename
,
time
:
time
,
context
:
testName
,
hhLogs
}
testCallback
(
undefined
,
resp
)
passingNum
+=
1
timePassed
+=
time
}
testCallback
(
undefined
,
resp
)
passingNum
+=
1
timePassed
+=
time
}
return
next
()
return
next
()
})
}
catch
(
err
)
{
console
.
error
(
err
)
return
next
(
err
)
...
...
libs/remix-tests/src/types.ts
View file @
dbb71b17
...
...
@@ -36,6 +36,7 @@ export interface TestResultInterface {
returned
?:
string
|
number
expected
?:
string
|
number
location
?:
string
hhLogs
?:
[]
}
export
interface
TestCbInterface
{
(
error
:
Error
|
null
|
undefined
,
result
:
TestResultInterface
)
:
void
;
...
...
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