Skip to content
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

pytest: fix nayduck looking for contracts that are long long gone #12748

Merged
merged 15 commits into from
Jan 31, 2025

Conversation

nagisa
Copy link
Collaborator

@nagisa nagisa commented Jan 16, 2025

Although not an ideal solution, this is introducing a near-test-contracts binary that can output the contracts upon request. A good solution would be for pytest to either maintain their own contracts or link to near-test-contracts proper and grab the contracts by calling a function, just like is done in the rest of the test suite.

If neard is known to be always built with e.g. test_features for nayduck specifically, this code could be moved to a top-level neard subcommand.

@nagisa nagisa requested a review from wacban January 16, 2025 15:32
@nagisa nagisa requested a review from a team as a code owner January 16, 2025 15:32
@nagisa
Copy link
Collaborator Author

nagisa commented Jan 16, 2025

Entirely untested, just a sketch that needs to be verified for operation on nayduck.

Storing build artifacts in the source directory shouldn't be happening.
Although not an ideal, this is introducing a near-test-contracts
binary that can output the contracts upon request. A good solution would
be for pytest to either maintain their own contracts or link to
`near-test-contracts` proper and grab the contracts by calling a
function, just like is done in the rest of the test suite.
@nagisa nagisa force-pushed the nagisa/fixes-nayduck-contract-grabbing branch from d2aa307 to c4b50dd Compare January 16, 2025 15:33
Copy link
Contributor

@wacban wacban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Does this work with nayduck tests?

Comment on lines 248 to 251
"""Loads a WASM file from near-test-contracts package."""
output = subprocess.check_output(['cargo', 'run', '-p', 'near-test-contracts', filename],
cwd=_REPO_DIR)
return output.stdout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Sanity check - are the tests always executed from within the repo?

@@ -0,0 +1,30 @@
use std::io::Write as _;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit surprised there aren't any changes to cargo files.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cargo implicitly considers presence of src/main.rs to add a [bin] target, just like presence of src/lib.rs implicitly adds a [lib] target and tests/* each add a new [test].

@nagisa nagisa force-pushed the nagisa/fixes-nayduck-contract-grabbing branch from 0723a38 to 552dc15 Compare January 17, 2025 12:44
Copy link

codecov bot commented Jan 17, 2025

Codecov Report

Attention: Patch coverage is 44.00000% with 14 lines in your changes missing coverage. Please review.

Project coverage is 70.38%. Comparing base (72999fa) to head (ce3bc39).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
tools/dump-test-contract/src/lib.rs 43.47% 10 Missing and 3 partials ⚠️
neard/src/cli.rs 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12748      +/-   ##
==========================================
- Coverage   70.39%   70.38%   -0.01%     
==========================================
  Files         851      852       +1     
  Lines      174188   174213      +25     
  Branches   174188   174213      +25     
==========================================
+ Hits       122614   122627      +13     
- Misses      46327    46336       +9     
- Partials     5247     5250       +3     
Flag Coverage Δ
backward-compatibility 0.35% <44.00%> (+0.19%) ⬆️
db-migration 0.35% <44.00%> (+0.19%) ⬆️
genesis-check 1.41% <0.00%> (-0.01%) ⬇️
linux 70.06% <44.00%> (-0.01%) ⬇️
linux-nightly 70.01% <0.00%> (-0.01%) ⬇️
pytests 1.71% <44.00%> (+<0.01%) ⬆️
sanity-checks 1.52% <0.00%> (-0.01%) ⬇️
unittests 70.21% <0.00%> (-0.01%) ⬇️
upgradability 0.35% <44.00%> (+0.15%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wacban
Copy link
Contributor

wacban commented Jan 30, 2025

@wacban
Copy link
Contributor

wacban commented Jan 30, 2025

@nagisa Can you have a look? I added some finishing touches to actually work in nayduck and I moved it to a neard subcommand.

@nagisa
Copy link
Collaborator Author

nagisa commented Jan 31, 2025

LGTM though it looks like that in the CI tests here we gotta use something like $CURRENT_NEARD rather than assuming neard available in $TARGET_DIR at some specific build configuration.

@wacban wacban enabled auto-merge January 31, 2025 14:14
@wacban wacban added this pull request to the merge queue Jan 31, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 31, 2025
@wacban wacban added this pull request to the merge queue Jan 31, 2025
Merged via the queue into near:master with commit 49b24de Jan 31, 2025
27 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants