From d9dcb162ce22f672725db04380adea5b02c55f3c Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 9 Oct 2024 18:09:00 +0200 Subject: [PATCH] add testd --- .../remix-ide-e2e/src/tests/vyper_api.test.ts | 52 +++++++++++++++++++ apps/vyper/src/app/app.tsx | 4 +- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/vyper_api.test.ts b/apps/remix-ide-e2e/src/tests/vyper_api.test.ts index e38583a9ae..14eb9dd673 100644 --- a/apps/remix-ide-e2e/src/tests/vyper_api.test.ts +++ b/apps/remix-ide-e2e/src/tests/vyper_api.test.ts @@ -114,6 +114,25 @@ module.exports = { } }, + 'Should lead to a compilation error #group1': function (browser: NightwatchBrowser) { + browser + .clickLaunchIcon('filePanel') + .switchWorkspace('default_workspace') + .addFile('test_error.vy', { content: wrongContract }) + .clickLaunchIcon('vyper') + // @ts-ignore + .frame(0) + .waitForElementVisible('[data-id="compile"]') + .click('[data-id="compile"]') + .waitForElementVisible({ + selector:'[data-id="test_error.vy"]', + timeout: 60000 + }) + .waitForElementContainsText('[data-id="test_error.vy"]', 'ERROR') + .waitForElementContainsText('[data-id="test_error.vy"]', 'StructureException:Unsupported syntax for module namespace') + .frameParent() + }, + 'Compile test contract and deploy to remix VM #group1': function (browser: NightwatchBrowser) { let contractAddress browser @@ -206,6 +225,39 @@ def _createPokemon(_name: String[32], _dna: uint256, _HP: uint256): wins: 0 }) self.totalPokemonCount += 1` + +const wrongContract = ` +DNA_DIGITS: constant(uint256) = 16 +DNA_MODULUS: constant(uint256) = 10 ** DNA_DIGITS +# add HP_LIMIT +ERROR +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` + const sources = [{ 'blindAuction' : { content: ` diff --git a/apps/vyper/src/app/app.tsx b/apps/vyper/src/app/app.tsx index 915cfd35bc..8004d9c210 100644 --- a/apps/vyper/src/app/app.tsx +++ b/apps/vyper/src/app/app.tsx @@ -88,7 +88,7 @@ const App = () => { useEffect(() => { remixClient.eventEmitter.on('setOutput', (payload) => { setOutput(payload) - }) + }) return () => { remixClient.eventEmitter.off('setOutput', (payload) => { @@ -181,8 +181,6 @@ const App = () => { } {output && output.status === 'failed' && output.errors && output.errors.map((error: VyperCompilationError, index: number) => { - // we need to tweak the path to not show the filesystem absolute error. - return