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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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 0% with 23 lines in your changes missing coverage. Please review.

Project coverage is 70.62%. Comparing base (8c0e9b9) to head (552dc15).
Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
runtime/near-test-contracts/src/main.rs 0.00% 23 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12748      +/-   ##
==========================================
- Coverage   70.66%   70.62%   -0.04%     
==========================================
  Files         848      850       +2     
  Lines      174088   174545     +457     
  Branches   174088   174545     +457     
==========================================
+ Hits       123016   123276     +260     
- Misses      45932    46114     +182     
- Partials     5140     5155      +15     
Flag Coverage Δ
backward-compatibility 0.16% <ø> (-0.01%) ⬇️
db-migration 0.16% <ø> (-0.01%) ⬇️
genesis-check 1.35% <ø> (-0.01%) ⬇️
linux 69.13% <0.00%> (-0.08%) ⬇️
linux-nightly 70.23% <0.00%> (-0.01%) ⬇️
pytests 1.65% <ø> (-0.01%) ⬇️
sanity-checks 1.46% <ø> (-0.01%) ⬇️
unittests 70.45% <0.00%> (-0.04%) ⬇️
upgradability 0.20% <ø> (-0.01%) ⬇️

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.

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