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
cd589641
Commit
cd589641
authored
Jun 20, 2019
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
general test refactor
parent
a3fcd865
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
89 deletions
+49
-89
generalTests.js
test-browser/tests/generalTests.js
+49
-89
No files found.
test-browser/tests/generalTests.js
View file @
cd589641
...
@@ -10,71 +10,28 @@ module.exports = {
...
@@ -10,71 +10,28 @@ module.exports = {
'@sources'
:
function
()
{
'@sources'
:
function
()
{
return
sources
return
sources
},
},
'Simple Contract'
:
function
(
browser
)
{
'Test Simple Contract'
:
function
(
browser
)
{
runTests
(
browser
)
},
tearDown
:
sauce
}
function
runTests
(
browser
)
{
browser
.
waitForElementVisible
(
'#icon-panel'
,
10000
)
.
clickLaunchIcon
(
'solidity'
)
.
clickLaunchIcon
(
'fileExplorers'
)
.
perform
(()
=>
{
// the first fn is used to pass browser to the other ones.
async
.
waterfall
([
function
(
callback
)
{
callback
(
null
,
browser
)
},
testSimpleContract
,
testSuccessImport
,
testFailedImport
,
/* testGitHubImport, */
addDeployLibTestFile
,
testAutoDeployLib
,
testManualDeployLib
,
testSignature
],
function
()
{
browser
.
end
()
})
})
}
function
testSimpleContract
(
browser
,
callback
)
{
console
.
log
(
'testSimpleContract'
)
console
.
log
(
'testSimpleContract'
)
browser
.
testContracts
(
'Untitled.sol'
,
sources
[
0
][
'browser/Untitled.sol'
],
[
'test1'
,
'test2'
])
browser
.
testContracts
(
'Untitled.sol'
,
sources
[
0
][
'browser/Untitled.sol'
],
[
'test1'
,
'test2'
])
.
perform
(()
=>
{
},
callback
(
null
,
browser
)
'Test Success Import'
:
function
(
browser
)
{
})
}
function
testSuccessImport
(
browser
,
callback
)
{
console
.
log
(
'testSuccessImport'
)
console
.
log
(
'testSuccessImport'
)
browser
.
addFile
(
'Untitled1.sol'
,
sources
[
1
][
'browser/Untitled1.sol'
])
browser
.
addFile
(
'Untitled1.sol'
,
sources
[
1
][
'browser/Untitled1.sol'
])
.
addFile
(
'Untitled2.sol'
,
sources
[
1
][
'browser/Untitled2.sol'
])
.
addFile
(
'Untitled2.sol'
,
sources
[
1
][
'browser/Untitled2.sol'
])
.
switchFile
(
'browser/Untitled1.sol'
)
.
switchFile
(
'browser/Untitled1.sol'
)
.
verifyContracts
([
'test6'
,
'test4'
,
'test5'
])
.
verifyContracts
([
'test6'
,
'test4'
,
'test5'
])
.
perform
(()
=>
{
},
callback
(
null
,
browser
)
})
}
function
testFailedImport
(
browser
,
callback
)
{
'Test Failed Import'
:
function
(
browser
)
{
console
.
log
(
'testFailedImport'
)
console
.
log
(
'testFailedImport'
)
browser
.
addFile
(
'Untitled3.sol'
,
sources
[
2
][
'browser/Untitled3.sol'
])
browser
.
addFile
(
'Untitled3.sol'
,
sources
[
2
][
'browser/Untitled3.sol'
])
.
clickLaunchIcon
(
'solidity'
)
.
clickLaunchIcon
(
'solidity'
)
.
assert
.
containsText
(
'#compileTabView .error pre'
,
'Unable to import "browser/Untitled11.sol": File not found'
)
.
assert
.
containsText
(
'#compileTabView .error pre'
,
'Unable to import "browser/Untitled11.sol": File not found'
)
.
perform
(
function
()
{
},
callback
(
null
,
browser
)
'Add Lib Test File'
:
function
(
browser
)
{
})
}
function
addDeployLibTestFile
(
browser
,
callback
)
{
browser
.
addFile
(
'Untitled5.sol'
,
sources
[
5
][
'browser/Untitled5.sol'
])
browser
.
addFile
(
'Untitled5.sol'
,
sources
[
5
][
'browser/Untitled5.sol'
])
.
perform
(()
=>
{
},
callback
(
null
,
browser
)
'Test Auto Deploy Lib'
:
function
(
browser
)
{
})
}
function
testAutoDeployLib
(
browser
,
callback
)
{
console
.
log
(
'testAutoDeployLib'
)
console
.
log
(
'testAutoDeployLib'
)
let
addressRef
let
addressRef
browser
.
verifyContracts
([
'test'
])
browser
.
verifyContracts
([
'test'
])
...
@@ -86,16 +43,13 @@ function testAutoDeployLib (browser, callback) {
...
@@ -86,16 +43,13 @@ function testAutoDeployLib (browser, callback) {
})
})
.
waitForElementPresent
(
'.instance:nth-of-type(2)'
)
.
waitForElementPresent
(
'.instance:nth-of-type(2)'
)
.
click
(
'.instance:nth-of-type(2) > div > button'
)
.
click
(
'.instance:nth-of-type(2) > div > button'
)
.
perform
(()
=>
{
.
perform
((
done
)
=>
{
browser
browser
.
testConstantFunction
(
addressRef
,
'get - call'
,
''
,
'0: uint256: 45'
).
perform
(()
=>
{
.
testConstantFunction
(
addressRef
,
'get - call'
,
''
,
'0: uint256: 45'
)
done
()
.
perform
(()
=>
{
callback
(
null
,
browser
)
})
})
})
})
}
},
'Test Manual Deploy Lib'
:
function
(
browser
)
{
function
testManualDeployLib
(
browser
,
callback
)
{
console
.
log
(
'testManualDeployLib'
)
console
.
log
(
'testManualDeployLib'
)
browser
.
click
(
'i[class^="clearinstance"]'
)
browser
.
click
(
'i[class^="clearinstance"]'
)
.
pause
(
5000
)
.
pause
(
5000
)
...
@@ -106,14 +60,47 @@ function testManualDeployLib (browser, callback) {
...
@@ -106,14 +60,47 @@ function testManualDeployLib (browser, callback) {
.
verifyContracts
([
'test'
])
.
verifyContracts
([
'test'
])
.
selectContract
(
'lib'
)
// deploy lib
.
selectContract
(
'lib'
)
// deploy lib
.
createContract
(
''
)
.
createContract
(
''
)
.
getAddressAtPosition
(
0
,
(
address
)
=>
{
.
perform
((
done
)
=>
{
browser
.
getAddressAtPosition
(
0
,
(
address
)
=>
{
console
.
log
(
address
)
console
.
log
(
address
)
checkDeployShouldFail
(
browser
,
()
=>
{
checkDeployShouldFail
(
browser
,
()
=>
{
checkDeployShouldSucceed
(
browser
,
address
,
()
=>
{
checkDeployShouldSucceed
(
browser
,
address
,
()
=>
{
callback
(
null
,
browser
)
done
()
})
})
})
})
})
})
})
},
'Test Signature'
:
function
(
browser
)
{
let
hash
,
signature
browser
.
signMessage
(
'test message'
,
(
h
,
s
)
=>
{
hash
=
h
signature
=
s
browser
.
assert
.
ok
(
typeof
hash
.
value
===
'string'
,
'type of hash.value must be String'
)
browser
.
assert
.
ok
(
typeof
signature
.
value
===
'string'
,
'type of signature.value must be String'
)
})
.
addFile
(
'signMassage.sol'
,
sources
[
6
][
'browser/signMassage.sol'
])
.
switchFile
(
'browser/signMassage.sol'
)
.
selectContract
(
'ECVerify'
)
.
createContract
(
''
)
.
waitForElementPresent
(
'.instance:nth-of-type(4)'
)
.
click
(
'.instance:nth-of-type(4) > div > button'
)
.
perform
((
done
)
=>
{
browser
.
getAttribute
(
'.instance:nth-of-type(4)'
,
'id'
,
(
result
)
=>
{
// skip 'instance' part of e.g. 'instance0x692a70d2e424a56d2c6c27aa97d1a86395877b3a'
const
address
=
result
.
value
.
slice
(
'instance'
.
length
)
browser
.
clickFunction
(
'ecrecovery - call'
,
{
types
:
'bytes32 hash, bytes sig'
,
values
:
`"
${
hash
.
value
}
","
${
signature
.
value
}
"`
})
.
verifyCallReturnValue
(
address
,
[
'0: address: 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c'
])
.
perform
(()
=>
{
done
()
})
})
})
},
tearDown
:
sauce
}
}
function
checkDeployShouldFail
(
browser
,
callback
)
{
function
checkDeployShouldFail
(
browser
,
callback
)
{
...
@@ -160,33 +147,6 @@ function checkDeployShouldSucceed (browser, address, callback) {
...
@@ -160,33 +147,6 @@ function checkDeployShouldSucceed (browser, address, callback) {
})
})
}
}
function
testSignature
(
browser
,
callback
)
{
let
hash
,
signature
browser
.
signMessage
(
'test message'
,
(
h
,
s
)
=>
{
hash
=
h
signature
=
s
browser
.
assert
.
ok
(
typeof
hash
.
value
===
'string'
,
'type of hash.value must be String'
)
browser
.
assert
.
ok
(
typeof
signature
.
value
===
'string'
,
'type of signature.value must be String'
)
})
.
addFile
(
'signMassage.sol'
,
sources
[
6
][
'browser/signMassage.sol'
])
.
switchFile
(
'browser/signMassage.sol'
)
.
selectContract
(
'ECVerify'
)
.
createContract
(
''
)
.
waitForElementPresent
(
'.instance:nth-of-type(4)'
)
.
click
(
'.instance:nth-of-type(4) > div > button'
)
.
getAttribute
(
'.instance:nth-of-type(4)'
,
'id'
,
(
result
)
=>
{
// skip 'instance' part of e.g. 'instance0x692a70d2e424a56d2c6c27aa97d1a86395877b3a'
const
address
=
result
.
value
.
slice
(
'instance'
.
length
)
browser
.
clickFunction
(
'ecrecovery - call'
,
{
types
:
'bytes32 hash, bytes sig'
,
values
:
`"
${
hash
.
value
}
","
${
signature
.
value
}
"`
})
.
verifyCallReturnValue
(
address
,
[
'0: address: 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c'
])
.
perform
(()
=>
{
callback
(
null
,
browser
)
})
})
}
/*
/*
function testGitHubImport (browser, callback) {
function testGitHubImport (browser, callback) {
contractHelper.addFile(browser, 'Untitled4.sol', sources[3]['browser/Untitled4.sol'], () => {
contractHelper.addFile(browser, 'Untitled4.sol', sources[3]['browser/Untitled4.sol'], () => {
...
...
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