Skip to content

Commit

Permalink
code review - use 'ignore'
Browse files Browse the repository at this point in the history
  • Loading branch information
wacban committed Jan 22, 2023
1 parent 5d72b4c commit 44741f3
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 79 deletions.
153 changes: 75 additions & 78 deletions integration-tests/src/tests/client/features/wasmer2.rs
Original file line number Diff line number Diff line change
@@ -1,89 +1,86 @@
// This test fails on aarch because wasmer0 and wasmer2 are not available.
#[cfg(not(all(target_arch = "aarch64", target_vendor = "apple")))]
mod test_wasmer2_upgrade {
use crate::tests::client::process_blocks::{create_nightshade_runtimes, deploy_test_contract};
use near_chain::ChainGenesis;
use near_chain_configs::Genesis;
use near_client::test_utils::TestEnv;
use near_crypto::{InMemorySigner, KeyType, Signer};
use near_primitives::hash::CryptoHash;
use near_primitives::transaction::{Action, FunctionCallAction, Transaction};
use nearcore::config::GenesisExt;
use crate::tests::client::process_blocks::{create_nightshade_runtimes, deploy_test_contract};
use near_chain::ChainGenesis;
use near_chain_configs::Genesis;
use near_client::test_utils::TestEnv;
use near_crypto::{InMemorySigner, KeyType, Signer};
use near_primitives::hash::CryptoHash;
use near_primitives::transaction::{Action, FunctionCallAction, Transaction};
use nearcore::config::GenesisExt;

#[test]
fn test_wasmer2_upgrade() {
let mut capture = near_o11y::testonly::TracingCapture::enable();
// This test fails on aarch because wasmer0 and wasmer2 are not available.
#[cfg_attr(all(target_arch = "aarch64", target_vendor = "apple"), ignore)]
#[test]
fn test_wasmer2_upgrade() {
let mut capture = near_o11y::testonly::TracingCapture::enable();

let old_protocol_version =
near_primitives::version::ProtocolFeature::Wasmer2.protocol_version() - 1;
let new_protocol_version = old_protocol_version + 1;
let old_protocol_version =
near_primitives::version::ProtocolFeature::Wasmer2.protocol_version() - 1;
let new_protocol_version = old_protocol_version + 1;

// Prepare TestEnv with a contract at the old protocol version.
let mut env = {
let epoch_length = 5;
let mut genesis =
Genesis::test(vec!["test0".parse().unwrap(), "test1".parse().unwrap()], 1);
genesis.config.epoch_length = epoch_length;
genesis.config.protocol_version = old_protocol_version;
let chain_genesis = ChainGenesis::new(&genesis);
let mut env = TestEnv::builder(chain_genesis)
.runtime_adapters(create_nightshade_runtimes(&genesis, 1))
.build();
// Prepare TestEnv with a contract at the old protocol version.
let mut env = {
let epoch_length = 5;
let mut genesis =
Genesis::test(vec!["test0".parse().unwrap(), "test1".parse().unwrap()], 1);
genesis.config.epoch_length = epoch_length;
genesis.config.protocol_version = old_protocol_version;
let chain_genesis = ChainGenesis::new(&genesis);
let mut env = TestEnv::builder(chain_genesis)
.runtime_adapters(create_nightshade_runtimes(&genesis, 1))
.build();

deploy_test_contract(
&mut env,
"test0".parse().unwrap(),
near_test_contracts::rs_contract(),
epoch_length,
1,
);
env
};
deploy_test_contract(
&mut env,
"test0".parse().unwrap(),
near_test_contracts::rs_contract(),
epoch_length,
1,
);
env
};

let signer = InMemorySigner::from_seed("test0".parse().unwrap(), KeyType::ED25519, "test0");
let tx = Transaction {
signer_id: "test0".parse().unwrap(),
receiver_id: "test0".parse().unwrap(),
public_key: signer.public_key(),
actions: vec![Action::FunctionCall(FunctionCallAction {
method_name: "log_something".to_string(),
args: Vec::new(),
gas: 100_000_000_000_000,
deposit: 0,
})],
let signer = InMemorySigner::from_seed("test0".parse().unwrap(), KeyType::ED25519, "test0");
let tx = Transaction {
signer_id: "test0".parse().unwrap(),
receiver_id: "test0".parse().unwrap(),
public_key: signer.public_key(),
actions: vec![Action::FunctionCall(FunctionCallAction {
method_name: "log_something".to_string(),
args: Vec::new(),
gas: 100_000_000_000_000,
deposit: 0,
})],

nonce: 0,
block_hash: CryptoHash::default(),
};
nonce: 0,
block_hash: CryptoHash::default(),
};

// Run the transaction & collect the logs.
let logs_at_old_version = {
let tip = env.clients[0].chain.head().unwrap();
let signed_transaction =
Transaction { nonce: 10, block_hash: tip.last_block_hash, ..tx.clone() }
.sign(&signer);
env.clients[0].process_tx(signed_transaction, false, false);
for i in 0..3 {
env.produce_block(0, tip.height + i + 1);
}
capture.drain()
};
// Run the transaction & collect the logs.
let logs_at_old_version = {
let tip = env.clients[0].chain.head().unwrap();
let signed_transaction =
Transaction { nonce: 10, block_hash: tip.last_block_hash, ..tx.clone() }.sign(&signer);
env.clients[0].process_tx(signed_transaction, false, false);
for i in 0..3 {
env.produce_block(0, tip.height + i + 1);
}
capture.drain()
};

env.upgrade_protocol(new_protocol_version);
env.upgrade_protocol(new_protocol_version);

// Re-run the transaction.
let logs_at_new_version = {
let tip = env.clients[0].chain.head().unwrap();
let signed_transaction =
Transaction { nonce: 11, block_hash: tip.last_block_hash, ..tx }.sign(&signer);
env.clients[0].process_tx(signed_transaction, false, false);
for i in 0..3 {
env.produce_block(0, tip.height + i + 1);
}
capture.drain()
};
// Re-run the transaction.
let logs_at_new_version = {
let tip = env.clients[0].chain.head().unwrap();
let signed_transaction =
Transaction { nonce: 11, block_hash: tip.last_block_hash, ..tx }.sign(&signer);
env.clients[0].process_tx(signed_transaction, false, false);
for i in 0..3 {
env.produce_block(0, tip.height + i + 1);
}
capture.drain()
};

assert!(logs_at_old_version.iter().any(|l| l.contains(&"vm_kind=Wasmer0")));
assert!(logs_at_new_version.iter().any(|l| l.contains(&"vm_kind=Wasmer2")));
}
assert!(logs_at_old_version.iter().any(|l| l.contains(&"vm_kind=Wasmer0")));
assert!(logs_at_new_version.iter().any(|l| l.contains(&"vm_kind=Wasmer2")));
}
4 changes: 3 additions & 1 deletion integration-tests/src/tests/client/process_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3474,7 +3474,6 @@ fn test_catchup_no_sharding_change() {
}

/// These tests fail on aarch because the WasmtimeVM::precompile method doesn't populate the cache.
#[cfg(not(all(target_arch = "aarch64", target_vendor = "apple")))]
mod contract_precompilation_tests {
use super::*;
use near_primitives::contract::ContractCode;
Expand Down Expand Up @@ -3513,6 +3512,7 @@ mod contract_precompilation_tests {
}

#[test]
#[cfg_attr(all(target_arch = "aarch64", target_vendor = "apple"), ignore)]
fn test_sync_and_call_cached_contract() {
let num_clients = 2;
let stores: Vec<Store> = (0..num_clients).map(|_| create_test_store()).collect();
Expand Down Expand Up @@ -3615,6 +3615,7 @@ mod contract_precompilation_tests {
}

#[test]
#[cfg_attr(all(target_arch = "aarch64", target_vendor = "apple"), ignore)]
fn test_two_deployments() {
let num_clients = 2;
let stores: Vec<Store> = (0..num_clients).map(|_| create_test_store()).collect();
Expand Down Expand Up @@ -3696,6 +3697,7 @@ mod contract_precompilation_tests {
}

#[test]
#[cfg_attr(all(target_arch = "aarch64", target_vendor = "apple"), ignore)]
fn test_sync_after_delete_account() {
let num_clients = 3;
let stores: Vec<Store> = (0..num_clients).map(|_| create_test_store()).collect();
Expand Down

0 comments on commit 44741f3

Please sign in to comment.