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
a4e522aa
Commit
a4e522aa
authored
Feb 07, 2018
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check transaction for assertion even and add to testCallback
parent
dc7741e9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
9 deletions
+36
-9
simple_storage_test.sol
examples/simple_storage_test.sol
+4
-4
index.js
index.js
+1
-1
run.js
run.js
+1
-0
tests.sol
sol/tests.sol
+1
-1
testRunner.js
src/testRunner.js
+29
-3
No files found.
examples/simple_storage_test.sol
View file @
a4e522aa
...
@@ -9,12 +9,12 @@ contract MyTest {
...
@@ -9,12 +9,12 @@ contract MyTest {
foo = new SimpleStorage();
foo = new SimpleStorage();
}
}
function initialValueShouldBe100() public
constant returns (bool)
{
function initialValueShouldBe100() public {
return
Assert.equal(foo.get(), 100, "initial value is not correct");
Assert.equal(foo.get(), 100, "initial value is not correct");
}
}
function initialValueShouldBe200() public
constant returns (bool)
{
function initialValueShouldBe200() public {
return
Assert.equal(foo.get(), 200, "initial value is not correct");
Assert.equal(foo.get(), 200, "initial value is not correct");
}
}
}
}
...
...
index.js
View file @
a4e522aa
...
@@ -60,7 +60,7 @@ var runTestFiles = function (filepath, isDirectory, web3) {
...
@@ -60,7 +60,7 @@ var runTestFiles = function (filepath, isDirectory, web3) {
}
}
async
.
eachOfLimit
(
contractsToTest
,
1
,
(
contractName
,
index
,
cb
)
=>
{
async
.
eachOfLimit
(
contractsToTest
,
1
,
(
contractName
,
index
,
cb
)
=>
{
TestRunner
.
runTest
(
contractName
,
contracts
[
contractName
],
testCallback
,
(
err
,
result
)
=>
{
TestRunner
.
runTest
(
web3
,
contractName
,
contracts
[
contractName
],
testCallback
,
(
err
,
result
)
=>
{
if
(
err
)
{
if
(
err
)
{
return
cb
(
err
)
return
cb
(
err
)
}
}
...
...
run.js
View file @
a4e522aa
...
@@ -6,6 +6,7 @@ const fs = require('fs')
...
@@ -6,6 +6,7 @@ const fs = require('fs')
commander
.
action
(
function
(
filename
)
{
commander
.
action
(
function
(
filename
)
{
let
web3
=
new
Web3
()
let
web3
=
new
Web3
()
web3
.
setProvider
(
new
web3
.
providers
.
HttpProvider
(
'http://localhost:8545'
))
web3
.
setProvider
(
new
web3
.
providers
.
HttpProvider
(
'http://localhost:8545'
))
//web3.setProvider(new web3.providers.WebsocketProvider('http://localhost:8546'))
let
isDirectory
=
fs
.
lstatSync
(
filename
).
isDirectory
()
let
isDirectory
=
fs
.
lstatSync
(
filename
).
isDirectory
()
RemixTests
.
runTestFiles
(
filename
,
isDirectory
,
web3
)
RemixTests
.
runTestFiles
(
filename
,
isDirectory
,
web3
)
...
...
sol/tests.sol
View file @
a4e522aa
...
@@ -3,7 +3,7 @@ pragma solidity ^0.4.7;
...
@@ -3,7 +3,7 @@ pragma solidity ^0.4.7;
library Assert {
library Assert {
event AssertionEvent(
event AssertionEvent(
bool
indexed
passed,
bool passed,
string message
string message
);
);
...
...
src/testRunner.js
View file @
a4e522aa
...
@@ -29,7 +29,7 @@ function createRunList (jsonInterface) {
...
@@ -29,7 +29,7 @@ function createRunList (jsonInterface) {
return
runList
return
runList
}
}
function
runTest
(
testName
,
testObject
,
testCallback
,
resultsCallback
)
{
function
runTest
(
web3
,
testName
,
testObject
,
testCallback
,
resultsCallback
)
{
let
runList
=
createRunList
(
testObject
.
_jsonInterface
)
let
runList
=
createRunList
(
testObject
.
_jsonInterface
)
let
passingNum
=
0
let
passingNum
=
0
...
@@ -48,13 +48,39 @@ function runTest (testName, testObject, testCallback, resultsCallback) {
...
@@ -48,13 +48,39 @@ function runTest (testName, testObject, testCallback, resultsCallback) {
passingNum
+=
1
passingNum
+=
1
timePassed
+=
time
timePassed
+=
time
}
else
{
}
else
{
testCallback
({
type
:
'testFailure'
,
value
:
changeCase
.
sentenceCase
(
func
.
name
),
time
:
time
})
testCallback
({
type
:
'testFailure'
,
value
:
changeCase
.
sentenceCase
(
func
.
name
),
time
:
time
,
errMsg
:
'function returned false'
})
failureNum
+=
1
failureNum
+=
1
}
}
next
()
next
()
})
})
}
else
{
}
else
{
method
.
send
().
then
(()
=>
{
method
.
send
().
on
(
'receipt'
,
function
(
receipt
)
{
let
time
=
Math
.
ceil
((
Date
.
now
()
-
startTime
)
/
1000.0
)
if
(
func
.
type
===
'test'
)
{
let
topic
=
web3
.
utils
.
sha3
(
'AssertionEvent(bool,string)'
)
let
matchingEvents
=
[]
for
(
let
i
in
receipt
.
events
)
{
let
event
=
receipt
.
events
[
i
]
if
(
event
.
raw
.
topics
.
indexOf
(
topic
)
>=
0
)
{
matchingEvents
.
push
(
web3
.
eth
.
abi
.
decodeParameters
([
'bool'
,
'string'
],
event
.
raw
.
data
))
}
}
if
(
matchingEvents
.
length
===
0
)
{
return
next
();
}
let
result
=
matchingEvents
[
0
];
if
(
result
[
0
])
{
testCallback
({
type
:
'testPass'
,
value
:
changeCase
.
sentenceCase
(
func
.
name
),
time
:
time
})
passingNum
+=
1
}
else
{
testCallback
({
type
:
'testFailure'
,
value
:
changeCase
.
sentenceCase
(
func
.
name
),
time
:
time
,
errMsg
:
result
[
1
]})
failureNum
+=
1
}
}
next
()
next
()
})
})
}
}
...
...
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