Skip to content

Commit a7aed55

Browse files
authored
test: use backwards_compatible_rs_contract where appropriate (#9175)
`rs_contract` can be used by tests that run only on the latest protocol version, as defined by the const PROTOCOL_VERSION. `backwards_compatible_rs_contract` must be used in backwards compatibility tests that rely on specific protocol versions. This is a pre-requisite to land the rustc 1.70 toolchain upgrade. (See also #9140)
1 parent 733c1d9 commit a7aed55

File tree

12 files changed

+26
-19
lines changed

12 files changed

+26
-19
lines changed

integration-tests/src/tests/client/features/chunk_nodes_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn compare_node_counts() {
101101
deploy_test_contract(
102102
&mut env,
103103
"test0".parse().unwrap(),
104-
near_test_contracts::base_rs_contract(),
104+
near_test_contracts::backwards_compatible_rs_contract(),
105105
num_blocks,
106106
1,
107107
);

integration-tests/src/tests/client/features/flat_storage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn test_flat_storage_upgrade() {
4646
deploy_test_contract_with_protocol_version(
4747
&mut env,
4848
"test0".parse().unwrap(),
49-
near_test_contracts::base_rs_contract(),
49+
near_test_contracts::backwards_compatible_rs_contract(),
5050
blocks_to_process_txn,
5151
1,
5252
old_protocol_version,

integration-tests/src/tests/client/features/increase_storage_compute_cost.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ fn assert_compute_limit_reached(
207207
// setup: deploy the contract
208208
{
209209
// This contract has a bunch of methods to invoke storage operations.
210-
let code = near_test_contracts::rs_contract().to_vec();
210+
let code = near_test_contracts::backwards_compatible_rs_contract().to_vec();
211211
let actions = vec![Action::DeployContract(DeployContractAction { code })];
212212

213213
let signer = InMemorySigner::from_seed(

integration-tests/src/tests/client/features/lower_storage_key_limit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn protocol_upgrade() {
5656
deploy_test_contract_with_protocol_version(
5757
&mut env,
5858
"test0".parse().unwrap(),
59-
near_test_contracts::base_rs_contract(),
59+
near_test_contracts::backwards_compatible_rs_contract(),
6060
epoch_length,
6161
1,
6262
old_protocol_version,

integration-tests/src/tests/client/features/nearvm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn test_nearvm_upgrade() {
3636
deploy_test_contract(
3737
&mut env,
3838
"test0".parse().unwrap(),
39-
near_test_contracts::rs_contract(),
39+
near_test_contracts::backwards_compatible_rs_contract(),
4040
epoch_length,
4141
1,
4242
);

integration-tests/src/tests/client/process_blocks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ pub(crate) fn prepare_env_with_congestion(
199199
"test0".parse().unwrap(),
200200
&signer,
201201
vec![Action::DeployContract(DeployContractAction {
202-
code: near_test_contracts::base_rs_contract().to_vec(),
202+
code: near_test_contracts::backwards_compatible_rs_contract().to_vec(),
203203
})],
204204
*genesis_block.hash(),
205205
);

integration-tests/src/tests/client/sharding_upgrade.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ fn setup_test_env_with_cross_contract_txs(
639639
account_id.clone(),
640640
&signer,
641641
vec![Action::DeployContract(DeployContractAction {
642-
code: near_test_contracts::base_rs_contract().to_vec(),
642+
code: near_test_contracts::backwards_compatible_rs_contract().to_vec(),
643643
})],
644644
genesis_hash,
645645
)

pytest/lib/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def load_binary_file(filepath):
232232

233233

234234
def load_test_contract(
235-
filename: str = 'base_test_contract_rs.wasm') -> bytearray:
235+
filename: str = 'backwards_compatible_rs_contract.wasm') -> bytearray:
236236
"""Loads a WASM file from near-test-contracts package.
237237
238238
This is just a convenience function around load_binary_file which loads

runtime/near-test-contracts/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn sized_contract(size: usize) -> Vec<u8> {
4545
///
4646
/// Note: the contract relies on the latest stable protocol version, and might
4747
/// not work for tests using an older version. In particular, if a test depends
48-
/// on a specific protocol version, it should use [`base_rs_contract`].
48+
/// on a specific protocol version, it should use [`backwards_compatible_rs_contract`].
4949
pub fn rs_contract() -> &'static [u8] {
5050
include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/res/", "test_contract_rs.wasm"))
5151
}
@@ -65,9 +65,9 @@ pub fn rs_contract() -> &'static [u8] {
6565
/// enabled. So we have to build it with Rustc <= 1.69. If we need to update the
6666
/// contracts content, we can build it manually with an older compiler and check
6767
/// in the new WASM.
68-
pub fn base_rs_contract() -> &'static [u8] {
68+
pub fn backwards_compatible_rs_contract() -> &'static [u8] {
6969
static CONTRACT: OnceCell<Vec<u8>> = OnceCell::new();
70-
CONTRACT.get_or_init(|| read_contract("base_test_contract_rs.wasm")).as_slice()
70+
CONTRACT.get_or_init(|| read_contract("backwards_compatible_rs_contract.wasm")).as_slice()
7171
}
7272

7373
/// Standard test contract which additionally includes all host functions from
@@ -154,7 +154,7 @@ fn smoke_test() {
154154
assert!(!ts_contract().is_empty());
155155
assert!(!trivial_contract().is_empty());
156156
assert!(!fuzzing_contract().is_empty());
157-
assert!(!base_rs_contract().is_empty());
157+
assert!(!backwards_compatible_rs_contract().is_empty());
158158
assert!(!ft_contract().is_empty());
159159
}
160160

@@ -238,7 +238,7 @@ pub fn arbitrary_contract(seed: u64) -> Vec<u8> {
238238
config.exceptions_enabled = false;
239239
config.saturating_float_to_int_enabled = false;
240240
config.sign_extension_enabled = false;
241-
config.available_imports = Some(base_rs_contract().to_vec());
241+
config.available_imports = Some(backwards_compatible_rs_contract().to_vec());
242242
let module = wasm_smith::Module::new(config, &mut arbitrary).expect("generate module");
243243
module.to_bytes()
244244
}

0 commit comments

Comments
 (0)