Skip to content

Commit

Permalink
Fix algo compatibility test
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchTurner committed Dec 17, 2024
1 parent 2f8100f commit 78f5b94
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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();

Expand Down Expand Up @@ -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()
Expand Down
31 changes: 28 additions & 3 deletions version-compatibility/forkless-upgrade/src/tests_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,17 @@ macro_rules! define_core_driver {

impl $name {
pub async fn spawn(extra_args: &[&str]) -> anyhow::Result<Self> {
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<Self> {
use clap::Parser;

let mut args = vec![
"_IGNORED_",
"--db-path",
Expand Down Expand Up @@ -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,
Expand All @@ -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 =
Expand Down

0 comments on commit 78f5b94

Please sign in to comment.