test working for remix-analyzer

pull/5/head
aniket-engg 4 years ago
commit 1e3ef5dd82
  1. 27
      libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.4.24.ts
  2. 27
      libs/remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.5.0.ts
  3. 17
      libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.4.24.ts
  4. 15
      libs/remix-analyzer/test/analysis/staticAnalysisIssues-test-0.5.0.ts
  5. 6
      libs/remix-analyzer/tsconfig.json
  6. 3
      workspace.json

@ -1,17 +1,14 @@
import { default as test } from "tape"
import test from "tape"
import { helpers } from '@remix-project/remix-lib'
import { readFileSync } from 'fs'
import { join } from 'path'
import { default as StatRunner } from '../../src/solidity-analyzer'
import * as modules from '../../src/solidity-analyzer/modules/'
import { CompilationResult, AnalysisReportObj, AnalysisReport } from '../../src/types'
import { install, require as requireNPMmodule } from 'npm-install-version'
install('solc@0.4.24')
const solc = requireNPMmodule('solc@0.4.24')
import solcOrg from 'solc';
const { compilerInput } = helpers.compiler
const folder: string = 'solidity-v0.4.24'
const testFiles: string[] = [
'KingOfTheEtherThrone.sol',
'assembly.sol',
@ -41,13 +38,21 @@ const testFiles: string[] = [
'forLoopIteratesOverDynamicArray.sol'
]
var compilationResults: Record<string, CompilationResult> = {}
let compilationResults: Record<string, CompilationResult> = {}
testFiles.forEach((fileName) => {
const content: string = readFileSync(join(__dirname, 'test-contracts/' + folder, fileName), 'utf8')
// Latest AST is available under 'compileStandardWrapper' under solc for, 0.4.12 <= version < 0.5.0
compilationResults[fileName] = JSON.parse(solc.compileStandardWrapper(compilerInput(content)))
})
test('setup', function (t: test.Test) {
solcOrg.loadRemoteVersion('v0.4.24+commit.e67f0147', (error, compiler) => {
if (error) throw error
testFiles.forEach((fileName) => {
const content: string = readFileSync(join(__dirname, 'test-contracts/' + folder, fileName), 'utf8')
// Latest AST is available under 'compileStandardWrapper' under solc for, 0.4.12 <= version < 0.5.0
compilationResults[fileName] = JSON.parse(compiler.compile(compilerInput(content)))
})
t.end()
})
});
test('Integration test thisLocal module', function (t: test.Test) {
t.plan(testFiles.length)

@ -1,13 +1,11 @@
import { default as test } from "tape"
import test from "tape"
import { helpers } from '@remix-project/remix-lib'
import { readFileSync } from 'fs'
import { join } from 'path'
import { default as StatRunner } from '../../src/solidity-analyzer'
import * as modules from '../../src/solidity-analyzer/modules/'
import solc from 'solc';
import { CompilationResult, AnalysisReportObj, AnalysisReport } from '../../src/types'
import { install, require as requireNPMmodule } from 'npm-install-version'
install('solc@0.5.0')
const solc = requireNPMmodule('solc@0.5.0')
const { compilerInput } = helpers.compiler
const folder: string = 'solidity-v0.5'
@ -40,12 +38,23 @@ const testFiles: string[] = [
'forLoopIteratesOverDynamicArray.sol'
]
var compilationResults: Record<string, CompilationResult> = {}
let compilationResults: Record<string, CompilationResult> = {}
test('setup', function (t) {
solc.loadRemoteVersion('v0.5.0+commit.1d4f565a', (error, compiler) => {
if (error) throw error
testFiles.forEach((fileName) => {
const content = readFileSync(join(__dirname, 'test-contracts/' + folder, fileName), 'utf8')
compilationResults[fileName] = JSON.parse(compiler.compile(compilerInput(content)))
})
t.end()
})
});
testFiles.forEach((fileName) => {
const content = readFileSync(join(__dirname, 'test-contracts/' + folder, fileName), 'utf8')
compilationResults[fileName] = JSON.parse(solc.compile(compilerInput(content)))
})
test('Integration test thisLocal module', function (t: test.Test) {
t.plan(testFiles.length)

@ -1,19 +1,26 @@
import * as test from "tape"
import test from "tape"
import { helpers } from '@remix-project/remix-lib'
import { readFileSync } from 'fs'
import { join } from 'path'
import { default as StatRunner } from '../../src/solidity-analyzer'
import solc from 'solc';
import { CompilationResult, AnalysisReportObj, AnalysisReport, AnalyzerModule } from '../../src/types'
import { checksEffectsInteraction } from '../../src/solidity-analyzer/modules/'
import { install, require as requireNPMmodule } from 'npm-install-version'
install('solc@0.4.24')
const compiler = requireNPMmodule('solc@0.4.24')
const { compilerInput } = helpers.compiler
const folder: string = 'solidity-v0.4.24'
let compiler
test('setup', function (t) {
solc.loadRemoteVersion('v0.4.24+commit.e67f0147', (error, solcVersion) => {
if (error) throw error
compiler = solcVersion
t.end()
})
});
function compile (fileName: string): CompilationResult {
const content: string = readFileSync(join(__dirname, 'test-contracts/' + folder, fileName), 'utf8')
return JSON.parse(compiler.compileStandardWrapper(compilerInput(content)))
return JSON.parse(compiler.compile(compilerInput(content)))
}
test('staticAnalysisIssues.functionParameterPassingError', function (t) {

@ -1,16 +1,23 @@
import * as test from "tape"
import test from "tape"
import { helpers } from '@remix-project/remix-lib'
import { readFileSync } from 'fs'
import { join } from 'path'
import { default as StatRunner } from '../../src/solidity-analyzer'
import solc from 'solc';
import { CompilationResult, AnalysisReportObj, AnalysisReport } from '../../src/types'
import { checksEffectsInteraction } from '../../src/solidity-analyzer/modules/'
import { install, require as requireNPMmodule } from 'npm-install-version'
install('solc@0.5.0')
const compiler = requireNPMmodule('solc@0.5.0')
const {compilerInput } = helpers.compiler
const folder: string = 'solidity-v0.5'
let compiler
test('setup', function (t) {
solc.loadRemoteVersion('v0.5.0+commit.1d4f565a', (error, solcVersion) => {
if (error) throw error
compiler = solcVersion
t.end()
})
});
function compile (fileName): CompilationResult {
const content: string = readFileSync(join(__dirname, 'test-contracts/' + folder, fileName), 'utf8')
return JSON.parse(compiler.compile(compilerInput(content)))

@ -1,8 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": ["node"],
"esModuleInterop": true
"types": ["node"],
"module": "commonjs",
"esModuleInterop": true,
"outDir": "./dist",
},
"include": ["**/*.ts"]
}

@ -88,9 +88,6 @@
"builder": "@nrwl/workspace:run-commands",
"options": {
"commands": [
{
"command": "rm -rf ../../dist"
},
{
"command": "./../../node_modules/.bin/npm-run-all test"
}

Loading…
Cancel
Save