Replies: 7 comments
-
always in favor of more tests overall your proposition makes sense |
Beta Was this translation helpful? Give feedback.
-
This proposal looks well thought out. Unfortunately I can't weigh too much of an opinion because I am not experienced with Solidity development. Generally speaking more tests are good but I understand and agree with diminishing returns as per @zgorizzo69 comment. We just need to use our best judgement on how much coverage we will have. Once we have the input from all the @ubiquity/bounty-masters @ubiquity/development Solidity developers lets convert these to separate issues. @rndquu you can add the label that represents your best time estimate for each bounty once we create the issues (e.g. <1 day, <1 week) you can also set all of them to priority 0 or 1. @rndquu I invited you so you can set labels https://github.com/orgs/ubiquity/teams/development/members |
Beta Was this translation helpful? Give feedback.
-
We should write a test for the vulnerability found. We might even be able to fork one from one of the linked GitHub links. |
Beta Was this translation helpful? Give feedback.
-
Agree that there's no need to test contracts from libraries. If it's from somewhere like OpenZeppelin or Uniswap we can generally trust that they've already been thoroughly tested. If it's from somewhere that's more of an unknown then we should be thoroughly reviewing the contracts before implementing them as a library. Permissioned functions fall under this and we don't need to test for when an account without the proper role calls one. Tests need to follow a common naming convention and we need to account for each possible state (ie just deployed is Zero State) We have test helpers that deploy the contracts in the proper order, for both mainnet forks and offline, all that's needed is to inherit from them and call The pattern of We need to ensure that we're testing both when a function should succeed, and when it should fail. Some functions have multiple fail states and we need to test for each one. If a feature is added or altered then the relevant PR shouldn't be merged unless it includes adequate testing. edit: Our tests are also running way too long, I imagine it's worse for anyone that's using a computer that's more than 3 years old. Anything we can do to optimize that will be a positive, and eliminating unnecessary tests is a good first step. |
Beta Was this translation helpful? Give feedback.
-
This proposal looks good. Thank you for your writing @rndquu. I definitely agree with creating a stable stablecoin project. Test coverage is very important.
If I had to say the general perspective of this discussion, I might say its not urgent rather than implementing general architecture to unblock UI testing env setup. 1/ Complete a deploy script PR which is still ongoing by @hashedMae . @rndquu would you please take a deep dive on this if you have bandwidth? |
Beta Was this translation helpful? Give feedback.
-
I removed the mock tests cause I was sick of them slowing down testing. |
Beta Was this translation helpful? Give feedback.
-
If we adopt the testing guidelines from the Foundry Book that should help us optimize for what's important and provides a robust naming style. |
Beta Was this translation helpful? Give feedback.
-
Let's make tests better.
Coverage
Right now if you run
forge coverage --fork-url https://cloudflare-eth.com
you get the following:So code coverage could be better for a stablecoin project.
Test naming
Also there is no single template for test naming, check out these 3 different test naming styles:
testPermit_ShouldRevert_IfSignatureIsInvalid
vstestCannotDeployEmptyAddress
vstest_setExpiredCreditNFTConversionRate
So new developers who come to the project can't understand what style to choose.
ERC4626 tests
We've got the following tests for the ERC4626 contract: https://github.com/ubiquity/ubiquity-dollar/blob/development/packages/contracts/test/dollar/ERC4626.t.sol
There are a few issues with those tests:
ERC4626
is already tested by the openzeppelin and its communityProposed tasks
1. Refactor tests to maintain a single naming convention
Refactor tests using the following convention
test[MethodName]_[ExpectedResult]_[Condition]
Examples:
2. Remove tests for ERC4624
Remove:
3. Add CI build badge
Add CI build badge at the top of the https://github.com/ubiquity/ubiquity-dollar/blob/development/README.md with the current CI build status (success or fail)
4. Add test coverage badge
Add test coverage badge with % of lines covered by tests at the top of the https://github.com/ubiquity/ubiquity-dollar/blob/development/README.md
5. Add CI action that fails on decreased test coverage
When user creates a PR to the
development
branch there should be a github action that checks that code coverage is not decreased. If code coverage is decreased the CI action should fail.6. Remove mocks, libs and tests from coverage report
Remove the following files from the test coverage report:
src/dollar/libs/*
src/dollar/mocks/*
src/dollar/utils/*
src/manager/libraries/*
src/ubiquistick/MockUBQmanager.sol
test/*
7. Add more tests for ERC1155SetUri
Add more tests for:
src/dollar/ERC1155SetUri/ERC1155BurnableSetUri.sol
src/dollar/ERC1155SetUri/ERC1155PausableSetUri.sol
src/dollar/ERC1155SetUri/ERC1155SetUri.sol
Test coverage right now:
8. Add more tests for Staking
Add more tests for:
src/dollar/Staking.sol
src/dollar/StakingShare.sol
Test coverage right now:
9. Add more tests for UbiquityChef and UbiquityFormulas
Add more tests for:
src/dollar/UbiquityChef.sol
src/dollar/UbiquityFormulas.sol
Test coverage right now:
10. Add more tests for CreditRedemptionCalculator, DollarMintExcess and UbiquityCreditToken
Add more tests for:
src/dollar/core/CreditRedemptionCalculator.sol
src/dollar/core/DollarMintExcess.sol
src/dollar/core/UbiquityCreditToken.sol
Test coverage right now:
11. Add more tests for ubiquistick: LP, SimpleBond and UAR
Add more tests for:
src/ubiquistick/LP.sol
src/ubiquistick/SimpleBond.sol
src/ubiquistick/UAR.sol
Test coverage right now:
12. Add more tests for UbiquiStick and UbiquiStickSale
Add more tests for:
src/ubiquistick/UbiquiStick.sol
src/ubiquistick/UbiquiStickSale.sol
Test coverage right now:
Beta Was this translation helpful? Give feedback.
All reactions