-
Notifications
You must be signed in to change notification settings - Fork 677
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pytest: fix nayduck looking for contracts that are long long gone (#1…
…2748) 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. --------- Co-authored-by: wacban <[email protected]> Co-authored-by: Waclaw Banasik <[email protected]>
- Loading branch information
1 parent
33b4907
commit 49b24de
Showing
13 changed files
with
130 additions
and
28 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[package] | ||
name = "near-dump-test-contract" | ||
version.workspace = true | ||
authors.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
repository.workspace = true | ||
license.workspace = true | ||
publish = false | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[dependencies] | ||
anyhow.workspace = true | ||
clap.workspace = true | ||
|
||
near-test-contracts.workspace = true | ||
|
||
[features] | ||
nightly_protocol = [] | ||
nightly = [ | ||
"near-test-contracts/nightly", | ||
"nightly_protocol", | ||
] | ||
test_features = [ | ||
"near-test-contracts/test_features", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use std::io::Write; | ||
|
||
use clap::Parser; | ||
use near_test_contracts::{ | ||
backwards_compatible_rs_contract, congestion_control_test_contract, estimator_contract, | ||
ft_contract, fuzzing_contract, nightly_rs_contract, rs_contract, smallest_rs_contract, | ||
trivial_contract, ts_contract, | ||
}; | ||
|
||
#[derive(Parser)] | ||
pub struct DumpTestContractCommand { | ||
#[arg(short, long)] | ||
contract_name: String, | ||
} | ||
|
||
impl DumpTestContractCommand { | ||
pub fn run(&self) -> anyhow::Result<()> { | ||
let Some((name, extension)) = self.contract_name.rsplit_once(".") else { | ||
panic!("argument expected in `filename.wasm` form"); | ||
}; | ||
|
||
if extension != "wasm" { | ||
panic!("unsupported filetype `{extension}`"); | ||
} | ||
|
||
let code = match &*name { | ||
"trivial" => trivial_contract(), | ||
"rs_contract" => rs_contract(), | ||
"nightly_rs_contract" => nightly_rs_contract(), | ||
"backwards_compatible_rs_contract" => backwards_compatible_rs_contract(), | ||
"ts_contract" => ts_contract(), | ||
"fuzzing_contract" => fuzzing_contract(), | ||
"ft_contract" => ft_contract(), | ||
"smallest_rs_contract" => smallest_rs_contract(), | ||
"estimator_contract" => estimator_contract(), | ||
"congestion_control_test_contract" => congestion_control_test_contract(), | ||
_ => panic!("unknown contract {name}"), | ||
}; | ||
|
||
std::io::stdout().write_all(&code).expect("while writing code to stdout"); | ||
|
||
Ok(()) | ||
} | ||
} |