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
27aa909b
Unverified
Commit
27aa909b
authored
Nov 05, 2020
by
yann300
Committed by
GitHub
Nov 05, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #557 from ethereum/fixRemixTest_Event
Handle array of events
parents
338dee12
811586de
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
27 deletions
+34
-27
testRunner.ts
libs/remix-tests/src/testRunner.ts
+30
-27
simple_storage.sol
libs/remix-tests/tests/examples_1/simple_storage.sol
+4
-0
No files found.
libs/remix-tests/src/testRunner.ts
View file @
27aa909b
...
@@ -286,35 +286,38 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
...
@@ -286,35 +286,38 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
const
assertionEventHashes
=
assertionEvents
.
map
(
e
=>
Web3
.
utils
.
sha3
(
e
.
name
+
'('
+
e
.
params
.
join
()
+
')'
)
)
const
assertionEventHashes
=
assertionEvents
.
map
(
e
=>
Web3
.
utils
.
sha3
(
e
.
name
+
'('
+
e
.
params
.
join
()
+
')'
)
)
let
testPassed
=
false
let
testPassed
=
false
for
(
const
i
in
receipt
.
events
)
{
for
(
const
i
in
receipt
.
events
)
{
const
event
=
receipt
.
events
[
i
]
let
events
=
receipt
.
events
[
i
]
const
eIndex
=
assertionEventHashes
.
indexOf
(
event
.
raw
.
topics
[
0
])
// event name topic will always be at index 0
if
(
!
Array
.
isArray
(
events
))
events
=
[
events
]
if
(
eIndex
>=
0
)
{
for
(
const
event
of
events
)
{
const
testEvent
=
web3
.
eth
.
abi
.
decodeParameters
(
assertionEvents
[
eIndex
].
params
,
event
.
raw
.
data
)
const
eIndex
=
assertionEventHashes
.
indexOf
(
event
.
raw
.
topics
[
0
])
// event name topic will always be at index 0
if
(
!
testEvent
[
0
])
{
if
(
eIndex
>=
0
)
{
const
assertMethod
=
testEvent
[
2
]
const
testEvent
=
web3
.
eth
.
abi
.
decodeParameters
(
assertionEvents
[
eIndex
].
params
,
event
.
raw
.
data
)
if
(
assertMethod
===
'ok'
)
{
// for 'Assert.ok' method
if
(
!
testEvent
[
0
])
{
testEvent
[
3
]
=
'false'
const
assertMethod
=
testEvent
[
2
]
testEvent
[
4
]
=
'true'
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
};
testCallback
(
undefined
,
resp
)
failureNum
+=
1
timePassed
+=
time
return
next
()
}
}
const
location
=
getAssertMethodLocation
(
fileAST
,
testName
,
func
.
name
,
assertMethod
)
testPassed
=
true
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
}
}
}
}
...
...
libs/remix-tests/tests/examples_1/simple_storage.sol
View file @
27aa909b
...
@@ -2,12 +2,16 @@ pragma solidity >= 0.5.0 < 0.8.0;
...
@@ -2,12 +2,16 @@ pragma solidity >= 0.5.0 < 0.8.0;
contract SimpleStorage {
contract SimpleStorage {
uint public storedData;
uint public storedData;
event Stored(uint256 value);
constructor() public {
constructor() public {
storedData = 100;
storedData = 100;
}
}
function set(uint x) public {
function set(uint x) public {
storedData = x;
storedData = x;
emit Stored(x);
emit Stored(x+10); // for testing multiple events only
}
}
function get() public view returns (uint retVal) {
function get() public view returns (uint retVal) {
...
...
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