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
10aa7322
Commit
10aa7322
authored
Nov 19, 2019
by
aniket-engg
Committed by
Aniket
Nov 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more types added
parent
d65af07f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
20 deletions
+29
-20
runTestFiles.ts
remix-tests/src/runTestFiles.ts
+3
-3
runTestSources.ts
remix-tests/src/runTestSources.ts
+5
-5
testRunner.ts
remix-tests/src/testRunner.ts
+16
-12
types.ts
remix-tests/src/types.ts
+5
-0
No files found.
remix-tests/src/runTestFiles.ts
View file @
10aa7322
import
async
from
'async'
import
async
from
'async'
import
fs
from
'./fileSystem'
import
fs
from
'./fileSystem'
import
{
runTest
}
from
'./testRunner'
import
{
runTest
}
from
'./testRunner'
import
{
TestResultInterface
,
ResultsInterface
,
compilationInterface
,
ASTInterface
}
from
'./types'
import
{
TestResultInterface
,
ResultsInterface
,
compilationInterface
,
ASTInterface
,
Options
,
AstNode
}
from
'./types'
import
colors
from
'colors'
import
colors
from
'colors'
import
Web3
=
require
(
'web3'
)
import
Web3
=
require
(
'web3'
)
...
@@ -16,7 +16,7 @@ import { deployAll } from './deployer'
...
@@ -16,7 +16,7 @@ import { deployAll } from './deployer'
* @param opts Options
* @param opts Options
*/
*/
export
function
runTestFiles
(
filepath
:
string
,
isDirectory
:
boolean
,
web3
:
Web3
,
opts
?:
object
)
{
export
function
runTestFiles
(
filepath
:
string
,
isDirectory
:
boolean
,
web3
:
Web3
,
opts
?:
Options
)
{
opts
=
opts
||
{}
opts
=
opts
||
{}
const
sourceASTs
:
any
=
{}
const
sourceASTs
:
any
=
{}
const
{
Signale
}
=
require
(
'signale'
)
const
{
Signale
}
=
require
(
'signale'
)
...
@@ -117,7 +117,7 @@ export function runTestFiles(filepath: string, isDirectory: boolean, web3: Web3,
...
@@ -117,7 +117,7 @@ export function runTestFiles(filepath: string, isDirectory: boolean, web3: Web3,
async
.
eachOfLimit
(
contractsToTest
,
1
,
(
contractName
:
string
,
index
,
cb
)
=>
{
async
.
eachOfLimit
(
contractsToTest
,
1
,
(
contractName
:
string
,
index
,
cb
)
=>
{
try
{
try
{
const
fileAST
=
sourceASTs
[
contracts
[
contractName
][
'filename'
]]
const
fileAST
:
AstNode
=
sourceASTs
[
contracts
[
contractName
][
'filename'
]]
runTest
(
contractName
,
contracts
[
contractName
],
contractsToTestDetails
[
index
],
fileAST
,
{
accounts
},
_testCallback
,
(
err
,
result
)
=>
{
runTest
(
contractName
,
contracts
[
contractName
],
contractsToTestDetails
[
index
],
fileAST
,
{
accounts
},
_testCallback
,
(
err
,
result
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
err
)
console
.
log
(
err
)
...
...
remix-tests/src/runTestSources.ts
View file @
10aa7322
...
@@ -4,11 +4,11 @@ require('colors')
...
@@ -4,11 +4,11 @@ require('colors')
import
{
compileContractSources
}
from
'./compiler'
import
{
compileContractSources
}
from
'./compiler'
import
{
deployAll
}
from
'./deployer'
import
{
deployAll
}
from
'./deployer'
import
{
runTest
}
from
'./testRunner'
import
{
runTest
}
from
'./testRunner'
import
{
TestResultInterface
}
from
'./types'
import
{
TestResultInterface
,
AstNode
}
from
'./types'
import
Web3
=
require
(
'web3'
)
import
Web3
=
require
(
'web3'
)
import
{
Provider
}
from
'remix-simulator'
import
{
Provider
}
from
'remix-simulator'
import
{
FinalResult
,
SrcIfc
,
compilationInterface
,
ASTInterface
}
from
'./types'
import
{
FinalResult
,
SrcIfc
,
compilationInterface
,
ASTInterface
,
Options
}
from
'./types'
const
createWeb3Provider
=
async
function
()
{
const
createWeb3Provider
=
async
function
()
{
let
web3
=
new
Web3
()
let
web3
=
new
Web3
()
...
@@ -29,11 +29,11 @@ const createWeb3Provider = async function () {
...
@@ -29,11 +29,11 @@ const createWeb3Provider = async function () {
* @param importFileCb Import file callback
* @param importFileCb Import file callback
* @param opts Options
* @param opts Options
*/
*/
export
async
function
runTestSources
(
contractSources
:
SrcIfc
,
versionUrl
:
string
,
usingWorker
:
boolean
,
testCallback
:
Function
,
resultCallback
:
Function
,
finalCallback
:
any
,
importFileCb
:
Function
,
opts
:
any
)
{
export
async
function
runTestSources
(
contractSources
:
SrcIfc
,
versionUrl
:
string
,
usingWorker
:
boolean
,
testCallback
:
Function
,
resultCallback
:
Function
,
finalCallback
:
any
,
importFileCb
:
Function
,
opts
:
Options
)
{
opts
=
opts
||
{}
opts
=
opts
||
{}
const
sourceASTs
:
any
=
{}
const
sourceASTs
:
any
=
{}
let
web3
=
opts
.
web3
||
await
createWeb3Provider
()
let
web3
=
opts
.
web3
||
await
createWeb3Provider
()
let
accounts
=
opts
.
accounts
||
null
let
accounts
:
string
[]
|
null
=
opts
.
accounts
||
null
async
.
waterfall
([
async
.
waterfall
([
function
getAccountList
(
next
)
{
function
getAccountList
(
next
)
{
if
(
accounts
)
return
next
()
if
(
accounts
)
return
next
()
...
@@ -95,7 +95,7 @@ export async function runTestSources(contractSources: SrcIfc, versionUrl: string
...
@@ -95,7 +95,7 @@ export async function runTestSources(contractSources: SrcIfc, versionUrl: string
}
}
async
.
eachOfLimit
(
contractsToTest
,
1
,
(
contractName
:
string
,
index
:
string
|
number
,
cb
:
ErrorCallback
)
=>
{
async
.
eachOfLimit
(
contractsToTest
,
1
,
(
contractName
:
string
,
index
:
string
|
number
,
cb
:
ErrorCallback
)
=>
{
const
fileAST
=
sourceASTs
[
contracts
[
contractName
][
'filename'
]]
const
fileAST
:
AstNode
=
sourceASTs
[
contracts
[
contractName
][
'filename'
]]
runTest
(
contractName
,
contracts
[
contractName
],
contractsToTestDetails
[
index
],
fileAST
,
{
accounts
},
_testCallback
,
(
err
,
result
)
=>
{
runTest
(
contractName
,
contracts
[
contractName
],
contractsToTestDetails
[
index
],
fileAST
,
{
accounts
},
_testCallback
,
(
err
,
result
)
=>
{
if
(
err
)
{
if
(
err
)
{
return
cb
(
err
)
return
cb
(
err
)
...
...
remix-tests/src/testRunner.ts
View file @
10aa7322
import
async
from
'async'
import
async
from
'async'
import
*
as
changeCase
from
'change-case'
import
*
as
changeCase
from
'change-case'
import
Web3
=
require
(
'web3'
)
import
Web3
=
require
(
'web3'
)
import
{
RunListInterface
,
TestCbInterface
,
TestResultInterface
,
ResultCbInterface
}
from
'./types'
import
{
RunListInterface
,
TestCbInterface
,
TestResultInterface
,
ResultCbInterface
,
CompiledContract
,
AstNode
,
Options
,
FunctionDescription
,
UserDocumentation
}
from
'./types'
function
getFunctionFullName
(
signature
:
string
,
methodIdentifiers
)
{
function
getFunctionFullName
(
signature
:
string
,
methodIdentifiers
:
any
)
{
for
(
const
method
in
methodIdentifiers
)
{
for
(
const
method
in
methodIdentifiers
)
{
if
(
signature
.
replace
(
'0x'
,
''
)
===
methodIdentifiers
[
method
].
replace
(
'0x'
,
''
))
{
if
(
signature
.
replace
(
'0x'
,
''
)
===
methodIdentifiers
[
method
].
replace
(
'0x'
,
''
))
{
return
method
return
method
...
@@ -12,10 +13,10 @@ function getFunctionFullName (signature: string, methodIdentifiers) {
...
@@ -12,10 +13,10 @@ function getFunctionFullName (signature: string, methodIdentifiers) {
return
null
return
null
}
}
function
getOverridedSender
(
userdoc
,
signature
:
string
,
methodIdentifiers
)
{
function
getOverridedSender
(
userdoc
:
UserDocumentation
,
signature
:
string
,
methodIdentifiers
:
any
)
{
let
fullName
:
any
=
getFunctionFullName
(
signature
,
methodIdentifiers
)
let
fullName
:
any
=
getFunctionFullName
(
signature
,
methodIdentifiers
)
let
match
=
/sender: account-+
(\d)
/g
let
match
:
RegExp
=
/sender: account-+
(\d)
/g
let
accountIndex
=
userdoc
.
methods
[
fullName
]
?
match
.
exec
(
userdoc
.
methods
[
fullName
].
notice
)
:
null
let
accountIndex
:
any
=
userdoc
.
methods
[
fullName
]
?
match
.
exec
(
userdoc
.
methods
[
fullName
].
notice
)
:
null
return
fullName
&&
accountIndex
?
accountIndex
[
1
]
:
null
return
fullName
&&
accountIndex
?
accountIndex
[
1
]
:
null
}
}
...
@@ -25,10 +26,13 @@ function getOverridedSender (userdoc, signature: string, methodIdentifiers) {
...
@@ -25,10 +26,13 @@ function getOverridedSender (userdoc, signature: string, methodIdentifiers) {
* @param testContractName Name of test contract
* @param testContractName Name of test contract
*/
*/
function
getAvailableFunctions
(
fileAST
:
any
,
testContractName
:
string
)
{
function
getAvailableFunctions
(
fileAST
:
AstNode
,
testContractName
:
string
)
{
const
contractAST
:
any
[]
=
fileAST
.
nodes
.
filter
(
node
=>
node
.
name
===
testContractName
&&
node
.
nodeType
===
'ContractDefinition'
)
var
funcList
:
string
[]
=
[]
const
funcNodes
:
any
[]
=
contractAST
[
0
].
nodes
.
filter
(
node
=>
node
.
kind
===
'function'
&&
node
.
nodeType
===
"FunctionDefinition"
)
if
(
fileAST
.
nodes
&&
fileAST
.
nodes
.
length
>
0
)
{
const
funcList
:
string
[]
=
funcNodes
.
map
(
node
=>
node
.
name
)
const
contractAST
:
any
[]
=
fileAST
.
nodes
.
filter
(
node
=>
node
.
name
===
testContractName
&&
node
.
nodeType
===
'ContractDefinition'
)
const
funcNodes
:
any
[]
=
contractAST
[
0
].
nodes
.
filter
(
node
=>
node
.
kind
===
'function'
&&
node
.
nodeType
===
"FunctionDefinition"
)
funcList
=
funcNodes
.
map
(
node
=>
node
.
name
)
}
return
funcList
;
return
funcList
;
}
}
...
@@ -38,7 +42,7 @@ function getAvailableFunctions (fileAST: any, testContractName: string) {
...
@@ -38,7 +42,7 @@ function getAvailableFunctions (fileAST: any, testContractName: string) {
* @param funcList Methods to extract the interface of
* @param funcList Methods to extract the interface of
*/
*/
function
getTestFunctionsInterface
(
jsonInterface
:
any
,
funcList
:
string
[])
{
function
getTestFunctionsInterface
(
jsonInterface
:
FunctionDescription
[]
,
funcList
:
string
[])
{
const
functionsInterface
:
any
[]
=
[]
const
functionsInterface
:
any
[]
=
[]
const
specialFunctions
=
[
'beforeAll'
,
'beforeEach'
,
'afterAll'
,
'afterEach'
]
const
specialFunctions
=
[
'beforeAll'
,
'beforeEach'
,
'afterAll'
,
'afterEach'
]
for
(
const
func
of
funcList
){
for
(
const
func
of
funcList
){
...
@@ -57,7 +61,7 @@ function getTestFunctionsInterface (jsonInterface: any, funcList: string[]) {
...
@@ -57,7 +61,7 @@ function getTestFunctionsInterface (jsonInterface: any, funcList: string[]) {
* @param testContractName Test contract name
* @param testContractName Test contract name
*/
*/
function
createRunList
(
jsonInterface
:
any
,
fileAST
:
any
,
testContractName
:
string
):
RunListInterface
[]
{
function
createRunList
(
jsonInterface
:
FunctionDescription
[],
fileAST
:
AstNode
,
testContractName
:
string
):
RunListInterface
[]
{
const
availableFunctions
:
string
[]
=
getAvailableFunctions
(
fileAST
,
testContractName
)
const
availableFunctions
:
string
[]
=
getAvailableFunctions
(
fileAST
,
testContractName
)
const
testFunctionsInterface
:
any
[]
=
getTestFunctionsInterface
(
jsonInterface
,
availableFunctions
)
const
testFunctionsInterface
:
any
[]
=
getTestFunctionsInterface
(
jsonInterface
,
availableFunctions
)
...
@@ -84,7 +88,7 @@ function createRunList (jsonInterface: any, fileAST: any, testContractName: stri
...
@@ -84,7 +88,7 @@ function createRunList (jsonInterface: any, fileAST: any, testContractName: stri
return
runList
return
runList
}
}
export
function
runTest
(
testName
,
testObject
:
any
,
contractDetails
:
any
,
fileAST
:
any
,
opts
:
any
,
testCallback
:
TestCbInterface
,
resultsCallback
:
ResultCbInterface
)
{
export
function
runTest
(
testName
:
string
,
testObject
:
any
,
contractDetails
:
CompiledContract
,
fileAST
:
AstNode
,
opts
:
Options
,
testCallback
:
TestCbInterface
,
resultsCallback
:
ResultCbInterface
)
{
const
runList
:
RunListInterface
[]
=
createRunList
(
testObject
.
_jsonInterface
,
fileAST
,
testName
)
const
runList
:
RunListInterface
[]
=
createRunList
(
testObject
.
_jsonInterface
,
fileAST
,
testName
)
let
passingNum
:
number
=
0
let
passingNum
:
number
=
0
let
failureNum
:
number
=
0
let
failureNum
:
number
=
0
...
...
remix-tests/src/types.ts
View file @
10aa7322
...
@@ -38,6 +38,11 @@ export interface ResultCbInterface {
...
@@ -38,6 +38,11 @@ export interface ResultCbInterface {
(
error
:
Error
|
null
|
undefined
,
result
:
ResultsInterface
)
:
void
;
(
error
:
Error
|
null
|
undefined
,
result
:
ResultsInterface
)
:
void
;
}
}
export
interface
Options
{
accounts
?:
string
[]
|
null
,
web3
?:
any
}
/** sources object with name of the file and content **/
/** sources object with name of the file and content **/
////////////
////////////
...
...
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