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
ba9ca8d0
Commit
ba9ca8d0
authored
Dec 10, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add recorder tests
parent
fa77260c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
160 additions
and
17 deletions
+160
-17
run-tab.js
src/app/tabs/run-tab.js
+2
-2
contracts.js
test-browser/helpers/contracts.js
+35
-2
ballot.js
test-browser/tests/ballot.js
+2
-0
compiling.js
test-browser/tests/compiling.js
+3
-1
testRecorder.js
test-browser/tests/units/testRecorder.js
+118
-12
No files found.
src/app/tabs/run-tab.js
View file @
ba9ca8d0
...
...
@@ -196,7 +196,7 @@ var pendingTxsText = yo`<span></span>`
function
runTab
(
container
,
appAPI
,
appEvents
,
opts
)
{
var
events
=
new
EventManager
()
var
clearInstanceElement
=
yo
`<i class="
fa fa-minus-square-o
${
css
.
clearinstance
}
" title="Clear Instances List" aria-hidden="true"></i>`
var
clearInstanceElement
=
yo
`<i class="
${
css
.
clearinstance
}
fa fa-minus-square-o
" title="Clear Instances List" aria-hidden="true"></i>`
clearInstanceElement
.
addEventListener
(
'click'
,
()
=>
{
events
.
trigger
(
'clearInstance'
,
[])
})
...
...
@@ -368,7 +368,7 @@ function contractDropdown (events, appAPI, appEvents, instanceContainer) {
})
var
atAddressButtonInput
=
yo
`<input class="
${
css
.
input
}
ataddressinput" placeholder="Load contract from Address" title="atAddress" />`
var
createButtonInput
=
yo
`<input class="
${
css
.
input
}
" placeholder="" title="Create" />`
var
createButtonInput
=
yo
`<input class="
${
css
.
input
}
create
" placeholder="" title="Create" />`
var
selectContractNames
=
yo
`<select class="
${
css
.
contractNames
}
" disabled></select>`
function
getSelectedContract
()
{
...
...
test-browser/helpers/contracts.js
View file @
ba9ca8d0
...
...
@@ -14,7 +14,10 @@ module.exports = {
addInstance
,
clickFunction
,
verifyCallReturnValue
,
setEditorValue
createContract
,
modalFooterOKClick
,
setEditorValue
,
getEditorValue
}
function
getCompiledContracts
(
browser
,
compiled
,
callback
)
{
...
...
@@ -34,6 +37,13 @@ function getCompiledContracts (browser, compiled, callback) {
})
}
function
createContract
(
browser
,
inputParams
,
callback
)
{
browser
.
click
(
'.runView'
)
.
setValue
(
'input.create'
,
inputParams
,
function
()
{
browser
.
click
(
'#runTabView div[class^="create"]'
).
perform
(
function
()
{
callback
()
})
})
}
function
verifyContract
(
browser
,
compiledContractNames
,
callback
)
{
getCompiledContracts
(
browser
,
compiledContractNames
,
(
result
)
=>
{
if
(
result
.
value
)
{
...
...
@@ -96,7 +106,7 @@ function verifyCallReturnValue (browser, address, checks, done) {
return
ret
},
[
address
],
function
(
result
)
{
for
(
var
k
in
checks
)
{
browser
.
assert
.
equal
(
checks
[
k
],
result
.
value
[
k
])
browser
.
assert
.
equal
(
result
.
value
[
k
],
checks
[
k
])
}
done
()
})
...
...
@@ -162,6 +172,29 @@ function addInstance (browser, address, callback) {
})
}
function
getEditorValue
(
callback
)
{
this
.
perform
((
client
,
done
)
=>
{
this
.
execute
(
function
(
value
)
{
return
document
.
getElementById
(
'input'
).
editor
.
getValue
()
},
[],
function
(
result
)
{
done
(
result
.
value
)
callback
(
result
.
value
)
})
})
return
this
}
function
modalFooterOKClick
()
{
this
.
perform
((
client
,
done
)
=>
{
this
.
execute
(
function
()
{
document
.
querySelector
(
'#modal-footer-ok'
).
click
()
},
[],
function
(
result
)
{
done
()
})
})
return
this
}
function
addFile
(
browser
,
name
,
content
,
done
)
{
browser
.
click
(
'.newFile'
)
.
perform
((
client
,
done
)
=>
{
...
...
test-browser/tests/ballot.js
View file @
ba9ca8d0
...
...
@@ -23,6 +23,8 @@ module.exports = {
function
runTests
(
browser
,
testData
)
{
browser
.
testFunction
=
contractHelper
.
testFunction
browser
.
clickFunction
=
contractHelper
.
clickFunction
browser
.
modalFooterOKClick
=
contractHelper
.
modalFooterOKClick
browser
.
setEditorValue
=
contractHelper
.
setEditorValue
browser
.
waitForElementVisible
(
'.newFile'
,
10000
)
...
...
test-browser/tests/compiling.js
View file @
ba9ca8d0
...
...
@@ -22,12 +22,14 @@ function runTests (browser) {
browser
.
testFunction
=
contractHelper
.
testFunction
browser
.
clickFunction
=
contractHelper
.
clickFunction
browser
.
setEditorValue
=
contractHelper
.
setEditorValue
browser
.
modalFooterOKClick
=
contractHelper
.
modalFooterOKClick
browser
.
getEditorValue
=
contractHelper
.
getEditorValue
browser
.
waitForElementVisible
(
'.newFile'
,
10000
)
.
click
(
'.compileView'
)
.
perform
(()
=>
{
// the first fn is used to pass browser to the other ones.
async
.
waterfall
([
function
(
callback
)
{
callback
(
null
,
browser
)
},
testSimpleContract
,
testReturnValues
,
testInputValues
,
testRecorder
],
function
()
{
async
.
waterfall
([
function
(
callback
)
{
callback
(
null
,
browser
)
},
testSimpleContract
,
testReturnValues
,
testInputValues
,
testRecorder
.
test
],
function
()
{
browser
.
end
()
})
})
...
...
test-browser/tests/units/testRecorder.js
View file @
ba9ca8d0
'use strict'
var
contractHelper
=
require
(
'../../helpers/contracts'
)
module
.
exports
=
function
(
browser
,
callback
)
{
contractHelper
.
addFile
(
browser
,
'scenario.json'
,
{
content
:
records
},
()
=>
{
browser
.
click
(
'.runView'
)
.
click
(
'#runTabView .runtransaction'
)
.
clickFunction
(
'getInt - call'
)
.
clickFunction
(
'getAddress - call'
)
.
clickFunction
(
'getFromLib - call'
)
.
waitForElementPresent
(
'div[class^="contractProperty"] div[class^="value"]'
)
.
perform
(()
=>
{
contractHelper
.
verifyCallReturnValue
(
browser
,
'0x35ef07393b57464e93deb59175ff72e6499450cf'
,
[
'0: uint256: 1'
,
'0: uint256: 3456'
,
'0: address: 0xca35b7d915458ef540ade6068dfe2f44e8fa733c'
],
()
=>
{
callback
()
})
module
.
exports
=
{
'@sources'
:
function
()
{
return
sources
},
test
:
function
(
browser
,
callback
)
{
contractHelper
.
addFile
(
browser
,
'scenario.json'
,
{
content
:
records
},
()
=>
{
browser
.
click
(
'.runView'
)
.
click
(
'#runTabView .runtransaction'
)
.
clickFunction
(
'getInt - call'
)
.
clickFunction
(
'getAddress - call'
)
.
clickFunction
(
'getFromLib - call'
)
.
waitForElementPresent
(
'div[class^="contractProperty"] div[class^="value"]'
)
.
perform
((
client
,
done
)
=>
{
contractHelper
.
verifyCallReturnValue
(
browser
,
'0x35ef07393b57464e93deb59175ff72e6499450cf'
,
[
'0: uint256: 1'
,
'0: uint256: 3456'
,
'0: address: 0xca35b7d915458ef540ade6068dfe2f44e8fa733c'
],
()
=>
{
done
()
})
})
.
click
(
'i[class^="clearinstance"]'
)
.
perform
((
client
,
done
)
=>
{
contractHelper
.
testContracts
(
browser
,
'testRecorder.sol'
,
sources
[
0
][
'browser/testRecorder.sol'
],
[
'testRecorder'
],
function
()
{
contractHelper
.
createContract
(
browser
,
'12'
,
function
()
{
browser
.
clickFunction
(
'set - transact (not payable)'
,
{
types
:
'uint256 _p'
,
values
:
'34'
})
.
click
(
'i.savetransaction'
).
modalFooterOKClick
().
getEditorValue
(
function
(
result
)
{
var
parsed
=
JSON
.
parse
(
result
)
browser
.
assert
.
equal
(
JSON
.
stringify
(
parsed
.
transactions
[
0
].
record
.
parameters
),
JSON
.
stringify
(
scenario
.
transactions
[
0
].
record
.
parameters
))
browser
.
assert
.
equal
(
JSON
.
stringify
(
parsed
.
transactions
[
0
].
record
.
name
),
JSON
.
stringify
(
scenario
.
transactions
[
0
].
record
.
name
))
browser
.
assert
.
equal
(
JSON
.
stringify
(
parsed
.
transactions
[
0
].
record
.
type
),
JSON
.
stringify
(
scenario
.
transactions
[
0
].
record
.
type
))
browser
.
assert
.
equal
(
JSON
.
stringify
(
parsed
.
transactions
[
0
].
record
.
from
),
JSON
.
stringify
(
scenario
.
transactions
[
0
].
record
.
from
))
browser
.
assert
.
equal
(
JSON
.
stringify
(
parsed
.
transactions
[
0
].
record
.
contractName
),
JSON
.
stringify
(
scenario
.
transactions
[
0
].
record
.
contractName
))
browser
.
assert
.
equal
(
JSON
.
stringify
(
parsed
.
transactions
[
1
].
record
.
parameters
),
JSON
.
stringify
(
scenario
.
transactions
[
1
].
record
.
parameters
))
browser
.
assert
.
equal
(
JSON
.
stringify
(
parsed
.
transactions
[
1
].
record
.
name
),
JSON
.
stringify
(
scenario
.
transactions
[
1
].
record
.
name
))
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
))
callback
()
})
})
})
})
})
}
)
}
}
var
sources
=
[{
'browser/testRecorder.sol'
:
{
content
:
`pragma solidity ^0.4.0;contract testRecorder {
function testRecorder(uint p) {
}
function set (uint _p) {
}
}`
}}]
var
records
=
`{
"accounts": {
"account{0}": "0xca35b7d915458ef540ade6068dfe2f44e8fa733c"
...
...
@@ -170,3 +208,71 @@ var records = `{
]
}
}`
var
scenario
=
{
'accounts'
:
{
'account{0}'
:
'0xca35b7d915458ef540ade6068dfe2f44e8fa733c'
},
'linkReferences'
:
{},
'transactions'
:
[
{
'timestamp'
:
1512912691086
,
'record'
:
{
'value'
:
'0'
,
'parameters'
:
[
12
],
'abi'
:
'0x54a8c0ab653c15bfb48b47fd011ba2b9617af01cb45cab344acd57c924d56798'
,
'contractName'
:
'testRecorder'
,
'bytecode'
:
'6060604052341561000f57600080fd5b6040516020806100cd833981016040528080519060200190919050505060938061003a6000396000f300606060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b1146044575b600080fd5b3415604e57600080fd5b606260048080359060200190919050506064565b005b505600a165627a7a723058204839660366b94f5f3c8c6da233a2c5fe95ad5635b5c8a2bb630a8b845d68ecdd0029'
,
'linkReferences'
:
{},
'name'
:
''
,
'type'
:
'constructor'
,
'from'
:
'account{0}'
}
},
{
'timestamp'
:
1512912696128
,
'record'
:
{
'value'
:
'0'
,
'parameters'
:
[
34
],
'to'
:
'created{1512912691086}'
,
'abi'
:
'0x54a8c0ab653c15bfb48b47fd011ba2b9617af01cb45cab344acd57c924d56798'
,
'name'
:
'set'
,
'type'
:
'function'
,
'from'
:
'account{0}'
}
}
],
'abis'
:
{
'0x54a8c0ab653c15bfb48b47fd011ba2b9617af01cb45cab344acd57c924d56798'
:
[
{
'constant'
:
false
,
'inputs'
:
[
{
'name'
:
'_p'
,
'type'
:
'uint256'
}
],
'name'
:
'set'
,
'outputs'
:
[],
'payable'
:
false
,
'stateMutability'
:
'nonpayable'
,
'type'
:
'function'
},
{
'inputs'
:
[
{
'name'
:
'p'
,
'type'
:
'uint256'
}
],
'payable'
:
false
,
'stateMutability'
:
'nonpayable'
,
'type'
:
'constructor'
}
]
}
}
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