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
2aa3a86f
Commit
2aa3a86f
authored
Aug 22, 2018
by
0mkar
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master'
parents
e0796e66
0a255757
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
8 deletions
+26
-8
compiler.js
src/compiler.js
+1
-1
testRunner.js
src/testRunner.js
+11
-4
simple_storage_test.sol
tests/examples_1/simple_storage_test.sol
+10
-1
testRunner.js
tests/testRunner.js
+4
-2
No files found.
src/compiler.js
View file @
2aa3a86f
...
@@ -68,7 +68,7 @@ function compileContractSources (sources, importFileCb, cb) {
...
@@ -68,7 +68,7 @@ function compileContractSources (sources, importFileCb, cb) {
compiler
.
compile
(
sources
,
filepath
)
compiler
.
compile
(
sources
,
filepath
)
}
}
],
function
(
err
,
result
)
{
],
function
(
err
,
result
)
{
let
errors
=
(
result
.
errors
||
[]).
filter
((
e
)
=>
e
.
type
===
'Error'
)
let
errors
=
(
result
.
errors
||
[]).
filter
((
e
)
=>
e
.
type
===
'Error'
||
e
.
severity
===
'error'
)
if
(
errors
.
length
>
0
)
{
if
(
errors
.
length
>
0
)
{
console
.
dir
(
errors
)
console
.
dir
(
errors
)
return
cb
(
new
Error
(
'errors compiling'
))
return
cb
(
new
Error
(
'errors compiling'
))
...
...
src/testRunner.js
View file @
2aa3a86f
...
@@ -61,19 +61,26 @@ function runTest (testName, testObject, testCallback, resultsCallback) {
...
@@ -61,19 +61,26 @@ function runTest (testName, testObject, testCallback, resultsCallback) {
let
time
=
Math
.
ceil
((
Date
.
now
()
-
startTime
)
/
1000.0
)
let
time
=
Math
.
ceil
((
Date
.
now
()
-
startTime
)
/
1000.0
)
let
topic
=
Web3
.
utils
.
sha3
(
'AssertionEvent(bool,string)'
)
let
topic
=
Web3
.
utils
.
sha3
(
'AssertionEvent(bool,string)'
)
let
testPassed
=
false
for
(
let
i
in
receipt
.
events
)
{
for
(
let
i
in
receipt
.
events
)
{
let
event
=
receipt
.
events
[
i
]
let
event
=
receipt
.
events
[
i
]
if
(
event
.
raw
.
topics
.
indexOf
(
topic
)
>=
0
)
{
if
(
event
.
raw
.
topics
.
indexOf
(
topic
)
>=
0
)
{
var
testEvent
=
web3
.
eth
.
abi
.
decodeParameters
([
'bool'
,
'string'
],
event
.
raw
.
data
)
var
testEvent
=
web3
.
eth
.
abi
.
decodeParameters
([
'bool'
,
'string'
],
event
.
raw
.
data
)
if
(
testEvent
[
0
])
{
if
(
!
testEvent
[
0
])
{
testCallback
({
type
:
'testPass'
,
value
:
changeCase
.
sentenceCase
(
func
.
name
),
time
:
time
,
context
:
testName
})
passingNum
+=
1
}
else
{
testCallback
({
type
:
'testFailure'
,
value
:
changeCase
.
sentenceCase
(
func
.
name
),
time
:
time
,
errMsg
:
testEvent
[
1
],
context
:
testName
})
testCallback
({
type
:
'testFailure'
,
value
:
changeCase
.
sentenceCase
(
func
.
name
),
time
:
time
,
errMsg
:
testEvent
[
1
],
context
:
testName
})
failureNum
+=
1
failureNum
+=
1
return
next
()
}
}
testPassed
=
true
}
}
}
}
if
(
testPassed
)
{
testCallback
({
type
:
'testPass'
,
value
:
changeCase
.
sentenceCase
(
func
.
name
),
time
:
time
,
context
:
testName
})
passingNum
+=
1
}
return
next
()
return
next
()
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
'error!'
)
console
.
log
(
'error!'
)
...
...
tests/examples_1/simple_storage_test.sol
View file @
2aa3a86f
pragma solidity ^0.4.7;
pragma solidity ^0.4.7;
import "
./
tests.sol";
import "
remix_
tests.sol";
import "./simple_storage.sol";
import "./simple_storage.sol";
contract MyTest {
contract MyTest {
...
@@ -19,5 +19,14 @@ contract MyTest {
...
@@ -19,5 +19,14 @@ contract MyTest {
return foo.get() == 200;
return foo.get() == 200;
}
}
function shouldTriggerOneFail() public {
Assert.equal(uint(1), uint(2), "the test 1 fails");
Assert.equal(uint(1), uint(2), "the test 2 fails");
}
function shouldTriggerOnePass() public {
Assert.equal(uint(1), uint(1), "the test 3 fails");
}
}
}
tests/testRunner.js
View file @
2aa3a86f
...
@@ -43,16 +43,18 @@ describe('testRunner', function () {
...
@@ -43,16 +43,18 @@ describe('testRunner', function () {
})
})
it
(
'should 1 passing test'
,
function
()
{
it
(
'should 1 passing test'
,
function
()
{
assert
.
equal
(
results
.
passingNum
,
1
)
assert
.
equal
(
results
.
passingNum
,
2
)
})
})
it
(
'should 1 failing test'
,
function
()
{
it
(
'should 1 failing test'
,
function
()
{
assert
.
equal
(
results
.
failureNum
,
1
)
assert
.
equal
(
results
.
failureNum
,
2
)
})
})
it
(
'should returns 3 messages'
,
function
()
{
it
(
'should returns 3 messages'
,
function
()
{
assert
.
deepEqual
(
tests
,
[
assert
.
deepEqual
(
tests
,
[
{
type
:
'contract'
,
value
:
'MyTest'
,
filename
:
'simple_storage_test.sol'
},
{
type
:
'contract'
,
value
:
'MyTest'
,
filename
:
'simple_storage_test.sol'
},
{
type
:
'testFailure'
,
value
:
'Should trigger one fail'
,
time
:
1
,
context
:
'MyTest'
,
errMsg
:
'the test 1 fails'
},
{
type
:
'testPass'
,
value
:
'Should trigger one pass'
,
time
:
1
,
context
:
'MyTest'
},
{
type
:
'testPass'
,
value
:
'Initial value should be100'
,
time
:
1
,
context
:
'MyTest'
},
{
type
:
'testPass'
,
value
:
'Initial value should be100'
,
time
:
1
,
context
:
'MyTest'
},
{
type
:
'testFailure'
,
value
:
'Initial value should be200'
,
time
:
1
,
context
:
'MyTest'
,
errMsg
:
'function returned false'
}
{
type
:
'testFailure'
,
value
:
'Initial value should be200'
,
time
:
1
,
context
:
'MyTest'
,
errMsg
:
'function returned false'
}
])
])
...
...
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