Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
c3a5ef3b
Commit
c3a5ef3b
authored
Mar 20, 2020
by
aniket-engg
Committed by
Aniket
Mar 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
blockhash, type defs in test file & module import
parent
5681ff8b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
134 additions
and
171 deletions
+134
-171
index.ts
remix-analyzer/src/solidity-analyzer/modules/index.ts
+22
-0
staticAnalysisCommon.ts
...zer/src/solidity-analyzer/modules/staticAnalysisCommon.ts
+3
-2
staticAnalysisIntegration-test-0.4.24.ts
...er/test/analysis/staticAnalysisIntegration-test-0.4.24.ts
+109
-169
No files found.
remix-analyzer/src/solidity-analyzer/modules/index.ts
0 → 100644
View file @
c3a5ef3b
export
{
default
as
txOrigin
}
from
'./txOrigin'
export
{
default
as
gasCosts
}
from
'./gasCosts'
export
{
default
as
thisLocal
}
from
'./thisLocal'
export
{
default
as
checksEffectsInteraction
}
from
'./checksEffectsInteraction'
export
{
default
as
constantFunctions
}
from
'./constantFunctions'
export
{
default
as
similarVariableNames
}
from
'./similarVariableNames'
export
{
default
as
inlineAssembly
}
from
'./inlineAssembly'
export
{
default
as
blockTimestamp
}
from
'./blockTimestamp'
export
{
default
as
lowLevelCalls
}
from
'./lowLevelCalls'
export
{
default
as
blockBlockhash
}
from
'./blockBlockhash'
export
{
default
as
noReturn
}
from
'./noReturn'
export
{
default
as
selfdestruct
}
from
'./selfdestruct'
export
{
default
as
guardConditions
}
from
'./guardConditions'
export
{
default
as
deleteDynamicArrays
}
from
'./deleteDynamicArrays'
export
{
default
as
assignAndCompare
}
from
'./assignAndCompare'
export
{
default
as
erc20Decimals
}
from
'./erc20Decimals'
export
{
default
as
stringBytesLength
}
from
'./stringBytesLength'
export
{
default
as
intDivisionTruncate
}
from
'./intDivisionTruncate'
export
{
default
as
etherTransferInLoop
}
from
'./etherTransferInLoop'
export
{
default
as
deleteFromDynamicArray
}
from
'./deleteFromDynamicArray'
export
{
default
as
forLoopIteratesOverDynamicArray
}
from
'./forLoopIteratesOverDynamicArray'
\ No newline at end of file
remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.ts
View file @
c3a5ef3b
...
@@ -132,7 +132,7 @@ const specialVariables: Record<string, SpecialObjDetail> = {
...
@@ -132,7 +132,7 @@ const specialVariables: Record<string, SpecialObjDetail> = {
BLOCKHASH
:
{
BLOCKHASH
:
{
obj
:
'block'
,
obj
:
'block'
,
member
:
'blockhash'
,
member
:
'blockhash'
,
type
:
buildFunctionSignature
([
basicTypes
.
UINT
],
[
basicTypes
.
BYTES32
],
false
)
type
:
buildFunctionSignature
([
basicTypes
.
UINT
],
[
basicTypes
.
BYTES32
],
false
,
'view'
)
}
}
}
}
...
@@ -808,7 +808,8 @@ function isBlockTimestampAccess (node: MemberAccessAstNode): boolean {
...
@@ -808,7 +808,8 @@ function isBlockTimestampAccess (node: MemberAccessAstNode): boolean {
* @return {bool}
* @return {bool}
*/
*/
function
isBlockBlockHashAccess
(
node
:
FunctionCallAstNode
):
boolean
{
function
isBlockBlockHashAccess
(
node
:
FunctionCallAstNode
):
boolean
{
return
isBuiltinFunctionCall
(
node
)
&&
getLocalCallName
(
node
)
===
'blockhash'
return
(
isBuiltinFunctionCall
(
node
)
&&
getLocalCallName
(
node
)
===
'blockhash'
)
||
isSpecialVariableAccess
(
node
.
expression
,
specialVariables
.
BLOCKHASH
)
}
}
/**
/**
...
...
remix-analyzer/test/analysis/staticAnalysisIntegration-test-0.4.24.ts
View file @
c3a5ef3b
...
@@ -5,11 +5,13 @@ import { join } from 'path'
...
@@ -5,11 +5,13 @@ import { join } from 'path'
import
{
default
as
StatRunner
}
from
'../../dist/src/solidity-analyzer'
import
{
default
as
StatRunner
}
from
'../../dist/src/solidity-analyzer'
import
{
install
,
require
as
requireNPMmodule
}
from
'npm-install-version'
import
{
install
,
require
as
requireNPMmodule
}
from
'npm-install-version'
install
(
'solc@0.4.24'
)
install
(
'solc@0.4.24'
)
const
compiler
=
requireNPMmodule
(
'solc@0.4.24'
)
const
solc
=
requireNPMmodule
(
'solc@0.4.24'
)
const
{
compilerInput
}
=
helpers
.
compiler
const
{
compilerInput
}
=
helpers
.
compiler
const
folder
=
'solidity-v0.4.24'
const
folder
:
string
=
'solidity-v0.4.24'
import
*
as
modules
from
'../../src/solidity-analyzer/modules/'
import
{
CompilationResult
,
AnalysisReportObj
,
AnalysisReport
,
AnalyzerModule
}
from
'../../src/types'
const
testFiles
=
[
const
testFiles
:
string
[]
=
[
'KingOfTheEtherThrone.sol'
,
'KingOfTheEtherThrone.sol'
,
'assembly.sol'
,
'assembly.sol'
,
'ballot.sol'
,
'ballot.sol'
,
...
@@ -37,20 +39,19 @@ const testFiles = [
...
@@ -37,20 +39,19 @@ const testFiles = [
'etherTransferInLoop.sol'
,
'etherTransferInLoop.sol'
,
'forLoopIteratesOverDynamicArray.sol'
'forLoopIteratesOverDynamicArray.sol'
]
]
// Latest AST was introduced in solidity v0.4.12
var
testFileAsts
=
{}
var
compilationResults
:
Record
<
string
,
CompilationResult
>
=
{}
testFiles
.
forEach
((
fileName
)
=>
{
testFiles
.
forEach
((
fileName
)
=>
{
const
content
=
readFileSync
(
join
(
__dirname
,
'test-contracts/'
+
folder
,
fileName
),
'utf8'
)
const
content
:
string
=
readFileSync
(
join
(
__dirname
,
'test-contracts/'
+
folder
,
fileName
),
'utf8'
)
testFileAsts
[
fileName
]
=
JSON
.
parse
(
compiler
.
compileStandardWrapper
(
compilerInput
(
content
)))
// 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
(
'Integration test thisLocal
.js'
,
function
(
t
)
{
test
(
'Integration test thisLocal
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
thisLocal
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/thisLocal'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
0
,
'KingOfTheEtherThrone.sol'
:
0
,
'assembly.sol'
:
0
,
'assembly.sol'
:
0
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -78,18 +79,15 @@ test('Integration test thisLocal.js', function (t) {
...
@@ -78,18 +79,15 @@ test('Integration test thisLocal.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of thisLocal warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of this local warnings`
)
})
})
})
})
test
(
'Integration test checksEffectsInteraction
.js'
,
function
(
t
)
{
test
(
'Integration test checksEffectsInteraction
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
checksEffectsInteraction
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/checksEffectsInteraction'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
1
,
'KingOfTheEtherThrone.sol'
:
1
,
'assembly.sol'
:
1
,
'assembly.sol'
:
1
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -117,18 +115,15 @@ test('Integration test checksEffectsInteraction.js', function (t) {
...
@@ -117,18 +115,15 @@ test('Integration test checksEffectsInteraction.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of checksEffectsInteraction warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of checks-effects-interaction warnings`
)
})
})
})
})
test
(
'Integration test constantFunctions
.js'
,
function
(
t
)
{
test
(
'Integration test constantFunctions
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
constantFunctions
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/constantFunctions'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
0
,
'KingOfTheEtherThrone.sol'
:
0
,
'assembly.sol'
:
0
,
'assembly.sol'
:
0
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -156,18 +151,15 @@ test('Integration test constantFunctions.js', function (t) {
...
@@ -156,18 +151,15 @@ test('Integration test constantFunctions.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of constantFunctions warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of constant warnings`
)
})
})
})
})
test
(
'Integration test inlineAssembly
.js'
,
function
(
t
)
{
test
(
'Integration test inlineAssembly
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
inlineAssembly
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/inlineAssembly'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
0
,
'KingOfTheEtherThrone.sol'
:
0
,
'assembly.sol'
:
2
,
'assembly.sol'
:
2
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -195,18 +187,15 @@ test('Integration test inlineAssembly.js', function (t) {
...
@@ -195,18 +187,15 @@ test('Integration test inlineAssembly.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of inlineAssembly warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of inline assembly warnings`
)
})
})
})
})
test
(
'Integration test txOrigin
.js'
,
function
(
t
)
{
test
(
'Integration test txOrigin
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
txOrigin
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/txOrigin'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
0
,
'KingOfTheEtherThrone.sol'
:
0
,
'assembly.sol'
:
1
,
'assembly.sol'
:
1
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -234,18 +223,15 @@ test('Integration test txOrigin.js', function (t) {
...
@@ -234,18 +223,15 @@ test('Integration test txOrigin.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of txOrigin warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of tx.origin warnings`
)
})
})
})
})
test
(
'Integration test gasCosts
.js'
,
function
(
t
)
{
test
(
'Integration test gasCosts
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
gasCosts
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/gasCosts'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
2
,
'KingOfTheEtherThrone.sol'
:
2
,
'assembly.sol'
:
2
,
'assembly.sol'
:
2
,
'ballot.sol'
:
3
,
'ballot.sol'
:
3
,
...
@@ -273,18 +259,15 @@ test('Integration test gasCosts.js', function (t) {
...
@@ -273,18 +259,15 @@ test('Integration test gasCosts.js', function (t) {
'etherTransferInLoop.sol'
:
3
,
'etherTransferInLoop.sol'
:
3
,
'forLoopIteratesOverDynamicArray.sol'
:
2
'forLoopIteratesOverDynamicArray.sol'
:
2
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of gasCosts warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of gasCost warnings`
)
})
})
})
})
test
(
'Integration test similarVariableNames
.js'
,
function
(
t
)
{
test
(
'Integration test similarVariableNames
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
similarVariableNames
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/similarVariableNames'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
0
,
'KingOfTheEtherThrone.sol'
:
0
,
'assembly.sol'
:
0
,
'assembly.sol'
:
0
,
'ballot.sol'
:
2
,
'ballot.sol'
:
2
,
...
@@ -312,18 +295,15 @@ test('Integration test similarVariableNames.js', function (t) {
...
@@ -312,18 +295,15 @@ test('Integration test similarVariableNames.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of similarVariableNames warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of similarVariableNames warnings`
)
})
})
})
})
test
(
'Integration test blockTimestamp
.js'
,
function
(
t
)
{
test
(
'Integration test blockTimestamp
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
blockTimestamp
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/blockTimestamp'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
1
,
'KingOfTheEtherThrone.sol'
:
1
,
'assembly.sol'
:
0
,
'assembly.sol'
:
0
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -351,18 +331,15 @@ test('Integration test blockTimestamp.js', function (t) {
...
@@ -351,18 +331,15 @@ test('Integration test blockTimestamp.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of blockTimestamp warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of blockTimestamp warnings`
)
})
})
})
})
test
(
'Integration test lowLevelCalls
.js'
,
function
(
t
)
{
test
(
'Integration test lowLevelCalls
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
lowLevelCalls
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/lowLevelCalls'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
1
,
'KingOfTheEtherThrone.sol'
:
1
,
'assembly.sol'
:
1
,
'assembly.sol'
:
1
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -390,18 +367,15 @@ test('Integration test lowLevelCalls.js', function (t) {
...
@@ -390,18 +367,15 @@ test('Integration test lowLevelCalls.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of lowLevelCalls warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of lowLevelCalls warnings`
)
})
})
})
})
test
(
'Integration test blockBlockhash
.js'
,
function
(
t
)
{
test
(
'Integration test blockBlockhash
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
blockBlockhash
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/blockBlockhash'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
0
,
'KingOfTheEtherThrone.sol'
:
0
,
'assembly.sol'
:
0
,
'assembly.sol'
:
0
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -414,7 +388,7 @@ test('Integration test blockBlockhash.js', function (t) {
...
@@ -414,7 +388,7 @@ test('Integration test blockBlockhash.js', function (t) {
'notReentrant.sol'
:
0
,
'notReentrant.sol'
:
0
,
'structReentrant.sol'
:
0
,
'structReentrant.sol'
:
0
,
'thisLocal.sol'
:
0
,
'thisLocal.sol'
:
0
,
'globals.sol'
:
0
,
// was 1 !! @TODO
'globals.sol'
:
1
,
'library.sol'
:
0
,
'library.sol'
:
0
,
'transfer.sol'
:
0
,
'transfer.sol'
:
0
,
'ctor.sol'
:
0
,
'ctor.sol'
:
0
,
...
@@ -429,18 +403,15 @@ test('Integration test blockBlockhash.js', function (t) {
...
@@ -429,18 +403,15 @@ test('Integration test blockBlockhash.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of blockBlockhash warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of blockBlockhash warnings`
)
})
})
})
})
test
(
'Integration test noReturn
.js'
,
function
(
t
)
{
test
(
'Integration test noReturn
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
noReturn
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/noReturn'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
0
,
'KingOfTheEtherThrone.sol'
:
0
,
'assembly.sol'
:
1
,
'assembly.sol'
:
1
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -468,18 +439,15 @@ test('Integration test noReturn.js', function (t) {
...
@@ -468,18 +439,15 @@ test('Integration test noReturn.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of noReturn warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of noReturn warnings`
)
})
})
})
})
test
(
'Integration test selfdestruct
.js'
,
function
(
t
)
{
test
(
'Integration test selfdestruct
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
selfdestruct
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/selfdestruct'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
0
,
'KingOfTheEtherThrone.sol'
:
0
,
'assembly.sol'
:
0
,
'assembly.sol'
:
0
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -507,18 +475,15 @@ test('Integration test selfdestruct.js', function (t) {
...
@@ -507,18 +475,15 @@ test('Integration test selfdestruct.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of selfdestruct warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of selfdestruct warnings`
)
})
})
})
})
test
(
'Integration test guardConditions
.js'
,
function
(
t
)
{
test
(
'Integration test guardConditions
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
guardConditions
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/guardConditions'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
0
,
'KingOfTheEtherThrone.sol'
:
0
,
'assembly.sol'
:
1
,
'assembly.sol'
:
1
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -546,18 +511,15 @@ test('Integration test guardConditions.js', function (t) {
...
@@ -546,18 +511,15 @@ test('Integration test guardConditions.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of guardConditions warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of guardCondition warnings`
)
})
})
})
})
test
(
'Integration test deleteDynamicArrays
.js'
,
function
(
t
)
{
test
(
'Integration test deleteDynamicArrays
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
deleteDynamicArrays
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/deleteDynamicArrays'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
0
,
'KingOfTheEtherThrone.sol'
:
0
,
'assembly.sol'
:
0
,
'assembly.sol'
:
0
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -585,18 +547,15 @@ test('Integration test deleteDynamicArrays.js', function (t) {
...
@@ -585,18 +547,15 @@ test('Integration test deleteDynamicArrays.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of deleteDynamicArrays warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of deleteDynamicArrays warnings`
)
})
})
})
})
test
(
'Integration test deleteFromDynamicArray
.js
'
,
function
(
t
)
{
test
(
'Integration test deleteFromDynamicArray
module
'
,
function
(
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
deleteFromDynamicArray
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/deleteFromDynamicArray'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
0
,
'KingOfTheEtherThrone.sol'
:
0
,
'assembly.sol'
:
0
,
'assembly.sol'
:
0
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -624,18 +583,15 @@ test('Integration test deleteFromDynamicArray.js', function (t) {
...
@@ -624,18 +583,15 @@ test('Integration test deleteFromDynamicArray.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of deleteFromDynamicArray warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of deleteFromDynamicArray warnings`
)
})
})
})
})
test
(
'Integration test assignAndCompare
.js'
,
function
(
t
)
{
test
(
'Integration test assignAndCompare
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
assignAndCompare
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/assignAndCompare'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
0
,
'KingOfTheEtherThrone.sol'
:
0
,
'assembly.sol'
:
0
,
'assembly.sol'
:
0
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -663,18 +619,15 @@ test('Integration test assignAndCompare.js', function (t) {
...
@@ -663,18 +619,15 @@ test('Integration test assignAndCompare.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of assignAndCompare warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of assignAndCompare warnings`
)
})
})
})
})
test
(
'Integration test intDivisionTruncate
.js'
,
function
(
t
)
{
test
(
'Integration test intDivisionTruncate
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
intDivisionTruncate
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/intDivisionTruncate'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
0
,
'KingOfTheEtherThrone.sol'
:
0
,
'assembly.sol'
:
0
,
'assembly.sol'
:
0
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -702,18 +655,15 @@ test('Integration test intDivisionTruncate.js', function (t) {
...
@@ -702,18 +655,15 @@ test('Integration test intDivisionTruncate.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of intDivisionTruncate warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of intDivisionTruncate warnings`
)
})
})
})
})
test
(
'Integration test erc20Decimal
.js'
,
function
(
t
)
{
test
(
'Integration test erc20Decimal
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
erc20Decimals
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/erc20Decimals'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
0
,
'KingOfTheEtherThrone.sol'
:
0
,
'assembly.sol'
:
0
,
'assembly.sol'
:
0
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -741,18 +691,15 @@ test('Integration test erc20Decimal.js', function (t) {
...
@@ -741,18 +691,15 @@ test('Integration test erc20Decimal.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of erc20Decimals warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of erc20Decimals warnings`
)
})
})
})
})
test
(
'Integration test stringBytesLength
.js'
,
function
(
t
)
{
test
(
'Integration test stringBytesLength
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
stringBytesLength
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/stringBytesLength'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
0
,
'KingOfTheEtherThrone.sol'
:
0
,
'assembly.sol'
:
0
,
'assembly.sol'
:
0
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -780,18 +727,15 @@ test('Integration test stringBytesLength.js', function (t) {
...
@@ -780,18 +727,15 @@ test('Integration test stringBytesLength.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of stringBytesLength warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of stringBytesLength warnings`
)
})
})
})
})
test
(
'Integration test etherTransferInLoop
.js'
,
function
(
t
)
{
test
(
'Integration test etherTransferInLoop
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
etherTransferInLoop
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/etherTransferInLoop'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
0
,
'KingOfTheEtherThrone.sol'
:
0
,
'assembly.sol'
:
0
,
'assembly.sol'
:
0
,
'ballot.sol'
:
0
,
'ballot.sol'
:
0
,
...
@@ -819,18 +763,15 @@ test('Integration test etherTransferInLoop.js', function (t) {
...
@@ -819,18 +763,15 @@ test('Integration test etherTransferInLoop.js', function (t) {
'etherTransferInLoop.sol'
:
3
,
'etherTransferInLoop.sol'
:
3
,
'forLoopIteratesOverDynamicArray.sol'
:
0
'forLoopIteratesOverDynamicArray.sol'
:
0
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of etherTransferInLoop warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of etherTransferInLoop warnings`
)
})
})
})
})
test
(
'Integration test forLoopIteratesOverDynamicArray
.js'
,
function
(
t
)
{
test
(
'Integration test forLoopIteratesOverDynamicArray
module'
,
function
(
t
:
test
.
Tes
t
)
{
t
.
plan
(
testFiles
.
length
)
t
.
plan
(
testFiles
.
length
)
const
module
:
any
=
modules
.
forLoopIteratesOverDynamicArray
const
module
=
require
(
'../../dist/src/solidity-analyzer/modules/forLoopIteratesOverDynamicArray'
).
default
const
lengthCheck
:
Record
<
string
,
number
>
=
{
const
lengthCheck
=
{
'KingOfTheEtherThrone.sol'
:
0
,
'KingOfTheEtherThrone.sol'
:
0
,
'assembly.sol'
:
0
,
'assembly.sol'
:
0
,
'ballot.sol'
:
2
,
'ballot.sol'
:
2
,
...
@@ -858,19 +799,18 @@ test('Integration test forLoopIteratesOverDynamicArray.js', function (t) {
...
@@ -858,19 +799,18 @@ test('Integration test forLoopIteratesOverDynamicArray.js', function (t) {
'etherTransferInLoop.sol'
:
0
,
'etherTransferInLoop.sol'
:
0
,
'forLoopIteratesOverDynamicArray.sol'
:
2
'forLoopIteratesOverDynamicArray.sol'
:
2
}
}
runModuleOnFiles
(
module
,
t
,
(
file
:
string
,
report
:
AnalysisReportObj
[])
=>
{
runModuleOnFiles
(
module
,
t
,
(
file
,
report
)
=>
{
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of forLoopIteratesOverDynamicArray warnings`
)
t
.
equal
(
report
.
length
,
lengthCheck
[
file
],
`
${
file
}
has right amount of forLoopIteratesOverDynamicArray warnings`
)
})
})
})
})
// #################### Helpers
// #################### Helpers
function
runModuleOnFiles
(
Module
,
t
,
cb
)
{
function
runModuleOnFiles
(
Module
:
any
,
t
:
test
.
Test
,
cb
:
((
fname
:
string
,
report
:
AnalysisReportObj
[])
=>
void
)):
void
{
const
statRunner
=
new
StatRunner
()
const
statRunner
:
StatRunner
=
new
StatRunner
()
testFiles
.
forEach
((
fileName
)
=>
{
testFiles
.
forEach
((
fileName
:
string
)
=>
{
statRunner
.
runWithModuleList
(
testFileAsts
[
fileName
],
[{
name
:
new
Module
().
name
,
mod
:
new
Module
()
}],
(
reports
)
=>
{
statRunner
.
runWithModuleList
(
compilationResults
[
fileName
],
[{
name
:
new
Module
().
name
,
mod
:
new
Module
()
}],
(
reports
:
AnalysisReport
[]
)
=>
{
let
report
=
reports
[
0
].
report
let
report
:
AnalysisReportObj
[]
=
reports
[
0
].
report
if
(
report
.
some
((
x
)
=>
x
[
'warning'
]
.
includes
(
'INTERNAL ERROR'
)))
{
if
(
report
.
some
((
x
:
AnalysisReportObj
)
=>
x
.
warning
.
includes
(
'INTERNAL ERROR'
)))
{
t
.
comment
(
'Error while executing Module: '
+
JSON
.
stringify
(
report
))
t
.
comment
(
'Error while executing Module: '
+
JSON
.
stringify
(
report
))
}
}
cb
(
fileName
,
report
)
cb
(
fileName
,
report
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment