Skip to content

Commit

Permalink
also test near-vm as soon as protocol upgrade is done (near#8901)
Browse files Browse the repository at this point in the history
Actual test changes will happen when we make VMConfig::test() return a protocol version with contract preparation v2, so when we introduce the near-vm protocol upgrade.
  • Loading branch information
Ekleog-NEAR authored Apr 11, 2023
1 parent 194312e commit 33e6abf
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 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.

4 changes: 2 additions & 2 deletions runtime/near-vm-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ assert_matches.workspace = true
bolero.workspace = true
expect-test.workspace = true
hex.workspace = true
near-primitives-core.workspace = true
near-test-contracts.workspace = true
rand.workspace = true
wasm-smith.workspace = true
wasmprinter.workspace = true
wat.workspace = true

near-test-contracts.workspace = true

[features]
# all vms enabled for now
default = [
Expand Down
40 changes: 39 additions & 1 deletion runtime/near-vm-runner/src/tests/test_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,50 @@ impl TestBuilder {

// We only test trapping tests on Wasmer, as of version 0.17, when tests executed in parallel,
// Wasmer signal handlers may catch signals thrown from the Wasmtime, and produce fake failing tests.
#[allow(dead_code)]
pub(crate) fn skip_wasmtime(mut self) -> Self {
self.skip.insert(VMKind::Wasmtime);
self
}

#[allow(dead_code)]
pub(crate) fn skip_wasmer0(mut self) -> Self {
self.skip.insert(VMKind::Wasmer0);
self
}

#[allow(dead_code)]
pub(crate) fn skip_wasmer2(mut self) -> Self {
self.skip.insert(VMKind::Wasmer2);
self
}

#[allow(dead_code)]
pub(crate) fn skip_near_vm(mut self) -> Self {
self.skip.insert(VMKind::NearVm);
self
}

#[allow(dead_code)]
pub(crate) fn only_wasmtime(self) -> Self {
self.skip_wasmer0().skip_wasmer2().skip_near_vm()
}

#[allow(dead_code)]
pub(crate) fn only_wasmer0(self) -> Self {
self.skip_wasmer2().skip_near_vm().skip_wasmtime()
}

#[allow(dead_code)]
pub(crate) fn only_wasmer2(self) -> Self {
self.skip_wasmer0().skip_near_vm().skip_wasmtime()
}

#[allow(dead_code)]
pub(crate) fn only_near_vm(self) -> Self {
self.skip_wasmer0().skip_wasmer2().skip_wasmtime()
}

/// Run the necessary tests to check protocol upgrades for the given
/// features.
///
Expand Down Expand Up @@ -147,12 +176,21 @@ impl TestBuilder {

for (want, &protocol_version) in wants.iter().zip(&self.protocol_versions) {
let mut results = vec![];
for vm_kind in [VMKind::Wasmer2, VMKind::Wasmer0, VMKind::Wasmtime] {
for vm_kind in [VMKind::NearVm, VMKind::Wasmer2, VMKind::Wasmer0, VMKind::Wasmtime] {
if self.skip.contains(&vm_kind) {
continue;
}

let runtime_config = runtime_config_store.get_config(protocol_version);

// NearVM includes a different contract preparation algorithm, that is not supported on old protocol versions
if vm_kind == VMKind::NearVm
&& runtime_config.wasm_config.limit_config.contract_prepare_version
!= near_primitives_core::config::ContractPrepareVersion::V2
{
continue;
}

let mut fake_external = MockedExternal::new();
let config = runtime_config.wasm_config.clone();
let fees = RuntimeFeesConfig::test();
Expand Down

0 comments on commit 33e6abf

Please sign in to comment.