Skip to content

Commit

Permalink
implement basic end to end testing
Browse files Browse the repository at this point in the history
Add a Python script to run securify on multiple input and see whether their
outputs match the ones previously saved, so that changes can be acknowledged
and bugs introduced can be fixed.
  • Loading branch information
Quentin Hibon committed Dec 5, 2018
1 parent d7ecc64 commit b54522e
Show file tree
Hide file tree
Showing 31 changed files with 4,243 additions and 1 deletion.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,27 @@ Alternatively, add the `--pretty` flag in order to get clang style output rather
than JSON based output.


### Travis
### Tests

Basic end to end tests can be run through the [test.py](test.py) file:
```py
python3 test.py
```

The requirements can be installed using Pipenv:
```sh
pipenv install
```

or using `pip`:
```sh
pip install -r requirements.txt
```

These tests compare the current json output given by Securify with some past
output, and report differences between the two.

### Travis Integration

You can add the following `.travis.yml` to your project to run Securify on new
commits:
Expand Down
79 changes: 79 additions & 0 deletions src/test/resources/solidity/DAOConstantGas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"src/test/resources/solidity/DAOConstantGas.sol:Wallet": {
"results": {
"DAO": {
"violations": [],
"warnings": [],
"safe": [],
"conflicts": []
},
"DAOConstantGas": {
"violations": [
5
],
"warnings": [],
"safe": [],
"conflicts": []
},
"LockedEther": {
"violations": [],
"warnings": [
0
],
"safe": [],
"conflicts": []
},
"MissingInputValidation": {
"violations": [],
"warnings": [
3
],
"safe": [],
"conflicts": []
},
"TODAmount": {
"violations": [
5
],
"warnings": [],
"safe": [],
"conflicts": []
},
"TODReceiver": {
"violations": [],
"warnings": [
5
],
"safe": [],
"conflicts": []
},
"UnhandledException": {
"violations": [],
"warnings": [
5
],
"safe": [],
"conflicts": []
},
"UnrestrictedEtherFlow": {
"violations": [],
"warnings": [],
"safe": [
5
],
"conflicts": []
},
"UnrestrictedWrite": {
"violations": [
6
],
"warnings": [],
"safe": [],
"conflicts": []
}
},
"securifyErrors": {
"errors": []
}
}
}
68 changes: 68 additions & 0 deletions src/test/resources/solidity/LockedEther.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"src/test/resources/solidity/LockedEther.sol:MarketPlace": {
"results": {
"DAO": {
"violations": [],
"warnings": [],
"safe": [],
"conflicts": []
},
"DAOConstantGas": {
"violations": [],
"warnings": [],
"safe": [],
"conflicts": []
},
"LockedEther": {
"violations": [
0
],
"warnings": [],
"safe": [],
"conflicts": []
},
"MissingInputValidation": {
"violations": [],
"warnings": [
1,
4
],
"safe": [],
"conflicts": []
},
"TODAmount": {
"violations": [],
"warnings": [],
"safe": [],
"conflicts": []
},
"TODReceiver": {
"violations": [],
"warnings": [],
"safe": [],
"conflicts": []
},
"UnhandledException": {
"violations": [],
"warnings": [],
"safe": [],
"conflicts": []
},
"UnrestrictedEtherFlow": {
"violations": [],
"warnings": [],
"safe": [],
"conflicts": []
},
"UnrestrictedWrite": {
"violations": [],
"warnings": [],
"safe": [],
"conflicts": []
}
},
"securifyErrors": {
"errors": []
}
}
}
79 changes: 79 additions & 0 deletions src/test/resources/solidity/MissingInputValidation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"src/test/resources/solidity/MissingInputValidation.sol:SimpleBank": {
"results": {
"DAO": {
"violations": [],
"warnings": [],
"safe": [],
"conflicts": []
},
"DAOConstantGas": {
"violations": [],
"warnings": [
5
],
"safe": [],
"conflicts": []
},
"LockedEther": {
"violations": [],
"warnings": [
0
],
"safe": [],
"conflicts": []
},
"MissingInputValidation": {
"violations": [
3
],
"warnings": [],
"safe": [],
"conflicts": []
},
"TODAmount": {
"violations": [],
"warnings": [
5
],
"safe": [],
"conflicts": []
},
"TODReceiver": {
"violations": [],
"warnings": [
5
],
"safe": [],
"conflicts": []
},
"UnhandledException": {
"violations": [],
"warnings": [
5
],
"safe": [],
"conflicts": []
},
"UnrestrictedEtherFlow": {
"violations": [
5
],
"warnings": [],
"safe": [],
"conflicts": []
},
"UnrestrictedWrite": {
"violations": [],
"warnings": [
4
],
"safe": [],
"conflicts": []
}
},
"securifyErrors": {
"errors": []
}
}
}
82 changes: 82 additions & 0 deletions src/test/resources/solidity/TODAmount.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"src/test/resources/solidity/TODAmount.sol:TokenMarket": {
"results": {
"DAO": {
"violations": [],
"warnings": [],
"safe": [],
"conflicts": []
},
"DAOConstantGas": {
"violations": [],
"warnings": [
13
],
"safe": [],
"conflicts": []
},
"LockedEther": {
"violations": [],
"warnings": [
0
],
"safe": [],
"conflicts": []
},
"MissingInputValidation": {
"violations": [
5
],
"warnings": [
10
],
"safe": [],
"conflicts": []
},
"TODAmount": {
"violations": [
13
],
"warnings": [],
"safe": [],
"conflicts": []
},
"TODReceiver": {
"violations": [],
"warnings": [
13
],
"safe": [],
"conflicts": []
},
"UnhandledException": {
"violations": [],
"warnings": [
13
],
"safe": [],
"conflicts": []
},
"UnrestrictedEtherFlow": {
"violations": [],
"warnings": [],
"safe": [
13
],
"conflicts": []
},
"UnrestrictedWrite": {
"violations": [],
"warnings": [
7,
12
],
"safe": [],
"conflicts": []
}
},
"securifyErrors": {
"errors": []
}
}
}
Loading

0 comments on commit b54522e

Please sign in to comment.