Add tests for the missing-inheritance detector

pull/858/head
Michael Colburn 4 years ago
parent 80808c2299
commit f894f7979e
  1. 9
      tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol
  2. 58
      tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol.0.4.25.MissingInheritance.json
  3. 9
      tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol
  4. 58
      tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol.0.5.16.MissingInheritance.json
  5. 9
      tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol
  6. 58
      tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol.0.6.11.MissingInheritance.json
  7. 9
      tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol
  8. 58
      tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol.0.7.6.MissingInheritance.json
  9. 20
      tests/test_detectors.py

@ -0,0 +1,9 @@
interface ISomething {
function f1() external returns(uint);
}
contract Something {
function f1() external returns(uint){
return 42;
}
}

@ -0,0 +1,58 @@
[
[
{
"elements": [
{
"type": "contract",
"name": "Something",
"source_mapping": {
"start": 68,
"length": 89,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol",
"is_dependency": false,
"lines": [
5,
6,
7,
8,
9,
10
],
"starting_column": 1,
"ending_column": 0
}
},
{
"type": "contract",
"name": "ISomething",
"source_mapping": {
"start": 0,
"length": 66,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol",
"is_dependency": false,
"lines": [
1,
2,
3
],
"starting_column": 1,
"ending_column": 2
}
}
],
"description": "Something (tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol#5-10) should inherit from ISomething (tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol#1-3)\n",
"markdown": "[Something](tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol#L5-L10) should inherit from [ISomething](tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol#L1-L3)\n",
"first_markdown_element": "tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol#L5-L10",
"id": "58962dc72a6c49524a027e8e1615ab92be30f1a0f5ef0eb4a029204687159649",
"check": "missing-inheritance",
"impact": "Informational",
"confidence": "High"
}
]
]

@ -0,0 +1,9 @@
interface ISomething {
function f1() external returns(uint);
}
contract Something {
function f1() external returns(uint){
return 42;
}
}

@ -0,0 +1,58 @@
[
[
{
"elements": [
{
"type": "contract",
"name": "Something",
"source_mapping": {
"start": 68,
"length": 89,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol",
"is_dependency": false,
"lines": [
5,
6,
7,
8,
9,
10
],
"starting_column": 1,
"ending_column": 0
}
},
{
"type": "contract",
"name": "ISomething",
"source_mapping": {
"start": 0,
"length": 66,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol",
"is_dependency": false,
"lines": [
1,
2,
3
],
"starting_column": 1,
"ending_column": 2
}
}
],
"description": "Something (tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol#5-10) should inherit from ISomething (tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol#1-3)\n",
"markdown": "[Something](tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol#L5-L10) should inherit from [ISomething](tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol#L1-L3)\n",
"first_markdown_element": "tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol#L5-L10",
"id": "58962dc72a6c49524a027e8e1615ab92be30f1a0f5ef0eb4a029204687159649",
"check": "missing-inheritance",
"impact": "Informational",
"confidence": "High"
}
]
]

@ -0,0 +1,9 @@
interface ISomething {
function f1() external returns(uint);
}
contract Something {
function f1() external returns(uint){
return 42;
}
}

@ -0,0 +1,58 @@
[
[
{
"elements": [
{
"type": "contract",
"name": "Something",
"source_mapping": {
"start": 68,
"length": 89,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol",
"is_dependency": false,
"lines": [
5,
6,
7,
8,
9,
10
],
"starting_column": 1,
"ending_column": 0
}
},
{
"type": "contract",
"name": "ISomething",
"source_mapping": {
"start": 0,
"length": 66,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol",
"is_dependency": false,
"lines": [
1,
2,
3
],
"starting_column": 1,
"ending_column": 2
}
}
],
"description": "Something (tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol#5-10) should inherit from ISomething (tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol#1-3)\n",
"markdown": "[Something](tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol#L5-L10) should inherit from [ISomething](tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol#L1-L3)\n",
"first_markdown_element": "tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol#L5-L10",
"id": "58962dc72a6c49524a027e8e1615ab92be30f1a0f5ef0eb4a029204687159649",
"check": "missing-inheritance",
"impact": "Informational",
"confidence": "High"
}
]
]

@ -0,0 +1,9 @@
interface ISomething {
function f1() external returns(uint);
}
contract Something {
function f1() external returns(uint){
return 42;
}
}

@ -0,0 +1,58 @@
[
[
{
"elements": [
{
"type": "contract",
"name": "Something",
"source_mapping": {
"start": 68,
"length": 89,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol",
"is_dependency": false,
"lines": [
5,
6,
7,
8,
9,
10
],
"starting_column": 1,
"ending_column": 0
}
},
{
"type": "contract",
"name": "ISomething",
"source_mapping": {
"start": 0,
"length": 66,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol",
"is_dependency": false,
"lines": [
1,
2,
3
],
"starting_column": 1,
"ending_column": 2
}
}
],
"description": "Something (tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol#5-10) should inherit from ISomething (tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol#1-3)\n",
"markdown": "[Something](tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol#L5-L10) should inherit from [ISomething](tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol#L1-L3)\n",
"first_markdown_element": "tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol#L5-L10",
"id": "58962dc72a6c49524a027e8e1615ab92be30f1a0f5ef0eb4a029204687159649",
"check": "missing-inheritance",
"impact": "Informational",
"confidence": "High"
}
]
]

@ -1164,6 +1164,26 @@ ALL_TESTS = [
"shift_parameter_mixup.sol", "shift_parameter_mixup.sol",
"0.7.6", "0.7.6",
), ),
Test(
all_detectors.MissingInheritance,
"unimplemented_interface.sol",
"0.4.25",
),
Test(
all_detectors.MissingInheritance,
"unimplemented_interface.sol",
"0.5.16",
),
Test(
all_detectors.MissingInheritance,
"unimplemented_interface.sol",
"0.6.11",
),
Test(
all_detectors.MissingInheritance,
"unimplemented_interface.sol",
"0.7.6",
),
] ]
GENERIC_PATH = "/GENERIC_PATH" GENERIC_PATH = "/GENERIC_PATH"

Loading…
Cancel
Save