Skip to content

Commit

Permalink
Prefer lazy_static_include_bytes in tests (#6654)
Browse files Browse the repository at this point in the history
Apparently lazy_static_include_bytes compiles faster than include_bytes
and we’re already using it in bunch of tests so do that consistently.
  • Loading branch information
mina86 authored Apr 21, 2022
1 parent 14e6f39 commit abd5559
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
10 changes: 6 additions & 4 deletions nearcore/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1441,10 +1441,12 @@ fn test_init_config_localnet() {
/// correctly parsed and defaults being applied correctly applied.
#[test]
fn test_config_from_file() {
for (has_gc, data) in [
(true, include_bytes!("../../testdata/example-config-gc.json").as_slice()),
(false, include_bytes!("../../testdata/example-config-no-gc.json").as_slice()),
] {
lazy_static_include::lazy_static_include_bytes! {
EXAMPLE_CONFIG_GC => "res/example-config-gc.json",
EXAMPLE_CONFIG_NO_GC => "res/example-config-no-gc.json",
};

for (has_gc, data) in [(true, &EXAMPLE_CONFIG_GC[..]), (false, &EXAMPLE_CONFIG_NO_GC[..])] {
let tmp = tempfile::NamedTempFile::new().unwrap();
tmp.as_file().write_all(data).unwrap();

Expand Down
1 change: 1 addition & 0 deletions runtime/near-vm-runner-standalone/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
clap = { version = "3.1.6", features = ["derive"] }
base64 = "0.13"
lazy-static-include = "3"
num-rational = "0.3"
tracing-span-tree = "0.1"

Expand Down
9 changes: 5 additions & 4 deletions runtime/near-vm-runner-standalone/src/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ fn profile_data_is_per_outcome() {
#[cfg(feature = "no_cache")]
#[test]
fn test_evm_slow_deserialize_repro() {
lazy_static_include::lazy_static_include_bytes! {
ZOMBIE_OWNERSHIP_BIN => "../near-test-contracts/res/ZombieOwnership.bin",
};

fn evm_slow_deserialize_repro(vm_kind: VMKind) {
println!("evm_slow_deserialize_repro of {:?}", &vm_kind);
tracing_span_tree::span_tree().enable();
Expand All @@ -262,10 +266,7 @@ fn test_evm_slow_deserialize_repro() {
let contract =
script.contract_from_file(Path::new("../near-test-contracts/res/near_evm.wasm"));

let input =
hex::decode(&include_bytes!("../../near-test-contracts/res/ZombieOwnership.bin"))
.unwrap();

let input = hex::decode(&ZOMBIE_OWNERSHIP_BIN[..]).unwrap();
script.step(contract, "deploy_code").input(input).repeat(3);
let res = script.run();
assert_eq!(res.outcomes[0].error(), None);
Expand Down

0 comments on commit abd5559

Please sign in to comment.