-
Notifications
You must be signed in to change notification settings - Fork 153
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
refactoring(cli && tests) - refactoring of the CLI package and integration tests #794
Conversation
be37399
to
9435b4c
Compare
791dd78
to
a890f34
Compare
f391d04
to
ca3cbbf
Compare
cli/ts/commands/publish.ts
Outdated
import { readContractAddress } from "../utils/storage" | ||
import { contractExists } from "../utils/contracts" | ||
import { getDefaultSigner, parseArtifact } from "maci-contracts" | ||
import { promptPwd } from "../utils/prompts" |
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.
@ctrlc03 , have you tried creating a hardhat task that imports any maci-cli command? I'm getting error (see below). I believe the hardhat import in the getDefaultSigner and parseArtifact is the issue. Hadhat scripts work fine, just the hardhat task
gives errors
Error HH9: Error while loading Hardhat's configuration.
You probably tried to import the "hardhat" module from your config or a file imported from it.
This is not possible, as Hardhat can't be initialized while its config is being defined.
To learn more about how to access the Hardhat Runtime Environment from different contexts go to https://hardhat.org/hre
For more info go to https://hardhat.org/HH9 or run Hardhat with --show-stack-traces```
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 have not, I will give it a try as soon as I get a chance
451adc7
to
206dc1d
Compare
I encountered a
|
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.
Great work on this PR! The reduction in test runtime from an hour to 30 minutes is a significant improvement and streamlining the testing process by eliminating the need for a separate hardhat network is highly beneficial. I've also provided some feedback to further refine our project's overall code quality and maintainability.
cli/package.json
Outdated
"compileSol": "./node_modules/maci-contracts/scripts/compileSol.sh $1", | ||
"pretest": "./node_modules/maci-contracts/scripts/compileSol.sh", |
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.
suggestion: here the CLI package references scripts directly from node_modules/maci-contracts/
. Given that our codebase is a monorepo using Lerna, which sets up symlinks via lerna bootstrap
, this setup could lead to issues. If the version specified in dependencies
differs from the local maci-contracts
version, Lerna might pull the package from npm instead of using the local symlink. This discrepancy could cause problems during development and testing, especially if there are version-specific dependencies or configurations. It's a potential area for tricky troubleshooting scenarios. We might want to consider revising this approach to ensure consistency and avoid such conflicts.
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.
What do you suggest here? I was thinking that users might install the cli package via npm and not have the full repo locally, so this way the package could work on its own
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.
suggestion: I noticed that our Mocha tests are throwing raw errors without using assertions. This results in unstructured and cluttered error logs, making it difficult to pinpoint the exact cause of test failures. For better clarity and maintainability, I suggest incorporating assertions (e.g., using assert
or a similar library) in our test cases. This way, if a test fails, we get a clear, concise message about what was expected versus what was actually observed. It will make debugging more straightforward and improve the overall quality of our test suite:
multiplePolls2
[✗] Could not find ./zkeys/ProcessMessages_10-2-1-2_test.wasm.
9) should run the first poll
✔ should deploy two more polls (452ms)
✔ should publish messages to the second poll (736ms)
✔ should publish messages to the third poll (756ms)
[✗] Could not find ./zkeys/ProcessMessages_10-2-1-2_test.wasm.
10) should complete the second poll
[✗] Could not find ./zkeys/ProcessMessages_10-2-1-2_test.wasm.
11) should complete the third poll
18 passing (1m)
11 failing
1) e2e tests
test1
should generate zk-SNARK proofs and verify them:
Error:
at logError (ts/utils/theme.ts:46:11)
at /Users/daehyun/workspace/pse/maci/cli/ts/commands/genProofs.ts:71:26
at step (ts/commands/genProofs.ts:33:23)
at Object.next (ts/commands/genProofs.ts:14:53)
at /Users/daehyun/workspace/pse/maci/cli/ts/commands/genProofs.ts:8:71
at new Promise (<anonymous>)
at __awaiter (ts/commands/genProofs.ts:4:12)
at genProofs (ts/commands/genProofs.ts:51:20)
at Suite.<anonymous> (tests/e2e.test.ts:110:28)
at step (tests/e2e.test.ts:33:23)
at Object.next (tests/e2e.test.ts:14:53)
at fulfilled (tests/e2e.test.ts:5:58)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at runNextTicks (node:internal/process/task_queues:64:3)
at listOnTimeout (node:internal/timers:538:9)
at processTimers (node:internal/timers:512:7)
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.
[✗] Could not find ./zkeys/ProcessMessages_10-2-1-2_test.wasm. isn't that clear enough?
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 am throwing directly with the error text rather than an empty and confusing stack trace too (as suggested in a previous comment)
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.
Tests should explicitly assert the conditions they're checking for clarity and precision. If you intend to address this in a follow-up PR, please create an issue to track it.
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.
Yea tests should actually be properly reviewed in a separate piece of work imo (this PR goal was not that), there's loads we can improve and perhaps some of them are not so correct
(+) I've observed that our current logging strategy frequently checks the There are several libraries that can help implement this, such as |
As I've gone through this PR, I've observed several areas that could benefit from future attention and refinement. While these don't necessarily need to be addressed within the scope of this current PR, they're important for the ongoing improvement of our project:
Though not pressing for this PR, this point would be valuable to keep in mind for future development to elevate the quality and usability of our CLI. |
I wanted to keep the production package a bit slimmer and avoid using third party libraries for that, what you think? |
f693acb
to
5716bfb
Compare
could you try to run it with ts-node instead please? this is due to hardhat.config.ts unfortunately. We need to think how this would work on a published npm package (how do users get access to the contracts ABI, how do they setup the config file locally, and how do they run the cli) |
75f6a70
to
10bfa67
Compare
It looks weird for me that we have to use |
…oded values from tests
…on and default cli flags
…e package-lock for contracts
…nd fix issue in markdown docs
… latest code features and node versions
…meter and throw error directly on failure
…PR comments, revert to using hardhat.config.js and running a local node first for cli local usage
…ommander level, update documentation
…hardhat for cli tests)
…/index) and remove conflict mark
81e078a
to
79de49f
Compare
CI failed due to corrupted lock file in contract package:
|
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.
Great job on this PR! Really appreciate all the effort we put into this.
thanks for the time taken to review this big one! |
…tom error handling for commander
79de49f
to
e3bd3d6
Compare
fix #789 and fix #790
What has been done in this PR: