Replies: 7 comments 2 replies
-
I do not agree at all with this system of writing tests. It adds complexity and creates chaos. A testing branch should be mirrored by a function test, not by a contract. Why would you create this complex inheritance system in the first place when you can simply write explanatory comments? Starting from the tree you've already written above:
Issues1. Compilation timeBecause you've added so much complexity to the code, the compilation time has increased by x4-5 times, this is absurd to me. Don't we use foundry because it is fast? You make it run in circles and it loses its beauty. V3 compiling timeFrom this commit 01dd010: Actual compiling timeFrom this commit 833bf92: I've actually tested this multiple times and I've never gotten a time shorter than 2 minutes and 24 seconds from the v3 commit. You can say foundry saves the artifacts, but this fact is true when there are no changes in the code (only if you compile the same code). Even the slightest change will make you wait x4-5 more time for the compilation. 2. Chaotic display in terminalBecause each function is written in a different contract the tests will be displayed in a very messy way. 3. Coding timeIt increases the time of writing the tests. ConclusionFrom my point of view there is nothing objective to this way of structuring the tests, it even makes the work much harder. |
Beta Was this translation helpful? Give feedback.
-
I think you haven't read the rationale I presented in this comment?
I agree that it's not as pretty as before, and likewise the tests are not grouped like they used to be, but at least in my experience it is rare that you need to run all the tests locally. Usually, you use the
Because:
Also, I don't think that complexity should ever be put forth as an argument against a potential improvement related to our testing system. It's fine for tests to be complex as long as they are clear and make it hard to fool ourselves - it's really just the production contracts that have to be gas efficient and easy to use.
Sure, but if that means you want 50ms instead of 10ms, surely you don't notice that time at all, do you? When the artifacts are cached by Foundry (i.e. in the vast majority of cases), compilation time doesn't take a lot of time.
I've been using this system for over a week now, it's really easy to identify a failing test, because Foundry lists the failures at the bottom of the console output. There's also the
Actually, not, it's just a question of getting used to the new format. And that wouldn't take long. And as I explained, by virtue of being an objective naming system, we would actually save time by not mulling over comment formatting and function naming. But even if this were true, it would actually be a GOOD thing for a new proposal to make us spend more time testing! Again, I emphasize how important it is now to fool ourselves while doing this.
This is an oxymoron. You cannot respond to a claim "X is objective" by saying that "In my opinion, X is not objective". |
Beta Was this translation helpful? Give feedback.
-
What do you think about this, @andreivladbrg? V4function testCannotFunction__Foo() external{}
modifier NotFoo { _; }
function testCannotFunction__Bar() NotFoo external{}
modifier NotBar { _; }
function testFunction() NotFoo NotBar external {} This should address your two main concerns.
|
Beta Was this translation helpful? Give feedback.
-
Given that we settled on v4, there is nothing left to say on my side. |
Beta Was this translation helpful? Give feedback.
-
Interestingly, someone else wrote an article about this approach already, though they have inspired from a tweet that I made a while ago: Take your Solidity testing to the next level with state building! |
Beta Was this translation helpful? Give feedback.
-
Closing, we ended up using the "V4" technique. |
Beta Was this translation helpful? Give feedback.
-
For future reference: I will give a talk about this testing branching technique at EthCC. |
Beta Was this translation helpful? Give feedback.
-
Context
In #90, I have completely refactored our test files to more accurately reflect the testing branches written in the
*.tree
file. This discussion delves into the rationale that went into the refactor and how I arrived at the final version used in the PR.Problem
The testing branches are not mirrored exactly in the testing files.
Solutions
Given this testing tree:
V1
You can see a full example in this GitHub gist: create-v1.t.sol.
V2
You can see a full example in this GitHub gist: create-v2.t.sol.
V3
You can see a full example in this GitHub gist: create-v3.t.sol.
My Decision
I have ultimately chosen V3, because it was the only that:
V1 did not scale, because Forge enforces a limit on how large a contract name can be (
os error 63
), and it also wasn't very readable at scale, due to the long contract names. Whereas V2 scaled, in that Foundry could run the tests even with very long function names, but again the readability wasn't great.The only slight problem with V3 is that in case where the tree branches in multiple directions (a good example is getWithdrawableAmount.tree), the contract names sort of have to be written using the V1 methodology, lest we get duplicates. But this shouldn't be a problem because usually the branching in one direction stops earlier than the bottom-most branch.
Screenshots
OS Error 63
Beta Was this translation helpful? Give feedback.
All reactions