-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: unit improvements #13
Conversation
7ec7e1f
to
1994426
Compare
c678d8f
to
a4c9a78
Compare
- name: Generate coverage report | ||
run: | | ||
forge coverage --report summary | ||
id: coverage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note this doesn't exit 1 on non-100% coverage unfortunately. Since the output:
Compiling 39 files with 0.8.25
Solc 0.8.25 finished in 2.42s
Compiler run �[32msuccessful!�[0m
Analysing contracts...
Running tests...
| File | % Lines | % Statements | % Branches | % Funcs |
|-----------------------|-----------------|-----------------|-----------------|-----------------|
| src/FoxStaking.sol | 100.00% (37/37) | 100.00% (38/38) | 100.00% (14/14) | 100.00% (14/14) |
| test/FoxStaking.t.sol | 100.00% (1/1) | 100.00% (1/1) | 100.00% (0/0) | 100.00% (1/1) |
| Total | 100.00% (38/38) | 100.00% (39/39) | 100.00% (14/14) | 100.00% (15/15) |
is more than likely to stay pretty much the same as we're not going to add more contract files/test files, do we want to have some smallish awk/sed/grep script here to exit 1 on non-100% coverage so that CI can fail? e.g something like this (ChatGPT-generated, untested but the idea is to rely on the output being consistent, filter out the irrelevant lines, and ensure both FoxStaking
, FoxStaking.t
and Total
lines are 100.00%.
- name: Check coverage for 100%
run: |
forge coverage --report summary | tee coverage.txt
# Assuming the coverage summary always starts at a known line after "Running tests..."
tail -n +10 coverage.txt > trimmed_coverage.txt
if grep -v '100.00%' trimmed_coverage.txt; then
echo "Not all coverage metrics are 100%"
exit 1
else
echo "All coverage metrics are 100%"
fi
Alternatively, forge coverage
can output lcov which we may be able to use instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll likely have more files as our test suites expand, but simply checking the total should be totally sufficient.
Could easily have a brute force check of the test with a regex to assert that any number preceding a %
symbol is the string 100.00
, which would cover all files regardless of how many we add in the future
1994426
to
968cac1
Compare
ab8e855
to
0e80a13
Compare
1b21631
to
476030f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting this in to keep things unblocked, will follow up on coverage assertion for CI re this comment
#13 (comment)
Description
This PR:
safeTransfer
/safeTransferFrom
for transfersAs the current last PR of the stack, also adds some improvements to the contract as noted by @0xean in #2, namely:
Issue
Screenshots