From 78f5b94c0cffb2614a97e995b1b00b8a97e5a988 Mon Sep 17 00:00:00 2001 From: Mitch Turner Date: Mon, 16 Dec 2024 21:29:15 -0700 Subject: [PATCH] Fix algo compatibility test --- .../src/gas_price_algo_compatibility.rs | 41 ++++++++++--------- .../forkless-upgrade/src/tests_helper.rs | 31 ++++++++++++-- 2 files changed, 49 insertions(+), 23 deletions(-) diff --git a/version-compatibility/forkless-upgrade/src/gas_price_algo_compatibility.rs b/version-compatibility/forkless-upgrade/src/gas_price_algo_compatibility.rs index 11de191507d..a19a6ffdb30 100644 --- a/version-compatibility/forkless-upgrade/src/gas_price_algo_compatibility.rs +++ b/version-compatibility/forkless-upgrade/src/gas_price_algo_compatibility.rs @@ -35,7 +35,7 @@ async fn latest_gas_price_algorithm_is_compatible_with_ignition() { let hexed_secret = hex::encode(genesis_keypair.secret().to_bytes()); let genesis_port = "30333"; let starting_gas_price = 987; - let _ = Version36FuelCoreDriver::spawn(&[ + let old_driver = Version36FuelCoreDriver::spawn(&[ "--service-name", "GenesisProducer", "--debug", @@ -58,27 +58,31 @@ async fn latest_gas_price_algorithm_is_compatible_with_ignition() { let public_key = Keypair::from(genesis_keypair).public(); let genesis_peer_id = PeerId::from_public_key(&public_key); let genesis_multiaddr = default_multiaddr(genesis_port, genesis_peer_id); + let temp_dir = old_driver.kill().await; // Starting node that uses latest fuel core. // It will connect to the genesis node and sync blocks. let latest_keypair = SecpKeypair::generate(); let hexed_secret = hex::encode(latest_keypair.secret().to_bytes()); - let latest_node = LatestFuelCoreDriver::spawn(&[ - "--service-name", - "LatestValidator", - "--debug", - "--poa-instant", - "false", - "--snapshot", - IGNITION_TESTNET_SNAPSHOT, - "--enable-p2p", - "--keypair", - hexed_secret.as_str(), - "--reserved-nodes", - genesis_multiaddr.as_str(), - "--peering-port", - "0", - ]) + let latest_node = LatestFuelCoreDriver::spawn_with_directory( + temp_dir, + &[ + "--service-name", + "LatestValidator", + "--debug", + "--poa-instant", + "false", + "--snapshot", + IGNITION_TESTNET_SNAPSHOT, + "--enable-p2p", + "--keypair", + hexed_secret.as_str(), + "--reserved-nodes", + genesis_multiaddr.as_str(), + "--peering-port", + "0", + ], + ) .await .unwrap(); @@ -110,9 +114,6 @@ async fn latest_gas_price_algorithm_is_compatible_with_ignition() { else { panic!("Expected V1Metadata, got {:?}", metadata); }; - // assert!( - // matches!(metadata, UpdaterMetadata::V1(V1Metadata { new_scaled_exec_price, gas_price_factor, .. }) if new_scaled_exec_price == starting_gas_price * gas_price_factor.get()) - // ); assert_eq!( new_scaled_exec_price, starting_gas_price * gas_price_factor.get() diff --git a/version-compatibility/forkless-upgrade/src/tests_helper.rs b/version-compatibility/forkless-upgrade/src/tests_helper.rs index c48a1b512a1..d60e47e53e8 100644 --- a/version-compatibility/forkless-upgrade/src/tests_helper.rs +++ b/version-compatibility/forkless-upgrade/src/tests_helper.rs @@ -52,12 +52,17 @@ macro_rules! define_core_driver { impl $name { pub async fn spawn(extra_args: &[&str]) -> anyhow::Result { - use clap::Parser; use tempfile::tempdir; - - // Generate temp params let db_dir = tempdir()?; + Self::spawn_with_directory(db_dir, extra_args).await + } + pub async fn spawn_with_directory( + db_dir: tempfile::TempDir, + extra_args: &[&str], + ) -> anyhow::Result { + use clap::Parser; + let mut args = vec![ "_IGNORED_", "--db-path", @@ -103,6 +108,16 @@ define_core_driver!( true ); +impl Version36FuelCoreDriver { + pub async fn kill(self) -> tempfile::TempDir { + self.node + .send_stop_signal_and_await_shutdown() + .await + .expect("Failed to stop the node"); + self._db_dir + } +} + define_core_driver!( latest_fuel_core_bin, LatestFuelService, @@ -111,6 +126,16 @@ define_core_driver!( true ); +impl LatestFuelCoreDriver { + pub async fn kill(self) -> tempfile::TempDir { + self.node + .send_stop_signal_and_await_shutdown() + .await + .expect("Failed to stop the node"); + self._db_dir + } +} + pub const IGNITION_TESTNET_SNAPSHOT: &str = "./chain-configurations/ignition"; pub const V36_TESTNET_SNAPSHOT: &str = "./chain-configurations/v36"; pub const POA_SECRET_KEY: &str =