From 6b16047f6620325f7c789172341e2a7e58baf7c0 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 19 Jan 2022 17:33:51 +0100 Subject: [PATCH 1/2] reset input parameters --- libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx index 4bd6c7df96..0533030946 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx @@ -25,6 +25,7 @@ export function ContractGUI (props: ContractGUIProps) { } else { setTitle(props.funcABI.type === 'receive' ? '(receive)' : '(fallback)') } + setBasicInput('') }, [props.title, props.funcABI]) useEffect(() => { From 6898e8aa4b97d4c7ee3fea3821f4fd2efb3b053e Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 20 Jan 2022 10:55:47 +0100 Subject: [PATCH 2/2] add e2e test --- .../src/tests/transactionExecution.test.ts | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts b/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts index 1be9168abb..feb70d7d62 100644 --- a/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts +++ b/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts @@ -195,6 +195,26 @@ module.exports = { .journalLastChildIncludes('"documentation": "param2 from library"') .journalLastChildIncludes('"documentation": "param3 from library"') .journalLastChildIncludes('Debug the transaction to get more information.') + }, + + 'Should compile and deploy 2 simple contracts, the contract creation component state should be correctly reset for the deployment of the second contract #group4': function (browser: NightwatchBrowser) { + browser + .addFile('Storage.sol', sources[6]['Storage.sol']) + .addFile('Owner.sol', sources[6]['Owner.sol']) + .clickLaunchIcon('udapp') + .createContract('42') + .openFile('Storage.sol') + .clickLaunchIcon('udapp') + .createContract('') // this creation will fail if the component hasn't been properly reset. + .clickInstance(1) + .clickFunction('store - transact (not payable)', { types: 'uint256 num', values: '24' }) + .testFunction('last', // we check if the contract is actually reachable. + { + status: 'true Transaction mined and execution succeed', + 'decoded input': { + 'uint256 num': '24' + } + }) .end() } } @@ -322,5 +342,92 @@ contract C { } }` } + }, + { + 'Owner.sol': { + content: ` + // SPDX-License-Identifier: GPL-3.0 + + pragma solidity >=0.7.0 <0.9.0; + + /** + * @title Owner + * @dev Set & change owner + */ + contract Owner { + + address private owner; + + // event for EVM logging + event OwnerSet(address indexed oldOwner, address indexed newOwner); + + // modifier to check if caller is owner + modifier isOwner() { + // If the first argument of 'require' evaluates to 'false', execution terminates and all + // changes to the state and to Ether balances are reverted. + // This used to consume all gas in old EVM versions, but not anymore. + // It is often a good idea to use 'require' to check if functions are called correctly. + // As a second argument, you can also provide an explanation about what went wrong. + require(msg.sender == owner, "Caller is not owner"); + _; + } + + /** + * @dev Set contract deployer as owner + */ + constructor(uint p) { + owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor + emit OwnerSet(address(0), owner); + } + + /** + * @dev Change owner + * @param newOwner address of new owner + */ + function changeOwner(address newOwner) public isOwner { + emit OwnerSet(owner, newOwner); + owner = newOwner; + } + + /** + * @dev Return owner address + * @return address of owner + */ + function getOwner() external view returns (address) { + return owner; + } + }` + }, + 'Storage.sol': { + content: ` + // SPDX-License-Identifier: GPL-3.0 + + pragma solidity >=0.7.0 <0.9.0; + + /** + * @title Storage + * @dev Store & retrieve value in a variable + */ + contract Storage { + + uint256 number; + + /** + * @dev Store value in variable + * @param num value to store + */ + function store(uint256 num) public { + number = num; + } + + /** + * @dev Return value + * @return value of 'number' + */ + function retrieve() public view returns (uint256){ + return number; + } + }` + } } ]