pull/4255/head
yann300 12 months ago
parent 7e18d33da9
commit 3b91dfd2ce
  1. 43
      apps/remix-ide-e2e/src/tests/terminal.test.ts
  2. 4
      libs/remix-ui/editor/src/lib/remix-ui-editor.tsx

@ -342,7 +342,7 @@ module.exports = {
.addFile('test.sol', { content: script })
.scrollToLine(3)
const path = "//*[@class='view-line' and contains(.,'runSomething') and contains(.,'view')]//span//span[contains(.,'(')]"
const pathRunFunction = `//li//*[@aria-label='Run the free function "runSomething" in the Remix VM']`
const pathRunFunction = `//li//*[@aria-label='Run the free function "runSomething".']`
browser.waitForElementVisible('#editorView')
.useXpath()
.click(path)
@ -358,6 +358,47 @@ module.exports = {
.waitForElementContainsText('*[data-id="terminalJournal"]', 'test running free function', 120000)
.waitForElementNotContainsText('*[data-id="terminalJournal"]', `test running free function
test running free function`, 2000)
},
'Should run a free function while being connected to mainnet #group10': function (browser: NightwatchBrowser) {
const script = `
import "https://github.com/ensdomains/ens-contracts/blob/master/contracts/utils/NameEncoder.sol";
import "hardhat/console.sol";
abstract contract ENS {
function resolver(bytes32 node) public virtual view returns (Resolver);
}
abstract contract Resolver {
function addr(bytes32 node) public virtual view returns (address);
}
function resolve() public view returns(address) {
// Same address for Mainet, Ropsten, Rinkerby, Gorli and other networks;
ENS ens = ENS(0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e);
(,bytes32 node) = NameEncoder.dnsEncodeName("vitalik.eth");
Resolver resolver = ens.resolver(node);
console.log(resolver.addr(node));
}
`
browser
.addFile('test_mainnet.sol', { content: script })
.scrollToLine(15)
const path = "//*[@class='view-line' and contains(.,'resolve') and contains(.,'view')]//span//span[contains(.,'(')]"
const pathRunFunction = `//li//*[@aria-label='Run the free function "resolve".']`
browser.waitForElementVisible('#editorView')
.useXpath()
.click(path)
.pause(3000) // the parser need to parse the code
.perform(function () {
const actions = this.actions({ async: true });
return actions
.keyDown(this.Keys.SHIFT)
.keyDown(this.Keys.ALT)
.sendKeys('r')
})
.useCss()
.waitForElementContainsText('*[data-id="terminalJournal"]', '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', 120000)
}
}

@ -734,7 +734,7 @@ export const EditorUI = (props: EditorUIProps) => {
let freeFunctionAction
const executeFreeFunctionAction = {
id: 'executeFreeFunction',
label: 'Run a free function in the Remix VM',
label: 'Run a free function',
contextMenuOrder: 0, // choose the order
contextMenuGroupId: 'execute', // create a new grouping
precondition: 'freeFunctionCondition',
@ -792,7 +792,7 @@ export const EditorUI = (props: EditorUIProps) => {
const { nodesAtPosition } = await retrieveNodesAtPosition(props.editorAPI, props.plugin)
const freeFunctionNode = nodesAtPosition.find((node) => node.kind === 'freeFunction')
if (freeFunctionNode) {
executeFreeFunctionAction.label = `Run the free function "${freeFunctionNode.name}" in the Remix VM`
executeFreeFunctionAction.label = `Run the free function "${freeFunctionNode.name}"`
freeFunctionAction = editor.addAction(executeFreeFunctionAction)
}
const functionImpl = nodesAtPosition.find((node) => node.kind === 'function')

Loading…
Cancel
Save