sablier-labs / flow

🍃 Smart contracts of the Sablier Flow protocol.
Other
8 stars 0 forks source link

Concrete tests for `SablierFlowBase` getters #299

Open smol-ninja opened 6 days ago

smol-ninja commented 6 days ago

Some of the getters in SablierFlowBase simply read and return storage values and so do not have their own concrete tests. As a consequence of which, we missed adding notNull to isTransferable function. This was discovered during Cantina audit.

To avoid similar errors in the future, we should concrete tests for those getters too.

andreivladbrg commented 5 days ago

since these tests would be the same for all getters we should generalize the test that can be applied to all of them

we already have expectRevert_Null which can be used we could also declare a function test_Getter(bytes memory callData, bytes memory expectedData);

test example for snapshot time

```solidity function test_RevertGiven_Null() external { bytes memory callData = abi.encodeCall(flow.getSnapshotTime, (nullStreamId)); expectRevert_Null(callData); } function test_NotNull() external { bytes memory callData = abi.encodeCall(flow.getSnapshotTime, (defaultStreamId)); bytes memory returnData = abi.encode(getBlockTimestamp()); test_Getter(callData, returnData); } ```

PaulRBerg commented 5 days ago

That's a great idea @andreivladbrg.