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
35bd3f74
Commit
35bd3f74
authored
Aug 14, 2020
by
aniket-engg
Committed by
Aniket
Aug 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
expected vs returned for equal method for uint type
parent
83251c82
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
11 deletions
+33
-11
tests.sol.ts
libs/remix-tests/sol/tests.sol.ts
+9
-2
testRunner.ts
libs/remix-tests/src/testRunner.ts
+17
-4
types.ts
libs/remix-tests/src/types.ts
+6
-4
testRunner.spec.ts
libs/remix-tests/tests/testRunner.spec.ts
+1
-1
No files found.
libs/remix-tests/sol/tests.sol.ts
View file @
35bd3f74
...
...
@@ -8,14 +8,21 @@ library Assert {
string message
);
event AssertionEventUint(
bool passed,
string message,
uint256 returned,
uint256 expected
);
function ok(bool a, string memory message) public returns (bool result) {
result = a;
emit AssertionEvent(result, message);
}
function equal(uint
a, uint
b, string memory message) public returns (bool result) {
function equal(uint
256 a, uint256
b, string memory message) public returns (bool result) {
result = (a == b);
emit AssertionEvent
(result, message
);
emit AssertionEvent
Uint(result, message, a, b
);
}
function equal(int a, int b, string memory message) public returns (bool result) {
...
...
libs/remix-tests/src/testRunner.ts
View file @
35bd3f74
...
...
@@ -228,20 +228,33 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
method
.
send
(
sendParams
).
on
(
'receipt'
,
(
receipt
)
=>
{
try
{
const
time
:
number
=
(
Date
.
now
()
-
startTime
)
/
1000.0
const
topic
=
Web3
.
utils
.
sha3
(
'AssertionEvent(bool,string)'
)
const
assertionEvents
=
[
{
name
:
'AssertionEvent'
,
params
:
[
'bool'
,
'string'
]
},
{
name
:
'AssertionEventUint'
,
params
:
[
'bool'
,
'string'
,
'uint256'
,
'uint256'
]
}
]
const
assertionEventHashes
=
assertionEvents
.
map
(
e
=>
Web3
.
utils
.
sha3
(
e
.
name
+
'('
+
e
.
params
.
join
()
+
')'
)
)
let
testPassed
=
false
for
(
const
i
in
receipt
.
events
)
{
const
event
=
receipt
.
events
[
i
]
if
(
event
.
raw
.
topics
.
indexOf
(
topic
)
>=
0
)
{
const
testEvent
=
web3
.
eth
.
abi
.
decodeParameters
([
'bool'
,
'string'
],
event
.
raw
.
data
)
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
resp
:
TestResultInterface
=
{
type
:
'testFailure'
,
value
:
changeCase
.
sentenceCase
(
func
.
name
),
time
:
time
,
errMsg
:
testEvent
[
1
],
context
:
testName
context
:
testName
,
returned
:
testEvent
[
2
],
expected
:
testEvent
[
3
]
};
testCallback
(
undefined
,
resp
)
failureNum
+=
1
...
...
libs/remix-tests/src/types.ts
View file @
35bd3f74
...
...
@@ -26,12 +26,14 @@ export interface ResultsInterface {
timePassed
:
number
}
export
interface
TestResultInterface
{
type
:
string
,
value
:
any
,
time
?:
number
,
context
?:
string
,
type
:
string
value
:
any
time
?:
number
context
?:
string
errMsg
?:
string
filename
?:
string
returned
?:
string
|
number
expected
?:
string
|
number
}
export
interface
TestCbInterface
{
(
error
:
Error
|
null
|
undefined
,
result
:
TestResultInterface
)
:
void
;
...
...
libs/remix-tests/tests/testRunner.spec.ts
View file @
35bd3f74
...
...
@@ -125,7 +125,7 @@ describe('testRunner', () => {
{
type
:
'contract'
,
value
:
'MyTest'
,
filename
:
__dirname
+
'/examples_1/simple_storage_test.sol'
},
{
type
:
'testPass'
,
value
:
'Initial value should be100'
,
context
:
'MyTest'
},
{
type
:
'testPass'
,
value
:
'Initial value should not be200'
,
context
:
'MyTest'
},
{
type
:
'testFailure'
,
value
:
'Should trigger one fail'
,
errMsg
:
'uint test 1 fails'
,
context
:
'MyTest'
},
{
type
:
'testFailure'
,
value
:
'Should trigger one fail'
,
errMsg
:
'uint test 1 fails'
,
context
:
'MyTest'
,
expected
:
'2'
,
returned
:
'1'
},
{
type
:
'testPass'
,
value
:
'Should trigger one pass'
,
context
:
'MyTest'
}
],
[
'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