-
Notifications
You must be signed in to change notification settings - Fork 3
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
ZK-559: (part 2) unit tests for shielder-sdk #90
Conversation
|
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.
Haven't finished reading but left a few comments, will get back to it tomorrow.
@@ -107,11 +109,11 @@ class MockedConverter implements Converter { | |||
|
|||
class MockedNoteTreeConfig implements NoteTreeConfig { | |||
treeHeight(): Promise<number> { | |||
return Promise.resolve(13); | |||
return Promise.resolve(1); |
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.
nice that we have control over this and get short test values
) | ||
).toBe(true); | ||
|
||
// merkleRoot should be equal to input merkleRoot |
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.
nit: These 3 lines are self-explanatory and don't really need comments, do they?
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.
maybe they don't need comments, but my goal was to comment as much as I can
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.
I claim that code with more comments is not always better. A comment helps if reading it is faster than reading the code being commented, or if it provides extra information, and this is not the case here.
So that it is not just me: https://medium.com/@bpnorlander/stop-writing-code-comments-28fef5272752
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.
I'm also a proponent of "good code doesn't have to be commented"
BUT
in such complex unit tests I really believe commenting is good.
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.
disagreeing here but it's not a big deal, feel free to merge
@@ -1,7 +1,9 @@ | |||
import { |
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.
It would be really cool to see not only coverage percentage but also which lines are covered. Do you know if it's easy to do?
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.
if you run pnpm coverage
locally, you can see which lines are uncovered, however it's tricky to add that to report.
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.
Thanks, it works for me. We probably can also use some vs code extension to overlay this on editor view, but it seems to take some time to configure.
); | ||
expect(isValid).toBe(true); | ||
|
||
// Amount should be equal to input amount |
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.
nit: I suggest removing the 3 comments as the commented code is self-explanatory.
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.
want to comment as much as it possible
) | ||
).toBe(true); | ||
|
||
// merkleRoot should be equal to input merkleRoot |
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.
nit: these 2 lines are self-explanatory, consider removing the 2 comments
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.
want to comment as much as it possible
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.
Nice coverage. Just a few comments.
); | ||
expect(isValid).toBe(true); | ||
|
||
// Amount should be equal to input amount |
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.
nit: the 3 comments below do not add value
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.
want to keep as commented as possible
No description provided.