-
Notifications
You must be signed in to change notification settings - Fork 712
test: aac add test coverage for ParseError
variants
#6631
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
base: develop
Are you sure you want to change the base?
test: aac add test coverage for ParseError
variants
#6631
Conversation
|
||
/// ParserError: [`ParseErrors::Lexer`] | ||
/// Caused by: unknown symbol | ||
/// Outcome: block accepted. |
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 like your comments. Clear, concise, easy to follow/reason about.
I actually think it might be slightly easier to reason about the test name/be able to find tests if we did something like #[test]
fn test_parse_error_lexer() {
contract_deploy_consensus_test!(
function_name!(),
contract_name: "my-contract",
contract_code: &{"(use-trait)"},
);
} since when I initially looked at contract_deploy_consensus_test! macro it took me a bit to realize it was a #[test]. But I am not strongly one way or the other. Whichever makes it easier for you to reuse these functions in your test, go for it. If you need help fixing your errors, let me know. I will give it a look. |
Considering we have a macro, we should be able to use |
Based on the feedback, I've updated consensus macros as proposed in the PR description. By the way, adding more tests exposed a new issue related to the
produce a non-deterministic
where the element listed in the paranthesis can have a different order and the flip/flop between them at each run. |
Codecov Report❌ Patch coverage is
❌ Your project check has failed because the head coverage (74.38%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #6631 +/- ##
===========================================
+ Coverage 64.85% 74.38% +9.52%
===========================================
Files 574 575 +1
Lines 355039 355145 +106
===========================================
+ Hits 230278 264188 +33910
+ Misses 124761 90957 -33804
... and 373 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
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.
Good changes! Definitely fine with the named tests.
PS:I am sure you already noticed, but some unit tests are currently failing
use clarity::vm::ast::stack_depth_checker::AST_CALL_STACK_DEPTH_BUFFER; | ||
use clarity::vm::MAX_CALL_STACK_DEPTH; | ||
#[allow(unused_imports)] // Just used for documentation purpose | ||
use clarity_types::{errors::ParseErrors, ContractName}; |
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: maybe we can directly import it from use clarity::vm::ast::errors::ParseErrors
and avoid adding clarity_types directly?
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.
you're right! the IDE didn't show auto-completition option to gather these symbols from clarity
crate. Damn it :)
crc: 2ac068b
transactions: [ | ||
ExpectedTransactionOutput( | ||
tx: "SmartContract(name: my-contract-Epoch3_3-Clarity4, code_body: [..], clarity_version: Some(Clarity4))", | ||
vm_error: "Some(use of undeclared trait <my-trait>) [NON-CONSENSUS BREAKING]", |
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.
damn, that's a pity that vm_error
contains the "message" of the error and not the error variant itself
contract_code: &{" | ||
(define-data-var my-int int 340282366920938463463374607431768211455) | ||
"}, |
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, you can remove &{
in case you pass a string slice
contract_code: &{" | |
(define-data-var my-int int 340282366920938463463374607431768211455) | |
"}, | |
contract_code: "(define-data-var my-int int 340282366920938463463374607431768211455)", |
even multiline strings will work fine
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.
crc: 730fc6d
Yeah! This is due the |
27b1d56
to
a81db5d
Compare
I opted to manage this issue, forcing the |
Description
This PR adds consensus test coverage for the ParseError enum in preparation for the upcoming refactor of that enum. The PR is currently a draft to gather early feedback on test organization and macro usage.
The PR is currently a draft to gather early feedback about test organization and macro usage::
ParseError
related tests in a dedicate moduleparse_tests.rs
contract_deploy_consensus_test!
andcontract_call_consensus_test!
macros opting for:clarity_types
crate as test dependency for documentation purposes (doc referencing Parse error variants). This is just a preliminary attempt, and I open to remove it if it's not beneficial (I'm also trying understanding this)Currently, it doesn’t work properly with the macro, causing IDE warnings and broken hyperlinks (would function correctly with a standard test function)
I also noticed that with the macro we loose the Outline view (is empty)
So, apart the doc thing, I'm wondering if in general would be convenient having "native" test functions while keeping the macro just for configuring the test body. Something like this:
Applicable issues
ParseError
enum #6627Additional info (benefits, drawbacks, caveats)
Checklist
docs/rpc/openapi.yaml
andrpc-endpoints.md
for v2 endpoints,event-dispatcher.md
for new events)clarity-benchmarking
repo