You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
2.9 KiB
101 lines
2.9 KiB
3 years ago
|
'use strict'
|
||
|
import { NightwatchBrowser } from 'nightwatch'
|
||
|
import init from '../helpers/init'
|
||
|
|
||
|
declare global {
|
||
|
interface Window { testplugin: { name: string, url: string }; }
|
||
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
'@disabled': true,
|
||
|
before: function (browser: NightwatchBrowser, done: VoidFunction) {
|
||
2 years ago
|
init(browser, done)
|
||
3 years ago
|
},
|
||
|
|
||
|
'Should connect to vyper plugin #group1': function (browser: NightwatchBrowser) {
|
||
|
browser.clickLaunchIcon('pluginManager')
|
||
|
.scrollAndClick('[data-id="pluginManagerComponentActivateButtonvyper"]')
|
||
|
.clickLaunchIcon('vyper')
|
||
|
.pause(5000)
|
||
|
// @ts-ignore
|
||
|
.frame(0)
|
||
|
},
|
||
|
|
||
3 years ago
|
'Should clone the Vyper repo #group1': function (browser: NightwatchBrowser) {
|
||
|
browser.click('button[data-id="add-repository"]')
|
||
3 years ago
|
.frameParent()
|
||
2 years ago
|
.waitForElementContainsText('*[data-shared="tooltipPopup"]', 'Vyper repository cloned', 60000)
|
||
3 years ago
|
.openFile('examples')
|
||
|
.openFile('examples/auctions')
|
||
|
.openFile('examples/auctions/blind_auction.vy')
|
||
3 years ago
|
},
|
||
|
|
||
3 years ago
|
'Compile blind_auction should success #group1': function (browser: NightwatchBrowser) {
|
||
3 years ago
|
browser.clickLaunchIcon('vyper')
|
||
|
// @ts-ignore
|
||
|
.frame(0)
|
||
|
.click('[data-id="remote-compiler"]')
|
||
|
.click('[data-id="compile"]')
|
||
3 years ago
|
.waitForElementVisible('[data-id="copy-abi"]')
|
||
3 years ago
|
},
|
||
|
|
||
3 years ago
|
'Compile test contract and deploy to remix VM #group1': function (browser: NightwatchBrowser) {
|
||
3 years ago
|
let contractAddress
|
||
|
browser
|
||
|
.frameParent()
|
||
3 years ago
|
.clickLaunchIcon('filePanel')
|
||
|
.switchWorkspace('default_workspace')
|
||
3 years ago
|
.addFile('test.vy', { content: testContract })
|
||
|
.clickLaunchIcon('vyper')
|
||
|
// @ts-ignore
|
||
|
.frame(0)
|
||
|
.click('[data-id="compile"]')
|
||
|
.frameParent()
|
||
|
.clickLaunchIcon('udapp')
|
||
|
.createContract('')
|
||
|
.clickInstance(0)
|
||
|
.clickFunction('totalPokemonCount - call')
|
||
|
.getAddressAtPosition(0, (address) => {
|
||
|
console.log('Vyper contract ' + address)
|
||
|
contractAddress = address
|
||
|
})
|
||
|
.perform((done) => {
|
||
|
browser.verifyCallReturnValue(contractAddress, ['0:uint256: 0'])
|
||
|
.perform(() => done())
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const testContract = `
|
||
|
# @version >=0.2.4 <0.3.0
|
||
|
|
||
|
DNA_DIGITS: constant(uint256) = 16
|
||
|
DNA_MODULUS: constant(uint256) = 10 ** DNA_DIGITS
|
||
|
# add HP_LIMIT
|
||
|
|
||
|
struct Pokemon:
|
||
|
name: String[32]
|
||
|
dna: uint256
|
||
|
HP: uint256
|
||
|
matches: uint256
|
||
|
wins: uint256
|
||
|
|
||
|
totalPokemonCount: public(uint256)
|
||
|
pokemonList: HashMap[uint256, Pokemon]
|
||
|
|
||
|
@pure
|
||
|
@internal
|
||
|
def _generateRandomDNA(_name: String[32]) -> uint256:
|
||
|
random: uint256 = convert(keccak256(_name), uint256)
|
||
|
return random % DNA_MODULUS
|
||
|
# modify _createPokemon
|
||
|
@internal
|
||
|
def _createPokemon(_name: String[32], _dna: uint256, _HP: uint256):
|
||
|
self.pokemonList[self.totalPokemonCount] = Pokemon({
|
||
|
name: _name,
|
||
|
dna: _dna,
|
||
|
HP: _HP,
|
||
|
matches: 0,
|
||
|
wins: 0
|
||
|
})
|
||
|
self.totalPokemonCount += 1`
|