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
50d23c06
Unverified
Commit
50d23c06
authored
Jun 25, 2019
by
yann300
Committed by
GitHub
Jun 25, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2111 from ethereum/refactorBrowserTests
Reorganize test files
parents
fdf51b0d
72628b4e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
408 additions
and
20 deletions
+408
-20
makeMockCompiler.js
ci/makeMockCompiler.js
+0
-1
package.json
package.json
+2
-1
clickInstance.js
test-browser/commands/clickInstance.js
+11
-0
generalTests.js
test-browser/tests/generalTests.js
+0
-0
libraryDeployment.js
test-browser/tests/libraryDeployment.js
+115
-0
recorder.js
test-browser/tests/recorder.js
+18
-8
signingMessage.js
test-browser/tests/signingMessage.js
+89
-0
solidityImport.js
test-browser/tests/solidityImport.js
+169
-0
transactionExecution.js
test-browser/tests/transactionExecution.js
+4
-10
No files found.
ci/makeMockCompiler.js
View file @
50d23c06
...
...
@@ -9,7 +9,6 @@ compiler.loadRemoteVersion(defaultVersion, (error, solcSnapshot) => {
if
(
error
)
console
.
log
(
error
)
var
compilationResult
=
{}
gatherCompilationResults
(
'./test-browser/tests/'
,
compilationResult
,
solcSnapshot
)
gatherCompilationResults
(
'./test-browser/tests/units/'
,
compilationResult
,
solcSnapshot
)
replaceSolCompiler
(
compilationResult
,
solcSnapshot
)
})
...
...
package.json
View file @
50d23c06
...
...
@@ -153,7 +153,8 @@
"make-mock-compiler"
:
"node ci/makeMockCompiler.js"
,
"minify"
:
"uglifyjs --in-source-map inline --source-map-inline -c warnings=false"
,
"nightwatch_local"
:
"nightwatch --config nightwatch.js --env local"
,
"nightwatch_local_general"
:
"nightwatch ./test-browser/tests/generalTests.js --config nightwatch.js --env local "
,
"nightwatch_local_recorder"
:
"nightwatch ./test-browser/tests/recorder.js --config nightwatch.js --env local "
,
"nightwatch_local_signingMessage"
:
"nightwatch ./test-browser/tests/signingMessage.js --config nightwatch.js --env local "
,
"nightwatch_local_sharedFolderExplorer"
:
"nightwatch ./test-browser/tests/sharedFolderExplorer.js --config nightwatch.js --env local "
,
"nightwatch_local_debugger"
:
"nightwatch --config nightwatch_debugger.js --env local"
,
"nightwatch_remote_chrome"
:
"nightwatch --config nightwatch.js --env chrome"
,
...
...
test-browser/commands/clickInstance.js
0 → 100644
View file @
50d23c06
const
EventEmitter
=
require
(
'events'
)
class
ClickInstance
extends
EventEmitter
{
command
(
index
)
{
index
=
index
+
2
this
.
api
.
click
(
'.instance:nth-of-type('
+
index
+
') > div > button'
).
perform
(()
=>
{
this
.
emit
(
'complete'
)
})
return
this
}
}
module
.
exports
=
ClickInstance
test-browser/tests/generalTests.js
deleted
100644 → 0
View file @
fdf51b0d
This diff is collapsed.
Click to expand it.
test-browser/tests/libraryDeployment.js
0 → 100644
View file @
50d23c06
'use strict'
var
init
=
require
(
'../helpers/init'
)
var
sauce
=
require
(
'./sauce'
)
module
.
exports
=
{
before
:
function
(
browser
,
done
)
{
init
(
browser
,
done
)
},
'@sources'
:
function
()
{
return
sources
},
'Add Lib Test File'
:
function
(
browser
)
{
browser
.
addFile
(
'Untitled5.sol'
,
sources
[
0
][
'browser/Untitled5.sol'
])
},
'Test Auto Deploy Lib'
:
function
(
browser
)
{
let
addressRef
browser
.
verifyContracts
([
'test'
])
.
selectContract
(
'test'
)
.
createContract
(
''
)
.
getAddressAtPosition
(
0
,
(
address
)
=>
{
console
.
log
(
'testAutoDeployLib '
+
address
)
addressRef
=
address
})
.
waitForElementPresent
(
'.instance:nth-of-type(2)'
)
.
click
(
'.instance:nth-of-type(2) > div > button'
)
.
perform
((
done
)
=>
{
browser
.
testConstantFunction
(
addressRef
,
'get - call'
,
''
,
'0: uint256: 45'
).
perform
(()
=>
{
done
()
})
})
},
'Test Manual Deploy Lib'
:
function
(
browser
)
{
console
.
log
(
'testManualDeployLib'
)
browser
.
click
(
'i[class^="clearinstance"]'
)
.
pause
(
5000
)
.
clickLaunchIcon
(
'settings'
)
.
click
(
'#generatecontractmetadata'
)
.
clickLaunchIcon
(
'solidity'
)
.
click
(
'#compileTabView button[title="Compile"]'
)
// that should generate the JSON artefact
.
verifyContracts
([
'test'
])
.
selectContract
(
'lib'
)
// deploy lib
.
createContract
(
''
)
.
perform
((
done
)
=>
{
browser
.
getAddressAtPosition
(
0
,
(
address
)
=>
{
console
.
log
(
address
)
checkDeployShouldFail
(
browser
,
()
=>
{
checkDeployShouldSucceed
(
browser
,
address
,
()
=>
{
done
()
})
})
})
})
},
tearDown
:
sauce
}
function
checkDeployShouldFail
(
browser
,
callback
)
{
let
config
browser
.
switchFile
(
'browser/test.json'
)
.
getEditorValue
((
content
)
=>
{
config
=
JSON
.
parse
(
content
)
config
.
deploy
[
'VM:-'
].
autoDeployLib
=
false
})
.
perform
(()
=>
{
browser
.
setEditorValue
(
JSON
.
stringify
(
config
))
})
.
switchFile
(
'browser/Untitled5.sol'
)
.
selectContract
(
'test'
)
// deploy lib
.
createContract
(
''
)
.
assert
.
containsText
(
'div[class^="terminal"]'
,
'<address> is not a valid address'
)
.
perform
(()
=>
{
callback
()
})
}
function
checkDeployShouldSucceed
(
browser
,
address
,
callback
)
{
let
addressRef
let
config
browser
.
switchFile
(
'browser/test.json'
)
.
getEditorValue
((
content
)
=>
{
config
=
JSON
.
parse
(
content
)
config
.
deploy
[
'VM:-'
].
autoDeployLib
=
false
config
.
deploy
[
'VM:-'
][
'linkReferences'
][
'browser/Untitled5.sol'
].
lib
=
address
})
.
perform
(()
=>
{
browser
.
setEditorValue
(
JSON
.
stringify
(
config
))
})
.
switchFile
(
'browser/Untitled5.sol'
)
.
selectContract
(
'test'
)
// deploy lib
.
createContract
(
''
)
.
getAddressAtPosition
(
1
,
(
address
)
=>
{
addressRef
=
address
})
.
waitForElementPresent
(
'.instance:nth-of-type(3)'
)
.
click
(
'.instance:nth-of-type(3) > div > button'
)
.
perform
(()
=>
{
browser
.
testConstantFunction
(
addressRef
,
'get - call'
,
''
,
'0: uint256: 45'
)
.
perform
(()
=>
{
callback
()
})
})
}
var
sources
=
[
{
'browser/Untitled5.sol'
:
{
content
:
`library lib {
function getInt () public view returns (uint) {
return 45;
}
}
contract test {
function get () public view returns (uint) {
return lib.getInt();
}
}`
}
}
]
test-browser/tests/
units/testR
ecorder.js
→
test-browser/tests/
r
ecorder.js
View file @
50d23c06
'use strict'
var
sauce
=
require
(
'./sauce'
)
var
init
=
require
(
'../helpers/init'
)
module
.
exports
=
{
'@disabled'
:
true
,
// run by compiling.
before
:
function
(
browser
,
done
)
{
init
(
browser
,
done
)
},
'@sources'
:
function
()
{
return
sources
},
test
:
function
(
browser
,
callback
)
{
'Test Recorder'
:
function
(
browser
)
{
var
addressRef
browser
.
addFile
(
'scenario.json'
,
{
content
:
records
})
.
clickLaunchIcon
(
'run'
)
.
click
(
'div[class^="cardContainer"] i[class^="arrow"]'
)
...
...
@@ -18,8 +23,14 @@ module.exports = {
.
clickFunction
(
'getAddress - call'
)
.
clickFunction
(
'getFromLib - call'
)
.
waitForElementPresent
(
'div[class^="contractActionsContainer"] div[class^="value"] ul'
)
.
verifyCallReturnValue
(
'0x35ef07393b57464e93deb59175ff72e6499450cf'
,
[
'0: uint256: 1'
,
'0: uint256: 3456'
,
'0: address: 0x35eF07393b57464e93dEB59175fF72E6499450cF'
])
.
getAddressAtPosition
(
1
,
(
address
)
=>
{
console
.
log
(
'Test Recorder '
+
address
)
addressRef
=
address
})
.
perform
((
done
)
=>
{
browser
.
verifyCallReturnValue
(
addressRef
,
[
'0: uint256: 1'
,
'0: uint256: 3456'
,
'0: address: 0xbBF289D846208c16EDc8474705C748aff07732dB'
])
.
perform
(()
=>
done
())
})
.
click
(
'i[class^="clearinstance"]'
)
.
testContracts
(
'testRecorder.sol'
,
sources
[
0
][
'browser/testRecorder.sol'
],
[
'testRecorder'
])
.
createContract
(
'12'
)
...
...
@@ -41,10 +52,9 @@ module.exports = {
browser
.
assert
.
equal
(
JSON
.
stringify
(
parsed
.
transactions
[
1
].
record
.
type
),
JSON
.
stringify
(
scenario
.
transactions
[
1
].
record
.
type
))
browser
.
assert
.
equal
(
JSON
.
stringify
(
parsed
.
transactions
[
1
].
record
.
from
),
JSON
.
stringify
(
scenario
.
transactions
[
1
].
record
.
from
))
})
.
perform
(()
=>
{
callback
()
})
}
.
end
()
},
tearDown
:
sauce
}
var
sources
=
[{
'browser/testRecorder.sol'
:
{
content
:
`contract testRecorder {
...
...
test-browser/tests/signingMessage.js
0 → 100644
View file @
50d23c06
'use strict'
var
init
=
require
(
'../helpers/init'
)
var
sauce
=
require
(
'./sauce'
)
module
.
exports
=
{
before
:
function
(
browser
,
done
)
{
init
(
browser
,
done
)
},
'@sources'
:
function
()
{
return
sources
},
'Test Signature'
:
function
(
browser
)
{
let
hash
,
signature
browser
.
clickLaunchIcon
(
'run'
).
signMessage
(
'test message'
,
(
h
,
s
)
=>
{
hash
=
h
signature
=
s
console
.
log
(
'hash'
,
hash
)
console
.
log
(
'signature'
,
signature
)
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
[
0
][
'browser/signMassage.sol'
])
.
switchFile
(
'browser/signMassage.sol'
)
.
selectContract
(
'ECVerify'
)
.
createContract
(
''
)
.
clickInstance
(
0
)
.
perform
((
done
)
=>
{
browser
.
getAddressAtPosition
(
0
,
(
address
)
=>
{
// skip 'instance' part of e.g. 'instance0x692a70d2e424a56d2c6c27aa97d1a86395877b3a'
console
.
log
(
'Test Signature address'
,
address
)
var
inputs
=
`"
${
hash
.
value
}
","
${
signature
.
value
}
"`
console
.
log
(
'Test Signature Input'
,
inputs
)
browser
.
clickFunction
(
'ecrecovery - call'
,
{
types
:
'bytes32 hash, bytes sig'
,
values
:
inputs
})
.
pause
(
5000
)
.
verifyCallReturnValue
(
address
,
[
'0: address: 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c'
])
.
perform
(()
=>
{
done
()
})
})
})
.
end
()
},
tearDown
:
sauce
}
var
sources
=
[
{
'browser/signMassage.sol'
:
{
content
:
`
contract SignMassageTest {
function testRecovery(bytes32 h, uint8 v, bytes32 r, bytes32 s) public pure returns (address) {
return ecrecover(h, v, r, s);
}
}
library ECVerify {
function ecrecovery(bytes32 hash, bytes memory sig) public pure returns (address) {
bytes32 r;
bytes32 s;
uint8 v;
if (sig.length != 65) {
return address(0);
}
assembly {
r := mload(add(sig, 32))
s := mload(add(sig, 64))
v := and(mload(add(sig, 65)), 255)
}
if (v < 27) {
v += 27;
}
if (v != 27 && v != 28) {
return address(0);
}
return ecrecover(hash, v, r, s);
}
function ecverify(bytes32 hash, bytes memory sig, address signer) public pure returns (bool) {
return signer == ecrecovery(hash, sig);
}
}`
}
}
]
test-browser/tests/solidityImport.js
0 → 100644
View file @
50d23c06
'use strict'
var
init
=
require
(
'../helpers/init'
)
var
sauce
=
require
(
'./sauce'
)
module
.
exports
=
{
before
:
function
(
browser
,
done
)
{
init
(
browser
,
done
)
},
'@sources'
:
function
()
{
return
sources
},
'Test Simple Contract'
:
function
(
browser
)
{
browser
.
testContracts
(
'Untitled.sol'
,
sources
[
0
][
'browser/Untitled.sol'
],
[
'test1'
,
'test2'
])
},
'Test Success Import'
:
function
(
browser
)
{
browser
.
addFile
(
'Untitled1.sol'
,
sources
[
1
][
'browser/Untitled1.sol'
])
.
addFile
(
'Untitled2.sol'
,
sources
[
1
][
'browser/Untitled2.sol'
])
.
switchFile
(
'browser/Untitled1.sol'
)
.
verifyContracts
([
'test6'
,
'test4'
,
'test5'
])
},
'Test Failed Import'
:
function
(
browser
)
{
browser
.
addFile
(
'Untitled3.sol'
,
sources
[
2
][
'browser/Untitled3.sol'
])
.
clickLaunchIcon
(
'solidity'
)
.
assert
.
containsText
(
'#compileTabView .error pre'
,
'Unable to import "browser/Untitled11.sol": File not found'
)
.
end
()
},
tearDown
:
sauce
}
var
abstractENS
=
`
contract AbstractENS {
function owner(bytes32 node) public view returns(address);
function resolver(bytes32 node) public view returns(address);
function ttl(bytes32 node) public view returns(uint64);
function setOwner(bytes32 node, address owner) public;
function setSubnodeOwner(bytes32 node, bytes32 label, address owner) public;
function setResolver(bytes32 node, address resolver) public;
function setTTL(bytes32 node, uint64 ttl) public;
// Logged when the owner of a node assigns a new owner to a subnode.
event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner);
// Logged when the owner of a node transfers ownership to a new account.
event Transfer(bytes32 indexed node, address owner);
// Logged when the resolver for a node changes.
event NewResolver(bytes32 indexed node, address resolver);
// Logged when the TTL of a node changes
event NewTTL(bytes32 indexed node, uint64 ttl);
}`
var
ENS
=
`pragma solidity ^0.4.0;
import './AbstractENS.sol';
/**
* The ENS registry contract.
*/
contract ENS is AbstractENS {
struct Record {
address owner;
address resolver;
uint64 ttl;
}
mapping(bytes32=>Record) records;
// Permits modifications only by the owner of the specified node.
modifier only_owner(bytes32 node) {
if (records[node].owner != msg.sender) revert();
_;
}
/**
* Constructs a new ENS registrar.
*/
constructor() public {
records[0].owner = msg.sender;
}
/**
* Returns the address that owns the specified node.
*/
function owner(bytes32 node) public view returns (address) {
return records[node].owner;
}
/**
* Returns the address of the resolver for the specified node.
*/
function resolver(bytes32 node) public view returns (address) {
return records[node].resolver;
}
/**
* Returns the TTL of a node, and any records associated with it.
*/
function ttl(bytes32 node) public view returns (uint64) {
return records[node].ttl;
}
/**
* Transfers ownership of a node to a new address. May only be called by the current
* owner of the node.
* @param node The node to transfer ownership of.
* @param owner The address of the new owner.
*/
function setOwner(bytes32 node, address owner) public only_owner(node) {
emit Transfer(node, owner);
records[node].owner = owner;
}
/**
* Transfers ownership of a subnode sha3(node, label) to a new address. May only be
* called by the owner of the parent node.
* @param node The parent node.
* @param label The hash of the label specifying the subnode.
* @param owner The address of the new owner.
*/
function setSubnodeOwner(bytes32 node, bytes32 label, address owner) public only_owner(node) {
bytes32 subnode = keccak256(abi.encodePacked(node, label));
emit NewOwner(node, label, owner);
records[subnode].owner = owner;
}
/**
* Sets the resolver address for the specified node.
* @param node The node to update.
* @param resolver The address of the resolver.
*/
function setResolver(bytes32 node, address resolver) public only_owner(node) {
emit NewResolver(node, resolver);
records[node].resolver = resolver;
}
/**
* Sets the TTL for the specified node.
* @param node The node to update.
* @param ttl The TTL in seconds.
*/
function setTTL(bytes32 node, uint64 ttl) public only_owner(node) {
emit NewTTL(node, ttl);
records[node].ttl = ttl;
}
}`
var
sources
=
[
{
'browser/Untitled.sol'
:
{
content
:
'contract test1 {} contract test2 {}'
}
},
{
'browser/Untitled1.sol'
:
{
content
:
'import "./Untitled2.sol"; contract test6 {}'
},
'browser/Untitled2.sol'
:
{
content
:
'contract test4 {} contract test5 {}'
}
},
{
'browser/Untitled3.sol'
:
{
content
:
'import "./Untitled11.sol"; contract test6 {}'
}
},
{
'browser/Untitled4.sol'
:
{
content
:
'import "github.com/ethereum/ens/contracts/ENS.sol"; contract test7 {}'
},
'github.com/ethereum/ens/contracts/ENS.sol'
:
{
content
:
ENS
}
},
{
'browser/Untitled4.sol'
:
{
content
:
'import "github.com/ethereum/ens/contracts/ENS.sol"; contract test7 {}'
},
'github.com/ethereum/ens/contracts/ENS.sol'
:
{
content
:
ENS
},
'github.com/ethereum/ens/contracts/AbstractENS.sol'
:
{
content
:
abstractENS
}
}
]
test-browser/tests/
compiling
.js
→
test-browser/tests/
transactionExecution
.js
View file @
50d23c06
'use strict'
var
init
=
require
(
'../helpers/init'
)
var
sauce
=
require
(
'./sauce'
)
var
testRecorder
=
require
(
'./units/testRecorder'
)
module
.
exports
=
{
before
:
function
(
browser
,
done
)
{
...
...
@@ -11,7 +10,7 @@ module.exports = {
return
sources
},
'
Test Simple Contract
'
:
function
(
browser
)
{
'
Execute Simple Contract and Test Terminal
'
:
function
(
browser
)
{
browser
.
testContracts
(
'Untitled.sol'
,
sources
[
0
][
'browser/Untitled.sol'
],
[
'TestContract'
])
.
clickLaunchIcon
(
'run'
)
.
click
(
'#runTabView button[class^="instanceButton"]'
)
...
...
@@ -38,7 +37,7 @@ module.exports = {
.
click
(
'i[class^="clearinstance"]'
)
},
'Test Return Values'
:
function
(
browser
)
{
'Test
Complex
Return Values'
:
function
(
browser
)
{
browser
.
testContracts
(
'returnValues.sol'
,
sources
[
1
][
'browser/returnValues.sol'
],
[
'testReturnValues'
])
.
clickLaunchIcon
(
'run'
)
.
click
(
'#runTabView button[class^="instanceButton"]'
)
...
...
@@ -75,7 +74,7 @@ module.exports = {
}`
).
click
(
'i[class^="clearinstance"]'
)
},
'Test Input Values'
:
function
(
browser
)
{
'Test
Complex
Input Values'
:
function
(
browser
)
{
browser
.
testContracts
(
'inputValues.sol'
,
sources
[
2
][
'browser/inputValues.sol'
],
[
'test'
])
.
clickLaunchIcon
(
'run'
)
.
click
(
'#runTabView button[class^="instanceButton"]'
)
...
...
@@ -125,12 +124,7 @@ module.exports = {
}
]`
)
.
click
(
'i[class^="clearinstance"]'
)
},
'Test Recorder'
:
function
(
browser
)
{
testRecorder
.
test
(
browser
,
()
=>
{
browser
.
end
()
})
.
end
()
},
tearDown
:
sauce
...
...
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