Skip to content

Commit daccb28

Browse files
committed
feat: test no return statement case
1 parent 2d0109c commit daccb28

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

Diff for: test/contracts/NoReturn.sol

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pragma solidity ^0.8.13;
2+
3+
contract TestNoReturn {
4+
function test() internal pure returns (uint256) {
5+
uint256 result = 0;
6+
}
7+
}

Diff for: test/explicitReturnTypesSafeCheck.test.js

+19-6
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,31 @@ const linter = require("solhint");
22
const fs = require("fs");
33
const assert = require("assert");
44

5+
const settings = {
6+
plugins: ["euler-swap"],
7+
rules: {
8+
"euler-swap/explicit-return-types-safe-check": "warn",
9+
},
10+
};
511
describe("ExplicitReturnTypesSafeCheck", () => {
612
it("should test the unchecked blocks in example contract", () => {
713
const uncheckedContract = fs.readFileSync(
814
"test/contracts/UncheckedReturn.sol",
915
"utf8"
1016
);
11-
const result = linter.processStr(uncheckedContract, {
12-
plugins: ["euler-swap"],
13-
rules: {
14-
"euler-swap/explicit-return-types-safe-check": "warn",
15-
},
16-
});
17+
const result = linter.processStr(uncheckedContract, settings);
1718
assert.equal(result.reports.length, 0);
1819
});
20+
21+
it("should return an error if no return is detected", () => {
22+
const noReturnContract = fs.readFileSync(
23+
"test/contracts/NoReturn.sol",
24+
"utf8"
25+
);
26+
const result = linter.processStr(noReturnContract, settings);
27+
assert.equal(
28+
result.reports[0].message,
29+
`Return statements must be written and must explicitly return something; consider "return uint256;"?`
30+
);
31+
});
1932
});

0 commit comments

Comments
 (0)