From 280689e4c8cf2bf533542f6a5de30bb76adf3c15 Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Wed, 6 Sep 2023 10:15:56 +0100 Subject: [PATCH] fix tests --- chain/chain/src/tests/simple_chain.rs | 4 ++-- integration-tests/src/tests/client/process_blocks.rs | 7 ++++--- integration-tests/src/tests/client/state_dump.rs | 6 +++--- .../src/tests/runtime/test_evil_contracts.rs | 12 ++++++------ integration-tests/src/tests/standard_cases/mod.rs | 9 +++++++-- runtime/runtime/src/actions.rs | 2 +- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/chain/chain/src/tests/simple_chain.rs b/chain/chain/src/tests/simple_chain.rs index a5e51a7dbaa..4b875f0a846 100644 --- a/chain/chain/src/tests/simple_chain.rs +++ b/chain/chain/src/tests/simple_chain.rs @@ -48,7 +48,7 @@ fn build_chain() { // cargo insta test --accept -p near-chain --features nightly -- tests::simple_chain::build_chain let hash = chain.head().unwrap().last_block_hash; if cfg!(feature = "nightly") { - insta::assert_display_snapshot!(hash, @"GargNTMFiuET32KH5uPLFwMSU8xXtvrk6aGqgkPbRZg8"); + insta::assert_display_snapshot!(hash, @"CwaiZ4AmfJSnMN9rytYwwYHCTzLioC5xcjHzNkDex1HH"); } else { insta::assert_display_snapshot!(hash, @"712T4sPbJhNWWN3bWweccECGYWbnUmGpqpKW2SJpb2k5"); } @@ -78,7 +78,7 @@ fn build_chain() { let hash = chain.head().unwrap().last_block_hash; if cfg!(feature = "nightly") { - insta::assert_display_snapshot!(hash, @"2aurKZqRfPkZ3woNjA7Kf79wq5MYz98AohTYWoBFiG7o"); + insta::assert_display_snapshot!(hash, @"Dn18HUFm149fojXpwV1dYCfjdPh56S1k233kp7vmnFeE"); } else { insta::assert_display_snapshot!(hash, @"GUAPgvPQQmhumyuFzPusg3BKtRkVLpCw4asTAWgdTLq6"); } diff --git a/integration-tests/src/tests/client/process_blocks.rs b/integration-tests/src/tests/client/process_blocks.rs index f39b25d42c3..8c80f90f818 100644 --- a/integration-tests/src/tests/client/process_blocks.rs +++ b/integration-tests/src/tests/client/process_blocks.rs @@ -2296,10 +2296,11 @@ fn test_data_reset_before_state_sync() { let signer = InMemorySigner::from_seed("test0".parse().unwrap(), KeyType::ED25519, "test0"); let genesis_block = env.clients[0].chain.get_block_by_height(0).unwrap(); let genesis_hash = *genesis_block.hash(); + let new_account_id: AccountId = "test_account.test0".parse().unwrap(); let tx = SignedTransaction::create_account( 1, "test0".parse().unwrap(), - "test_account".parse().unwrap(), + new_account_id.clone(), NEAR_BASE, signer.public_key(), &signer, @@ -2322,7 +2323,7 @@ fn test_data_reset_before_state_sync() { &head.prev_block_hash, &head.last_block_hash, head_block.header().epoch_id(), - &QueryRequest::ViewAccount { account_id: "test_account".parse().unwrap() }, + &QueryRequest::ViewAccount { account_id: new_account_id.clone() }, ) .unwrap(); assert_matches!(response.kind, QueryResponseKind::ViewAccount(_)); @@ -2336,7 +2337,7 @@ fn test_data_reset_before_state_sync() { &head.prev_block_hash, &head.last_block_hash, head_block.header().epoch_id(), - &QueryRequest::ViewAccount { account_id: "test_account".parse().unwrap() }, + &QueryRequest::ViewAccount { account_id: new_account_id }, ); // TODO(#3742): ViewClient still has data in cache by current design. assert!(response.is_ok()); diff --git a/integration-tests/src/tests/client/state_dump.rs b/integration-tests/src/tests/client/state_dump.rs index 6dae1ce2db5..213577f672b 100644 --- a/integration-tests/src/tests/client/state_dump.rs +++ b/integration-tests/src/tests/client/state_dump.rs @@ -229,7 +229,7 @@ fn run_state_sync_with_dumped_parts( let tx = SignedTransaction::create_account( 1, "test0".parse().unwrap(), - "test_account".parse().unwrap(), + "test_account.test0".parse().unwrap(), NEAR_BASE, signer.public_key(), &signer, @@ -256,7 +256,7 @@ fn run_state_sync_with_dumped_parts( &head.prev_block_hash, &head.last_block_hash, head_block.header().epoch_id(), - &QueryRequest::ViewAccount { account_id: "test_account".parse().unwrap() }, + &QueryRequest::ViewAccount { account_id: "test_account.test0".parse().unwrap() }, ) .unwrap(); assert_matches!(response.kind, QueryResponseKind::ViewAccount(_)); @@ -360,7 +360,7 @@ fn run_state_sync_with_dumped_parts( &synced_block_tip.prev_block_hash, &synced_block_tip.last_block_hash, synced_block_header.epoch_id(), - &QueryRequest::ViewAccount { account_id: "test_account".parse().unwrap() }, + &QueryRequest::ViewAccount { account_id: "test_account.test0".parse().unwrap() }, ); if is_final_block_in_new_epoch { diff --git a/integration-tests/src/tests/runtime/test_evil_contracts.rs b/integration-tests/src/tests/runtime/test_evil_contracts.rs index e6c11c6783f..98f78a8f0a2 100644 --- a/integration-tests/src/tests/runtime/test_evil_contracts.rs +++ b/integration-tests/src/tests/runtime/test_evil_contracts.rs @@ -21,7 +21,7 @@ fn setup_test_contract(wasm_binary: &[u8]) -> RuntimeNode { let transaction_result = node_user .create_account( account_id, - "test_contract".parse().unwrap(), + "test_contract.alice.near".parse().unwrap(), node.signer().public_key(), TESTING_INIT_BALANCE / 2, ) @@ -30,7 +30,7 @@ fn setup_test_contract(wasm_binary: &[u8]) -> RuntimeNode { assert_eq!(transaction_result.receipts_outcome.len(), 2); let transaction_result = - node_user.deploy_contract("test_contract".parse().unwrap(), wasm_binary.to_vec()).unwrap(); + node_user.deploy_contract("test_contract.alice.near".parse().unwrap(), wasm_binary.to_vec()).unwrap(); assert_eq!(transaction_result.status, FinalExecutionStatus::SuccessValue(Vec::new())); assert_eq!(transaction_result.receipts_outcome.len(), 1); @@ -51,7 +51,7 @@ fn test_evil_deep_trie() { .user() .function_call( "alice.near".parse().unwrap(), - "test_contract".parse().unwrap(), + "test_contract.alice.near".parse().unwrap(), "insert_strings", input_data.to_vec(), MAX_GAS, @@ -72,7 +72,7 @@ fn test_evil_deep_trie() { .user() .function_call( "alice.near".parse().unwrap(), - "test_contract".parse().unwrap(), + "test_contract.alice.near".parse().unwrap(), "delete_strings", input_data.to_vec(), MAX_GAS, @@ -94,7 +94,7 @@ fn test_evil_deep_recursion() { .user() .function_call( "alice.near".parse().unwrap(), - "test_contract".parse().unwrap(), + "test_contract.alice.near".parse().unwrap(), "recurse", n_bytes.clone(), MAX_GAS, @@ -116,7 +116,7 @@ fn test_evil_abort() { .user() .function_call( "alice.near".parse().unwrap(), - "test_contract".parse().unwrap(), + "test_contract.alice.near".parse().unwrap(), "abort_with_zero", vec![], MAX_GAS, diff --git a/integration-tests/src/tests/standard_cases/mod.rs b/integration-tests/src/tests/standard_cases/mod.rs index d4100656990..adc2155847b 100644 --- a/integration-tests/src/tests/standard_cases/mod.rs +++ b/integration-tests/src/tests/standard_cases/mod.rs @@ -674,12 +674,17 @@ pub fn test_create_top_level_account(node: impl Node) { "0x5e97870f263700f46aa00d967821199b9bc5a120", "0x0000000000000000000000000000000000000000", "alice", - "thisisaveryverylongtoplevelaccount" + "thisisaveryverylongtoplevelaccount", ]; for (_, id) in top_level_accounts.iter().enumerate() { let new_account_id = id.parse::().unwrap(); let transaction_result = node_user - .create_account(account_id.clone(), new_account_id.clone(), node.signer().public_key(), 0) + .create_account( + account_id.clone(), + new_account_id.clone(), + node.signer().public_key(), + 0, + ) .unwrap(); assert_eq!( transaction_result.status, diff --git a/runtime/runtime/src/actions.rs b/runtime/runtime/src/actions.rs index ab90d862420..3a42fbfff9a 100644 --- a/runtime/runtime/src/actions.rs +++ b/runtime/runtime/src/actions.rs @@ -1095,7 +1095,7 @@ mod tests { "0x32400084c286cf3e17e7b677ea9583e60a000324", "thisisaveryverylongtoplevelaccount", "32400084c286cf3e17e7b677ea9583e60a000324", - "000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000", ]; for id in &account_ids { let account_id: AccountId = id.parse().unwrap();