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
ce32c89d
Unverified
Commit
ce32c89d
authored
Sep 24, 2021
by
David Disu
Committed by
GitHub
Sep 24, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into test-local-plugin
parents
a2eed840
718a2cd9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
2 deletions
+49
-2
solidityUnittests.spec.ts
apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts
+42
-0
testRunner.ts
libs/remix-tests/src/testRunner.ts
+7
-2
No files found.
apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts
View file @
ce32c89d
...
...
@@ -207,6 +207,23 @@ module.exports = {
.
removeFile
(
'tests/hhLogs_test.sol'
,
'workspace_new'
)
},
'Solidity Unit tests with hardhat console log for EVM revert'
:
function
(
browser
:
NightwatchBrowser
)
{
browser
.
waitForElementPresent
(
'*[data-id="verticalIconsKindfilePanel"]'
)
.
addFile
(
'tests/ballotFailedLog_test.sol'
,
sources
[
0
][
'tests/ballotFailedLog_test.sol'
])
.
clickLaunchIcon
(
'solidityUnitTesting'
)
.
waitForElementVisible
(
'*[id="singleTesttests/4_Ballot_test.sol"]'
,
60000
)
.
click
(
'*[id="singleTesttests/4_Ballot_test.sol"]'
)
.
click
(
'#runTestsTabRunAction'
)
.
pause
(
2000
)
.
waitForElementVisible
(
'*[data-id="testTabSolidityUnitTestsOutputheader"]'
,
120000
)
.
waitForElementContainsText
(
'#solidityUnittestsOutput'
,
'tests/ballotFailedLog_test.sol'
,
60000
)
.
assert
.
containsText
(
'#journal > div:nth-child(6) > span > div'
,
'Check winning proposal:'
)
.
assert
.
containsText
(
'#journal > div:nth-child(6) > span > div'
,
'Inside checkWinningProposal'
)
.
openFile
(
'tests/ballotFailedLog_test.sol'
)
.
removeFile
(
'tests/ballotFailedLog_test.sol'
,
'workspace_new'
)
},
'Debug failed test using debugger'
:
function
(
browser
:
NightwatchBrowser
)
{
browser
.
waitForElementPresent
(
'*[data-id="verticalIconsKindfilePanel"]'
)
...
...
@@ -483,6 +500,31 @@ const sources = [
}
}`
},
'tests/ballotFailedLog_test.sol'
:
{
content
:
`// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
import "remix_tests.sol"; // this import is automatically injected by Remix.
import "../contracts/3_Ballot.sol";
import "hardhat/console.sol";
contract BallotTest {
bytes32[] proposalNames;
Ballot ballotToTest;
function beforeAll () public {
proposalNames.push(bytes32("candidate1"));
ballotToTest = new Ballot(proposalNames);
}
function checkWinningProposal () public {
console.log("Inside checkWinningProposal");
ballotToTest.vote(1); // This will revert the transaction
}
}`
},
'tests/hhLogs_test.sol'
:
{
content
:
`// SPDX-License-Identifier: GPL-3.0
...
...
libs/remix-tests/src/testRunner.ts
View file @
ce32c89d
...
...
@@ -232,6 +232,7 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
testCallback
(
undefined
,
resp
)
async
.
eachOfLimit
(
runList
,
1
,
function
(
func
,
index
,
next
)
{
let
sender
:
string
|
null
=
null
let
hhLogs
if
(
func
.
signature
)
{
sender
=
getOverridedSender
(
contractDetails
.
userdoc
,
func
.
signature
,
contractDetails
.
evm
.
methodIdentifiers
)
if
(
opts
.
accounts
&&
sender
)
{
...
...
@@ -293,7 +294,6 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
sendParams
.
gas
=
10000000
*
8
method
.
send
(
sendParams
).
on
(
'receipt'
,
async
(
receipt
)
=>
{
try
{
let
hhLogs
if
(
web3
.
eth
&&
web3
.
eth
.
getHHLogsForTx
)
hhLogs
=
await
web3
.
eth
.
getHHLogsForTx
(
receipt
.
transactionHash
)
const
time
:
number
=
(
Date
.
now
()
-
startTime
)
/
1000.0
const
assertionEventHashes
=
assertionEvents
.
map
(
e
=>
Web3
.
utils
.
sha3
(
e
.
name
+
'('
+
e
.
params
.
join
()
+
')'
))
...
...
@@ -366,7 +366,7 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
console
.
error
(
err
)
return
next
(
err
)
}
}).
on
(
'error'
,
function
(
err
:
Error
)
{
}).
on
(
'error'
,
async
(
err
:
Error
)
=>
{
const
time
:
number
=
(
Date
.
now
()
-
startTime
)
/
1000.0
const
resp
:
TestResultInterface
=
{
type
:
'testFailure'
,
...
...
@@ -377,6 +377,11 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
context
:
testName
,
web3
}
if
(
err
.
message
.
includes
(
'Transaction has been reverted by the EVM'
))
{
const
txHash
=
JSON
.
parse
(
err
.
message
.
replace
(
'Transaction has been reverted by the EVM:'
,
''
)).
transactionHash
if
(
web3
.
eth
&&
web3
.
eth
.
getHHLogsForTx
)
hhLogs
=
await
web3
.
eth
.
getHHLogsForTx
(
txHash
)
if
(
hhLogs
)
resp
.
hhLogs
=
hhLogs
}
testCallback
(
undefined
,
resp
)
failureNum
+=
1
timePassed
+=
time
...
...
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