From 47ed2e39c1da037838adb3571394cce969818c41 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 11 Feb 2025 13:16:25 +0100 Subject: [PATCH] add E2E --- apps/remix-ide-e2e/src/tests/vm_state.test.ts | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/apps/remix-ide-e2e/src/tests/vm_state.test.ts b/apps/remix-ide-e2e/src/tests/vm_state.test.ts index 2c02750859e..41c0f9491cf 100644 --- a/apps/remix-ide-e2e/src/tests/vm_state.test.ts +++ b/apps/remix-ide-e2e/src/tests/vm_state.test.ts @@ -39,6 +39,7 @@ const tests = { ) }, 'Should fork state successfully #group1': function (browser: NightwatchBrowser) { + let contractAddress = '' browser .openFile('contracts') .openFile('contracts/1_Storage.sol') @@ -46,6 +47,12 @@ const tests = { .clickLaunchIcon('udapp') .click('[data-id="Deploy - transact (not payable)"]') .clickInstance(0) + .perform((done) => { + browser.getAddressAtPosition(0, (address) => { + contractAddress = address + done() + }) + }) .clickFunction('store - transact (not payable)', { types: 'uint256 num', values: '"55"' }) .testFunction('last', { @@ -81,6 +88,42 @@ const tests = { browser.assert.ok(content.indexOf(`"db":`) !== -1) browser.assert.ok(content.indexOf(`"blocks":`) !== -1) }) + // fork again this state + .click('*[data-id="fork-state-icon"]') + .waitForElementVisible('*[data-id="udappNotifyModalDialogModalTitle-react"]') + .click('input[data-id="modalDialogForkState"]') + .setValue('input[data-id="modalDialogForkState"]', 'forkedState_2') + .modalFooterOKClick('udappNotify') + // load the previous contract + .addAtAddressInstance(contractAddress, false, false, false) + .clickInstance(0) + // check that the state is loaded + .clickFunction('retrieve - call') + .testFunction('last', + { + 'decoded output': { '0': 'uint256: 55' } + }) + // update the state + .clickFunction('store - transact (not payable)', { types: 'uint256 num', values: '"57"' }) + .testFunction('last', + { + status: '0x1 Transaction mined and execution succeed', + 'decoded input': { 'uint256 num': '57' } + }) + .clickFunction('retrieve - call') + .testFunction('last', + { + 'decoded output': { '0': 'uint256: 57' } + }) + // switch back to the previous state and check the value hasn't changed. + .switchWorkspace('forkedState_1') + .addAtAddressInstance(contractAddress, false, false, false) + .clickInstance(0) + .clickFunction('retrieve - call') + .testFunction('last', + { + 'decoded output': { '0': 'uint256: 55' } + }) }, 'Should show fork states provider in environment explorer & make txs using forked state #group1': function (browser: NightwatchBrowser) { browser