From 02bbad12861b58ada80e3f76b6f05d50d786f2b0 Mon Sep 17 00:00:00 2001 From: Frank Bell Date: Mon, 9 Dec 2024 17:44:25 +0000 Subject: [PATCH] refactor: use single constant --- crates/pop-parachains/src/call/metadata/action.rs | 3 +-- crates/pop-parachains/src/call/metadata/mod.rs | 4 +--- crates/pop-parachains/src/call/metadata/params.rs | 4 +--- crates/pop-parachains/src/call/mod.rs | 6 +++--- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/crates/pop-parachains/src/call/metadata/action.rs b/crates/pop-parachains/src/call/metadata/action.rs index 09e3a166..c4e0a97f 100644 --- a/crates/pop-parachains/src/call/metadata/action.rs +++ b/crates/pop-parachains/src/call/metadata/action.rs @@ -119,11 +119,10 @@ pub fn supported_actions(pallets: &[Pallet]) -> Vec { #[cfg(test)] mod tests { use super::*; - use crate::{parse_chain_metadata, set_up_client}; + use crate::{call::tests::POP_NETWORK_TESTNET_URL, parse_chain_metadata, set_up_client}; use anyhow::Result; use std::collections::HashMap; - const POP_NETWORK_TESTNET_URL: &str = "wss://rpc1.paseo.popnetwork.xyz"; const POLKADOT_NETWORK_URL: &str = "wss://polkadot-rpc.publicnode.com"; #[test] diff --git a/crates/pop-parachains/src/call/metadata/mod.rs b/crates/pop-parachains/src/call/metadata/mod.rs index 5d0f7641..a5cfde67 100644 --- a/crates/pop-parachains/src/call/metadata/mod.rs +++ b/crates/pop-parachains/src/call/metadata/mod.rs @@ -192,12 +192,10 @@ pub fn parse_extrinsic_arguments( mod tests { use super::*; - use crate::set_up_client; + use crate::{call::tests::POP_NETWORK_TESTNET_URL, set_up_client}; use anyhow::Result; use subxt::ext::scale_bits; - const POP_NETWORK_TESTNET_URL: &str = "wss://rpc1.paseo.popnetwork.xyz"; - #[tokio::test] async fn parse_chain_metadata_works() -> Result<()> { let client = set_up_client(POP_NETWORK_TESTNET_URL).await?; diff --git a/crates/pop-parachains/src/call/metadata/params.rs b/crates/pop-parachains/src/call/metadata/params.rs index 232e4d6b..23b69921 100644 --- a/crates/pop-parachains/src/call/metadata/params.rs +++ b/crates/pop-parachains/src/call/metadata/params.rs @@ -154,11 +154,9 @@ fn type_to_param(name: String, registry: &PortableRegistry, type_id: u32) -> Res #[cfg(test)] mod tests { use super::*; - use crate::set_up_client; + use crate::{call::tests::POP_NETWORK_TESTNET_URL, set_up_client}; use anyhow::Result; - const POP_NETWORK_TESTNET_URL: &str = "wss://rpc1.paseo.popnetwork.xyz"; - #[tokio::test] async fn field_to_param_works() -> Result<()> { let client = set_up_client(POP_NETWORK_TESTNET_URL).await?; diff --git a/crates/pop-parachains/src/call/mod.rs b/crates/pop-parachains/src/call/mod.rs index 1716b47a..b88e3378 100644 --- a/crates/pop-parachains/src/call/mod.rs +++ b/crates/pop-parachains/src/call/mod.rs @@ -137,7 +137,7 @@ mod tests { use anyhow::Result; const ALICE_SURI: &str = "//Alice"; - const POP_NETWORK_TESTNET_URL: &str = "wss://rpc1.paseo.popnetwork.xyz"; + pub(crate) const POP_NETWORK_TESTNET_URL: &str = "wss://rpc1.paseo.popnetwork.xyz"; #[tokio::test] async fn set_up_client_works() -> Result<()> { @@ -196,7 +196,7 @@ mod tests { #[tokio::test] async fn decode_call_data_works() -> Result<()> { assert!(matches!(decode_call_data("wrongcalldata"), Err(Error::CallDataDecodingError(..)))); - let client = set_up_client("wss://rpc1.paseo.popnetwork.xyz").await?; + let client = set_up_client(POP_NETWORK_TESTNET_URL).await?; let pallets = parse_chain_metadata(&client)?; let remark = find_extrinsic_by_name(&pallets, "System", "remark")?; let extrinsic = construct_extrinsic("System", &remark, vec!["0x11".to_string()])?; @@ -225,7 +225,7 @@ mod tests { #[tokio::test] async fn construct_sudo_extrinsic_works() -> Result<()> { - let client = set_up_client("wss://rpc1.paseo.popnetwork.xyz").await?; + let client = set_up_client(POP_NETWORK_TESTNET_URL).await?; let pallets = parse_chain_metadata(&client)?; let force_transfer = find_extrinsic_by_name(&pallets, "Balances", "force_transfer")?; let extrinsic = construct_extrinsic(