diff --git a/.circleci/config.yml b/.circleci/config.yml index a7cae9785e..9d0791cd7e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -105,6 +105,7 @@ jobs: steps: - checkout - run: npm install + - run: npm run downloadsolc_assets - run: npx nx build remix-ide --with-deps - run: name: Download Selenium @@ -171,6 +172,7 @@ jobs: steps: - checkout - run: npm install + - run: npm run downloadsolc_assets - run: npx nx build remix-ide --with-deps - run: name: Download Selenium diff --git a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts index 2c3a43ebc4..a46781eaea 100644 --- a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts +++ b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts @@ -166,27 +166,41 @@ module.exports = { .verify.attributeEquals('*[data-id="uiPathInput"]', 'value', 'tests') }, - 'Solidity Unittests': function (browser: NightwatchBrowser) { - runTests(browser) - } -} + 'Solidity Unit tests Basic': function (browser: NightwatchBrowser) { + browser + .waitForElementPresent('*[data-id="verticalIconsKindfilePanel"]') + .clickLaunchIcon('filePanel') + .click('*[data-id="treeViewLitreeViewItemcontracts"]') + .openFile('contracts/3_Ballot.sol') + .clickLaunchIcon('solidityUnitTesting') + .pause(2000) + .verify.attributeEquals('*[data-id="uiPathInput"]', 'value', 'tests') + .scrollAndClick('#runTestsTabRunAction') + .waitForElementVisible('*[data-id="testTabSolidityUnitTestsOutputheader"]', 120000) + .waitForElementPresent('#solidityUnittestsOutput div[class^="testPass"]', 60000) + .waitForElementContainsText('#solidityUnittestsOutput', '/tests/4_Ballot_test.sol', 60000) + .waitForElementContainsText('#solidityUnittestsOutput', '✓ Check winning proposal', 60000) + .waitForElementContainsText('#solidityUnittestsOutput', '✓ Check winnin proposal with return value', 60000) + }, -function runTests (browser: NightwatchBrowser) { - browser - .waitForElementPresent('*[data-id="verticalIconsKindfilePanel"]') - .clickLaunchIcon('filePanel') - .click('*[data-id="treeViewLitreeViewItemcontracts"]') - .openFile('contracts/3_Ballot.sol') - .clickLaunchIcon('solidityUnitTesting') - .pause(2000) - .verify.attributeEquals('*[data-id="uiPathInput"]', 'value', 'tests') - .scrollAndClick('#runTestsTabRunAction') - .waitForElementVisible('*[data-id="testTabSolidityUnitTestsOutputheader"]', 120000) - .waitForElementPresent('#solidityUnittestsOutput div[class^="testPass"]', 60000) - .waitForElementContainsText('#solidityUnittestsOutput', '/tests/4_Ballot_test.sol', 60000) - .waitForElementContainsText('#solidityUnittestsOutput', '✓ Check winning proposal', 60000) - .waitForElementContainsText('#solidityUnittestsOutput', '✓ Check winnin proposal with return value', 60000) - .end() + 'Solidity Unit tests Basic Basic with local compiler': function (browser: NightwatchBrowser) { + browser + .clickLaunchIcon('solidity') + .setSolidityCompilerVersion('builtin') + .openFile('contracts/3_Ballot.sol') + .clickLaunchIcon('pluginManager') + .scrollAndClick('[data-id="pluginManagerComponentDeactivateButtonsolidityUnitTesting"]') + .pause(2000) + .scrollAndClick('[data-id="pluginManagerComponentActivateButtonsolidityUnitTesting"]') + .clickLaunchIcon('solidityUnitTesting') + .scrollAndClick('#runTestsTabRunAction') + .waitForElementVisible('*[data-id="testTabSolidityUnitTestsOutputheader"]', 120000) + .waitForElementPresent('#solidityUnittestsOutput div[class^="testPass"]', 60000) + .waitForElementContainsText('#solidityUnittestsOutput', '/tests/4_Ballot_test.sol', 60000) + .waitForElementContainsText('#solidityUnittestsOutput', '✓ Check winning proposal', 60000) + .waitForElementContainsText('#solidityUnittestsOutput', '✓ Check winnin proposal with return value', 60000) + .end() + } } const sources = [ diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 6750efde55..030745e5d1 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -278,6 +278,8 @@ module.exports = class TestTab extends ViewPlugin { `) } + } else if (result.type === 'logOnly') { + if (result.hhLogs && result.hhLogs.length) this.printHHLogs(result.hhLogs, result.value) } } diff --git a/libs/remix-solidity/src/compiler/compiler-utils.ts b/libs/remix-solidity/src/compiler/compiler-utils.ts index da3bc487b3..7e19ae7d8a 100644 --- a/libs/remix-solidity/src/compiler/compiler-utils.ts +++ b/libs/remix-solidity/src/compiler/compiler-utils.ts @@ -12,9 +12,21 @@ export const pathToURL = {} * @param version is the version of compiler with or without 'soljson-v' prefix and .js postfix */ export function urlFromVersion (version) { - if (!version.startsWith('soljson-v')) version = 'soljson-v' + version - if (!version.endsWith('.js')) version = version + '.js' - return `${pathToURL[version]}/${version}` + let url + if (version === 'builtin') { + let location: string | Location = window.document.location + let path = location.pathname + if (!path.startsWith('/')) path = '/' + path + location = `${location.protocol}//${location.host}${path}assets/js` + if (location.endsWith('index.html')) location = location.substring(0, location.length - 10) + if (!location.endsWith('/')) location += '/' + url = `${location}soljson.js` + } else { + if (!version.startsWith('soljson-v')) version = 'soljson-v' + version + if (!version.endsWith('.js')) version = version + '.js' + url = `${pathToURL[version]}/${version}` + } + return url } /** diff --git a/libs/remix-tests/src/testRunner.ts b/libs/remix-tests/src/testRunner.ts index 47b44d708b..ffc2cecde4 100644 --- a/libs/remix-tests/src/testRunner.ts +++ b/libs/remix-tests/src/testRunner.ts @@ -244,8 +244,15 @@ export function runTest (testName: string, testObject: any, contractDetails: Com const method = testObject.methods[func.name].apply(testObject.methods[func.name], []) const startTime = Date.now() if (func.constant) { - method.call(sendParams).then((result) => { + sendParams = {} + const tagTimestamp = 'remix_tests_tag' + Date.now() + sendParams.timestamp = tagTimestamp + method.call(sendParams).then(async (result) => { const time = (Date.now() - startTime) / 1000.0 + let tagTxHash + let hhLogs + if (web3.eth && web3.eth.getHashFromTagBySimulator) tagTxHash = await web3.eth.getHashFromTagBySimulator(tagTimestamp) + if (web3.eth && web3.eth.getHHLogsForTx) hhLogs = await web3.eth.getHHLogsForTx(tagTxHash) if (result) { const resp: TestResultInterface = { type: 'testPass', @@ -254,6 +261,7 @@ export function runTest (testName: string, testObject: any, contractDetails: Com time: time, context: testName } + if (hhLogs) resp.hhLogs = hhLogs testCallback(undefined, resp) passingNum += 1 timePassed += time @@ -266,6 +274,7 @@ export function runTest (testName: string, testObject: any, contractDetails: Com errMsg: 'function returned false', context: testName } + if (hhLogs) resp.hhLogs = hhLogs testCallback(undefined, resp) failureNum += 1 timePassed += time @@ -338,6 +347,17 @@ export function runTest (testName: string, testObject: any, contractDetails: Com testCallback(undefined, resp) passingNum += 1 timePassed += time + } else if (hhLogs) { + const resp: TestResultInterface = { + type: 'logOnly', + value: changeCase.sentenceCase(func.name), + filename: testObject.filename, + time: time, + context: testName, + hhLogs + } + testCallback(undefined, resp) + timePassed += time } return next() diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx index db26cf980b..98713182cd 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx @@ -5,7 +5,6 @@ import { BN } from 'ethereumjs-util' export const GlobalVariables = ({ block, receipt, tx }) => { // see https://docs.soliditylang.org/en/latest/units-and-global-variables.html#block-and-transaction-properties const globals = { - 'block.basefee': (new BN(block.baseFeePerGas.replace('0x', ''), 'hex')).toString(10) + ` Wei (${block.baseFeePerGas})`, 'block.chainid': tx.chainId, 'block.coinbase': block.miner, 'block.difficulty': block.difficulty, @@ -17,6 +16,10 @@ export const GlobalVariables = ({ block, receipt, tx }) => { 'msg.value': tx.value + ' Wei', 'tx.origin': tx.from } + if (block.baseFeePerGas) { + globals['block.basefee'] = (new BN(block.baseFeePerGas.replace('0x', ''), 'hex')).toString(10) + ` Wei (${block.baseFeePerGas})` + } + return (
diff --git a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx index 9469121adf..80b1004ab6 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -333,19 +333,15 @@ export const CompilerContainer = (props: CompilerContainerProps) => { updateCurrentVersion(selectedVersion) url = customUrl api.setParameters({ version: selectedVersion }) - } else if (selectedVersion === 'builtin') { - let location: string | Location = window.document.location - let path = location.pathname - if (!path.startsWith('/')) path = '/' + path - location = `${location.protocol}//${location.host}${path}assets/js` - if (location.endsWith('index.html')) location = location.substring(0, location.length - 10) - if (!location.endsWith('/')) location += '/' - url = location + 'soljson.js' } else { - if (selectedVersion.indexOf('soljson') !== 0 || helper.checkSpecialChars(selectedVersion)) { - return console.log('loading ' + selectedVersion + ' not allowed') + if (helper.checkSpecialChars(selectedVersion)) { + return console.log('loading ' + selectedVersion + ' not allowed, special chars not allowed.') + } + if (selectedVersion === 'builtin' || selectedVersion.indexOf('soljson') === 0) { + url = urlFromVersion(selectedVersion) + } else { + return console.log('loading ' + selectedVersion + ' not allowed, version should start with "soljson"') } - url = `${urlFromVersion(selectedVersion)}` } // Workers cannot load js on "file:"-URLs and we get a