Merge branch 'master' into remixd_terminal

pull/1342/head
David Zagi 3 years ago committed by GitHub
commit 617078b8fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .circleci/config.yml
  2. 54
      apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts
  3. 2
      apps/remix-ide/src/app/tabs/test-tab.js
  4. 18
      libs/remix-solidity/src/compiler/compiler-utils.ts
  5. 22
      libs/remix-tests/src/testRunner.ts
  6. 5
      libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx
  7. 18
      libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx

@ -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

@ -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 = [

@ -278,6 +278,8 @@ module.exports = class TestTab extends ViewPlugin {
</div>
`)
}
} else if (result.type === 'logOnly') {
if (result.hhLogs && result.hhLogs.length) this.printHHLogs(result.hhLogs, result.value)
}
}

@ -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
}
/**

@ -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()

@ -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 (
<div id='globalvariable' data-id='globalvariable'>
<DropdownPanel hexHighlight={false} bodyStyle={{ fontFamily: 'monospace' }} dropdownName='Global Variables' calldata={globals || {}} />

@ -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

Loading…
Cancel
Save