From fc705894b34ab9224911f16d0d160ab97b252a89 Mon Sep 17 00:00:00 2001 From: Richard Melkonian Date: Tue, 29 Jul 2025 15:49:00 +0100 Subject: [PATCH 1/2] feat: migrate-resource-post-rotation --- networks/movement/movement-client/Cargo.toml | 5 ++ .../src/bin/e2e/cli_key_rotation_resource.rs | 67 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 networks/movement/movement-client/src/bin/e2e/cli_key_rotation_resource.rs diff --git a/networks/movement/movement-client/Cargo.toml b/networks/movement/movement-client/Cargo.toml index 2f72744d5..3ffb7c6b1 100644 --- a/networks/movement/movement-client/Cargo.toml +++ b/networks/movement/movement-client/Cargo.toml @@ -58,6 +58,11 @@ path = "src/bin/e2e/key_rotation.rs" name = "movement-tests-sequence-number-ooo" path = "src/bin/e2e/sequence_number_ooo.rs" +[[bin]] +name = "movement-tests-cli-key-rotation-resource" +path = "src/bin/e2e/cli_key_rotation_resource.rs" + + [dependencies] aptos-language-e2e-tests = { workspace = true } aptos-sdk = { workspace = true } diff --git a/networks/movement/movement-client/src/bin/e2e/cli_key_rotation_resource.rs b/networks/movement/movement-client/src/bin/e2e/cli_key_rotation_resource.rs new file mode 100644 index 000000000..e7cd10aaa --- /dev/null +++ b/networks/movement/movement-client/src/bin/e2e/cli_key_rotation_resource.rs @@ -0,0 +1,67 @@ +use aptos_sdk::types::account_address::AccountAddress; +/// The key_rotation.rs test tests the basic functionality of key rotation works as expected. +/// It essnetially makes the calls that the CLI cmd `movement account rotate-key` abstracts away. +/// This test makes checks the CLI level and checks on the existence of resource pre and post +/// rotation. And demonstrates the correct approach on how to correctly migrate resources and +/// balances for an account prior to key rotation. Failure to rotate resources will render them +/// unnaccessable after a key has been rotated out. +use aptos_sdk::{coin_client::CoinClient, rest_client::Client}; +use once_cell::sync::Lazy; +use std::str::FromStr; +use tracing_subscriber::EnvFilter; +use url::Url; + +static SUZUKA_CONFIG: Lazy = Lazy::new(|| { + let dot_movement = dot_movement::DotMovement::try_from_env().unwrap(); + dot_movement.try_get_config_from_json::().unwrap() +}); + +static NODE_URL: Lazy = Lazy::new(|| { + let node_connection_address = SUZUKA_CONFIG + .execution_config + .maptos_config + .client + .maptos_rest_connection_hostname + .clone(); + let node_connection_port = + SUZUKA_CONFIG.execution_config.maptos_config.client.maptos_rest_connection_port; + let node_connection_url = + format!("http://{}:{}", node_connection_address, node_connection_port); + Url::from_str(&node_connection_url).unwrap() +}); + +static FAUCET_URL: Lazy = Lazy::new(|| { + let faucet_listen_address = SUZUKA_CONFIG + .execution_config + .maptos_config + .client + .maptos_faucet_rest_connection_hostname + .clone(); + let faucet_listen_port = SUZUKA_CONFIG + .execution_config + .maptos_config + .client + .maptos_faucet_rest_connection_port; + + let faucet_listen_url = format!("http://{}:{}", faucet_listen_address, faucet_listen_port); + + Url::from_str(faucet_listen_url.as_str()).unwrap() +}); + +const ACCOUNT_ADDRESS: &str = "0xd1126ce48bd65fb72190dbd9a6eaa65ba973f1e1664ac0cfba4db1d071fd0c36"; + +#[tokio::main] +async fn main() -> Result<(), anyhow::Error> { + tracing_subscriber::fmt() + .with_env_filter( + EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")), + ) + .init(); + + let rest_client = Client::new(NODE_URL.clone()); + let account = AccountAddress::from_hex_literal(ACCOUNT_ADDRESS)?; + + let res = rest_client.get_account_resources(account).await?; + println!("{:#?}", res); + Ok(()) +} From 384ae015f08fc4eaeb45f0f83af200479067d9d9 Mon Sep 17 00:00:00 2001 From: Richard Melkonian Date: Tue, 29 Jul 2025 15:52:14 +0100 Subject: [PATCH 2/2] chore: define process-compose test file --- .../src/bin/e2e/key_rotation.rs | 1 - ...ose.test-migrate-resource-key-rotation.yml | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 process-compose/movement-full-node/process-compose.test-migrate-resource-key-rotation.yml diff --git a/networks/movement/movement-client/src/bin/e2e/key_rotation.rs b/networks/movement/movement-client/src/bin/e2e/key_rotation.rs index 1417313a9..31881bc36 100644 --- a/networks/movement/movement-client/src/bin/e2e/key_rotation.rs +++ b/networks/movement/movement-client/src/bin/e2e/key_rotation.rs @@ -119,7 +119,6 @@ async fn main() -> Result<(), anyhow::Error> { // Generate recipient account let recipient = LocalAccount::generate(&mut rand::rngs::OsRng); - faucet_client.fund(recipient.address(), 100_000_000_000).await?; let recipient_bal = coin_client diff --git a/process-compose/movement-full-node/process-compose.test-migrate-resource-key-rotation.yml b/process-compose/movement-full-node/process-compose.test-migrate-resource-key-rotation.yml new file mode 100644 index 000000000..9dd8c6a7a --- /dev/null +++ b/process-compose/movement-full-node/process-compose.test-migrate-resource-key-rotation.yml @@ -0,0 +1,23 @@ +version: "3" + +environment: + +processes: + + setup: + environment: + - APTOS_ACCOUNT_WHITELIST=$DOT_MOVEMENT_PATH/default_signer_address_whitelist + - MAPTOS_PRIVATE_KEY=random + + movement-faucet: + command : | + movement-faucet-service run-simple --do-not-delegate + + test-key-rotation: + command : | + cargo run --bin movement-tests-cli-key-rotation-resource + depends_on: + movement-full-node: + condition: process_healthy + movement-faucet: + condition: process_healthy