diff --git a/Cargo.lock b/Cargo.lock index 6bcde5bb8..71cc5f097 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3830,9 +3830,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libloading" @@ -7045,6 +7045,7 @@ dependencies = [ "frame-support", "futures 0.3.28", "jsonrpsee", + "libc", "log", "module-oracle-rpc-runtime-api", "oracle", @@ -7064,7 +7065,6 @@ dependencies = [ "spacewalk-standalone", "substrate-stellar-sdk", "subxt 0.25.0", - "subxt-client", "tempdir", "thiserror", "tokio", @@ -11092,6 +11092,7 @@ dependencies = [ "jsonrpc-core", "jsonrpc-core-client", "lazy_static", + "libc", "mockall 0.8.3", "nonzero_ext", "ntest", diff --git a/clients/runtime/Cargo.toml b/clients/runtime/Cargo.toml index e06b84ccc..e014fae57 100644 --- a/clients/runtime/Cargo.toml +++ b/clients/runtime/Cargo.toml @@ -15,11 +15,11 @@ testing-utils = [ "rand", "testchain", "testchain-runtime", - "subxt-client", "oracle" ] [dependencies] +libc = "0.2.150" async-trait = "0.1.40" backoff = { version = "0.3.0", features = ["tokio"] } cfg-if = "1.0" @@ -45,8 +45,6 @@ sp-version = { git = "https://github.com/paritytech/substrate", branch = "polkad # Subxt dependencies subxt = "0.25.0" jsonrpsee = { version = "0.16.0", features = ["macros", "jsonrpsee-types", "client", "jsonrpsee-ws-client", "jsonrpsee-client-transport"] } -# Used for performing the integration tests -subxt-client = { path = "./client", optional = true } # Needed for the `BalanceWrapper` struct module-oracle-rpc-runtime-api = { path = "../../pallets/oracle/rpc/runtime-api" } diff --git a/clients/runtime/src/integration/mod.rs b/clients/runtime/src/integration/mod.rs index 148a72d38..039456edb 100644 --- a/clients/runtime/src/integration/mod.rs +++ b/clients/runtime/src/integration/mod.rs @@ -1,10 +1,16 @@ #![cfg(feature = "testing-utils")] -use std::{sync::Arc, time::Duration}; +use std::{ + os::unix::process::CommandExt, + process::{Child, Command, Stdio}, + sync::Arc, + time::Duration, +}; use frame_support::assert_ok; use futures::{future::Either, pin_mut, Future, FutureExt, SinkExt, StreamExt}; use oracle::dia::{DiaOracleKeyConvertor, NativeCurrencyKey, XCMCurrencyConversion}; +use sp_keyring::AccountKeyring; use sp_runtime::traits::Convert; use subxt::{ events::StaticEvent as Event, @@ -13,15 +19,9 @@ use subxt::{ use tempdir::TempDir; use tokio::{sync::RwLock, time::timeout}; -pub use subxt_client::SubxtClient; -use subxt_client::{ - AccountKeyring, DatabaseSource, KeystoreConfig, Role, SubxtClientConfig, WasmExecutionMethod, - WasmtimeInstantiationStrategy, -}; - use crate::{ rpc::{OraclePallet, VaultRegistryPallet}, - CurrencyId, FixedU128, SpacewalkParachain, SpacewalkSigner, + CurrencyId, FixedU128, SpacewalkParachain, SpacewalkSigner, SudoPallet, }; use primitives::oracle::Key as OracleKey; @@ -54,55 +54,41 @@ impl XCMCurrencyConversion for MockValue { } } +fn get_pair_from_keyring(keyring: AccountKeyring) -> Result { + let pair = Pair::from_string(keyring.to_seed().as_str(), None) + .map_err(|_| "Could not create pair for keyring")?; + Ok(pair) +} + /// Start a new instance of the parachain. The second item in the returned tuple must remain in /// scope as long as the parachain is active, since dropping it will remove the temporary directory /// that the parachain uses -pub async fn default_provider_client(key: AccountKeyring) -> (SubxtClient, TempDir) { +pub async fn default_root_provider(key: AccountKeyring) -> (SpacewalkParachain, TempDir) { let tmp = TempDir::new("spacewalk-parachain-").expect("failed to create tempdir"); - let config = SubxtClientConfig { - impl_name: "spacewalk-parachain-full-client", - impl_version: "0.0.1", - author: "SatoshiPay", - copyright_start_year: 2020, - db: DatabaseSource::ParityDb { path: tmp.path().join("db") }, - keystore: KeystoreConfig::Path { path: tmp.path().join("keystore"), password: None }, - chain_spec: testchain::chain_spec::development_config(), - role: Role::Authority(key), - telemetry: None, - wasm_method: WasmExecutionMethod::Compiled { - instantiation_strategy: WasmtimeInstantiationStrategy::LegacyInstanceReuse, - }, - tokio_handle: tokio::runtime::Handle::current(), - }; - - // enable off chain workers - let mut service_config = config.into_service_config(); - service_config.offchain_worker.enabled = true; - - let (task_manager, rpc_handlers) = - testchain::service::start_instant(service_config).await.unwrap(); - - let client = SubxtClient::new(task_manager, rpc_handlers); - - (client, tmp) -} + let root_provider = setup_provider(key).await; -fn get_pair_from_keyring(keyring: AccountKeyring) -> Result { - let pair = Pair::from_string(keyring.to_seed().as_str(), None) - .map_err(|_| "Could not create pair for keyring")?; - Ok(pair) + if let Err(e) = root_provider.set_parachain_confirmations(1).await { + log::warn!("default_root_provider(): ERROR: {e:?}"); + } + + (root_provider, tmp) } /// Create a new parachain_rpc with the given keyring -pub async fn setup_provider(client: SubxtClient, key: AccountKeyring) -> SpacewalkParachain { +pub async fn setup_provider(key: AccountKeyring) -> SpacewalkParachain { let pair = get_pair_from_keyring(key).unwrap(); let signer = SpacewalkSigner::new(pair); let signer = Arc::new(RwLock::new(signer)); let shutdown_tx = crate::ShutdownSender::new(); - - SpacewalkParachain::new(client.into(), signer, shutdown_tx) - .await - .expect("Error creating parachain_rpc") + let parachain_rpc = SpacewalkParachain::from_url_with_retry( + &"ws://127.0.0.1:9944".to_string(), + signer.clone(), + Duration::from_secs(20), + shutdown_tx, + ) + .await + .unwrap(); + parachain_rpc } pub async fn set_exchange_rate_and_wait( @@ -185,3 +171,19 @@ pub async fn periodically_produce_blocks(parachain_rpc: SpacewalkParachain) { parachain_rpc.manual_seal().await; } } + +pub async fn start_chain() -> std::io::Result { + unsafe { + Command::new("sh") + .arg("./scripts/run_parachain_node.sh") + .stdout(Stdio::inherit()) + .stderr(Stdio::inherit()) + .pre_exec(|| { + // Create a new session and set the process group ID + // Used for deleting all the processes spawned when starting the chain + libc::setsid(); + Ok(()) + }) + .spawn() + } +} diff --git a/clients/runtime/src/tests.rs b/clients/runtime/src/tests.rs index 18029d4db..37c73161a 100644 --- a/clients/runtime/src/tests.rs +++ b/clients/runtime/src/tests.rs @@ -26,8 +26,8 @@ fn dummy_public_key() -> StellarPublicKeyRaw { [0u8; 32] } -async fn set_exchange_rate(client: SubxtClient) { - let oracle_provider = setup_provider(client, AccountKeyring::Bob).await; +async fn set_exchange_rate() { + let oracle_provider = setup_provider(AccountKeyring::Bob).await; let key = primitives::oracle::Key::ExchangeRate(DEFAULT_TESTING_CURRENCY); let converted_key = DiaOracleKeyConvertor::::convert(key.clone()).unwrap(); let exchange_rate = FixedU128::saturating_from_rational(1u128, 100u128); @@ -39,8 +39,7 @@ async fn set_exchange_rate(client: SubxtClient) { #[tokio::test(flavor = "multi_thread")] async fn test_getters() { - let (client, _tmp_dir) = default_provider_client(AccountKeyring::Alice).await; - let parachain_rpc = setup_provider(client.clone(), AccountKeyring::Alice).await; + let (parachain_rpc, _tmp_dir) = default_root_provider(AccountKeyring::Alice).await; tokio::join!( async { @@ -62,8 +61,7 @@ async fn test_getters() { #[ignore] #[tokio::test(flavor = "multi_thread")] async fn test_invalid_tx_matching() { - let (client, _tmp_dir) = default_provider_client(AccountKeyring::Alice).await; - let parachain_rpc = setup_provider(client.clone(), AccountKeyring::Alice).await; + let (parachain_rpc, _tmp_dir) = default_root_provider(AccountKeyring::Alice).await; let err = parachain_rpc.get_invalid_tx_error(AccountKeyring::Bob.into()).await; assert!(err.is_invalid_transaction().is_some()) } @@ -71,18 +69,17 @@ async fn test_invalid_tx_matching() { #[ignore] #[tokio::test(flavor = "multi_thread")] async fn test_too_low_priority_matching() { - let (client, _tmp_dir) = default_provider_client(AccountKeyring::Alice).await; - let parachain_rpc = setup_provider(client.clone(), AccountKeyring::Alice).await; + let (parachain_rpc, _tmp_dir) = default_root_provider(AccountKeyring::Alice).await; let err = parachain_rpc.get_too_low_priority_error(AccountKeyring::Bob.into()).await; assert!(err.is_pool_too_low_priority().is_some()) } #[tokio::test(flavor = "multi_thread")] async fn test_subxt_processing_events_after_dispatch_error() { - let (client, _tmp_dir) = default_provider_client(AccountKeyring::Alice).await; + let (_, _tmp_dir) = default_root_provider(AccountKeyring::Alice).await; - let oracle_provider = setup_provider(client.clone(), AccountKeyring::Bob).await; - let invalid_oracle = setup_provider(client, AccountKeyring::Dave).await; + let oracle_provider = setup_provider( AccountKeyring::Bob).await; + let invalid_oracle = setup_provider(AccountKeyring::Dave).await; let key = primitives::oracle::Key::ExchangeRate(DEFAULT_TESTING_CURRENCY); let converted_key = DiaOracleKeyConvertor::::convert(key.clone()).unwrap(); @@ -100,9 +97,8 @@ async fn test_subxt_processing_events_after_dispatch_error() { #[tokio::test(flavor = "multi_thread")] async fn test_register_vault() { - let (client, _tmp_dir) = default_provider_client(AccountKeyring::Alice).await; - let parachain_rpc = setup_provider(client.clone(), AccountKeyring::Alice).await; - set_exchange_rate(client.clone()).await; + let (parachain_rpc, _tmp_dir) = default_root_provider(AccountKeyring::Alice).await; + set_exchange_rate().await; let vault_id = VaultId::new( AccountKeyring::Alice.into(), diff --git a/clients/vault/Cargo.toml b/clients/vault/Cargo.toml index bd7155feb..916a12666 100644 --- a/clients/vault/Cargo.toml +++ b/clients/vault/Cargo.toml @@ -20,6 +20,7 @@ parachain-metadata-foucoco = ["runtime/parachain-metadata-foucoco"] integration-test = ["runtime/standalone-metadata", "integration"] [dependencies] +libc = "0.2.150" async-trait = "0.1.40" base64 = { version = '0.13.0', default-features = false, features = ['alloc'] } bincode = "1.3.3" diff --git a/clients/vault/scripts/run_parachain_node.sh b/clients/vault/scripts/run_parachain_node.sh new file mode 100644 index 000000000..5343e6d26 --- /dev/null +++ b/clients/vault/scripts/run_parachain_node.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd ../.. +cargo run --bin spacewalk-standalone --release -- --dev \ No newline at end of file diff --git a/clients/vault/tests/helper/helper.rs b/clients/vault/tests/helper/helper.rs index a5ad5a5fa..98140cb2f 100644 --- a/clients/vault/tests/helper/helper.rs +++ b/clients/vault/tests/helper/helper.rs @@ -3,9 +3,7 @@ use async_trait::async_trait; use frame_support::assert_ok; use primitives::{stellar::Asset as StellarAsset, CurrencyId, StellarStroops, H256}; use runtime::{ - integration::{ - assert_event, get_required_vault_collateral_for_issue, setup_provider, SubxtClient, - }, + integration::{assert_event, get_required_vault_collateral_for_issue, setup_provider}, stellar::SecretKey, ExecuteRedeemEvent, IssuePallet, SpacewalkParachain, VaultId, VaultRegistryPallet, }; @@ -44,13 +42,12 @@ pub trait SpacewalkParachainExt: VaultRegistryPallet { } pub async fn create_vault( - client: SubxtClient, account: AccountKeyring, wrapped_currency: CurrencyId, ) -> (VaultId, SpacewalkParachain) { let vault_id = VaultId::new(account.clone().into(), DEFAULT_TESTING_CURRENCY, wrapped_currency); - let vault_provider = setup_provider(client, account).await; + let vault_provider = setup_provider(account).await; (vault_id, vault_provider) } diff --git a/clients/vault/tests/helper/mod.rs b/clients/vault/tests/helper/mod.rs index 1cd84a33b..a27446544 100644 --- a/clients/vault/tests/helper/mod.rs +++ b/clients/vault/tests/helper/mod.rs @@ -8,15 +8,19 @@ use async_trait::async_trait; use lazy_static::lazy_static; use primitives::CurrencyId; use runtime::{ - integration::{ - default_provider_client, set_exchange_rate_and_wait, setup_provider, SubxtClient, - }, + integration::{default_root_provider, set_exchange_rate_and_wait, setup_provider, start_chain}, types::FixedU128, SpacewalkParachain, VaultId, }; use sp_arithmetic::FixedPointNumber; use sp_keyring::AccountKeyring; -use std::{future::Future, sync::Arc}; +use std::{ + future::Future, + io, + panic::{self, AssertUnwindSafe}, + process::Child, + sync::Arc, +}; use stellar_relay_lib::StellarOverlayConfig; use tokio::sync::RwLock; use vault::{ @@ -38,16 +42,14 @@ lazy_static! { impl SpacewalkParachainExt for SpacewalkParachain {} pub async fn test_with( - execute: impl FnOnce(SubxtClient, ArcRwLock, ArcRwLock) -> F, + execute: impl FnOnce(ArcRwLock, ArcRwLock) -> F, ) -> R where F: Future, { service::init_subscriber(); - let (client, tmp_dir) = default_provider_client(AccountKeyring::Alice).await; - // Has to be Bob because he is set as `authorized_oracle` in the genesis config - let parachain_rpc = setup_provider(client.clone(), AccountKeyring::Bob).await; + let (parachain_rpc, tmp_dir) = default_root_provider(AccountKeyring::Bob).await; set_exchange_rate_and_wait( ¶chain_rpc, @@ -99,12 +101,11 @@ where .unwrap(), )); - execute(client, vault_wallet, user_wallet).await + execute(vault_wallet, user_wallet).await } pub async fn test_with_vault( execute: impl FnOnce( - SubxtClient, ArcRwLock, ArcRwLock, Arc, @@ -115,70 +116,103 @@ pub async fn test_with_vault( where F: Future, { - service::init_subscriber(); - let (client, tmp_dir) = default_provider_client(AccountKeyring::Alice).await; - - let parachain_rpc = setup_provider(client.clone(), AccountKeyring::Bob).await; - set_exchange_rate_and_wait( - ¶chain_rpc, - DEFAULT_TESTING_CURRENCY, - FixedU128::saturating_from_rational(1u128, 1u128), - ) - .await; - set_exchange_rate_and_wait( - ¶chain_rpc, - DEFAULT_WRAPPED_CURRENCY, - // Set exchange rate to 10:1 with USD - FixedU128::saturating_from_rational(1u128, 10u128), - ) - .await; - - set_exchange_rate_and_wait( - ¶chain_rpc, - LESS_THAN_4_CURRENCY_CODE, - // Set exchange rate to 100:1 with USD - FixedU128::saturating_from_rational(1u128, 10u128), - ) - .await; - - set_exchange_rate_and_wait( - ¶chain_rpc, - CurrencyId::StellarNative, - // Set exchange rate to 10:1 with USD - FixedU128::saturating_from_rational(1u128, 10u128), - ) - .await; - - let vault_provider = setup_provider(client.clone(), AccountKeyring::Charlie).await; - let vault_id = VaultId::new( - AccountKeyring::Charlie.into(), - DEFAULT_TESTING_CURRENCY, - DEFAULT_WRAPPED_CURRENCY, - ); - - let path = tmp_dir.path().to_str().expect("should return a string").to_string(); - let vault_wallet = Arc::new(RwLock::new( - StellarWallet::from_secret_encoded_with_cache( - &SECRET_KEY, - CFG.is_public_network(), - path.clone(), - ) - .unwrap(), - )); - - let user_wallet = Arc::new(RwLock::new( - StellarWallet::from_secret_encoded_with_cache( - &DESTINATION_SECRET_KEY, - CFG.is_public_network(), - path, - ) - .unwrap(), - )); - - let oracle_agent = start_oracle_agent(CFG.clone(), &SECRET_KEY) - .await - .expect("failed to start agent"); - let oracle_agent = Arc::new(oracle_agent); + let parachain_runner = start_chain().await.expect("Failed to start chain"); + + // Take the PGID when the test starts running and execute the following command to check the processes spawned: + // ps -o pid,pgid,command -g + println!("PGID: {}", parachain_runner.id()); + + let result = panic::catch_unwind(AssertUnwindSafe(|| { + futures::executor::block_on(async { + service::init_subscriber(); + let (parachain_rpc, tmp_dir) = default_root_provider(AccountKeyring::Bob).await; + + set_exchange_rate_and_wait( + ¶chain_rpc, + DEFAULT_TESTING_CURRENCY, + FixedU128::saturating_from_rational(1u128, 1u128), + ) + .await; + set_exchange_rate_and_wait( + ¶chain_rpc, + DEFAULT_WRAPPED_CURRENCY, + // Set exchange rate to 10:1 with USD + FixedU128::saturating_from_rational(1u128, 10u128), + ) + .await; + + set_exchange_rate_and_wait( + ¶chain_rpc, + LESS_THAN_4_CURRENCY_CODE, + // Set exchange rate to 100:1 with USD + FixedU128::saturating_from_rational(1u128, 10u128), + ) + .await; + + set_exchange_rate_and_wait( + ¶chain_rpc, + CurrencyId::StellarNative, + // Set exchange rate to 10:1 with USD + FixedU128::saturating_from_rational(1u128, 10u128), + ) + .await; + + let vault_provider = setup_provider(AccountKeyring::Charlie).await; + let vault_id = VaultId::new( + AccountKeyring::Charlie.into(), + DEFAULT_TESTING_CURRENCY, + DEFAULT_WRAPPED_CURRENCY, + ); + + let path = tmp_dir.path().to_str().expect("should return a string").to_string(); + let vault_wallet = Arc::new(RwLock::new( + StellarWallet::from_secret_encoded_with_cache( + &SECRET_KEY, + CFG.is_public_network(), + path.clone(), + ) + .unwrap(), + )); + + let user_wallet = Arc::new(RwLock::new( + StellarWallet::from_secret_encoded_with_cache( + &DESTINATION_SECRET_KEY, + CFG.is_public_network(), + path, + ) + .unwrap(), + )); + + let oracle_agent = start_oracle_agent(CFG.clone(), &SECRET_KEY) + .await + .expect("failed to start agent"); + let oracle_agent = Arc::new(oracle_agent); + + execute(vault_wallet, user_wallet, oracle_agent, vault_id, vault_provider).await + }) + })); + + // Ensure the process group is terminated + if let Err(e) = kill_process_group(¶chain_runner) { + println!("Failed to kill process group: {}", e); + } + + match result { + Ok(r) => r, + Err(e) => panic::resume_unwind(e), + } +} - execute(client, vault_wallet, user_wallet, oracle_agent, vault_id, vault_provider).await +fn kill_process_group(child: &Child) -> io::Result<()> { + // Spawned child is the leader of the process group + // Therefore the process group has the same id as the spawned child + let pgid = child.id() as i32; + unsafe { + if libc::killpg(pgid, libc::SIGTERM) == -1 { + Err(io::Error::last_os_error()) + } else { + println!("Successfully killed process group"); + Ok(()) + } + } } diff --git a/clients/vault/tests/vault_integration_tests.rs b/clients/vault/tests/vault_integration_tests.rs index 17df04f52..e7e57196c 100644 --- a/clients/vault/tests/vault_integration_tests.rs +++ b/clients/vault/tests/vault_integration_tests.rs @@ -25,11 +25,11 @@ use helper::*; #[tokio::test(flavor = "multi_thread")] #[serial] async fn test_register() { - test_with(|client, vault_wallet, _| async move { + test_with(|vault_wallet, _| async move { let (eve_id, eve_provider) = - create_vault(client.clone(), AccountKeyring::Eve, CurrencyId::StellarNative).await; + create_vault(AccountKeyring::Eve, CurrencyId::StellarNative).await; let (dave_id, dave_provider) = - create_vault(client.clone(), AccountKeyring::Dave, LESS_THAN_4_CURRENCY_CODE).await; + create_vault(AccountKeyring::Dave, LESS_THAN_4_CURRENCY_CODE).await; let issue_amount = upscaled_compatible_amount(100); @@ -46,8 +46,8 @@ async fn test_register() { #[serial] async fn test_redeem_succeeds() { test_with_vault( - |client, vault_wallet, user_wallet, oracle_agent, vault_id, vault_provider| async move { - let user_provider = setup_provider(client.clone(), AccountKeyring::Dave).await; + |vault_wallet, user_wallet, oracle_agent, vault_id, vault_provider| async move { + let user_provider = setup_provider(AccountKeyring::Dave).await; let vault_ids = vec![vault_id.clone()]; let vault_id_manager = @@ -114,16 +114,11 @@ async fn test_redeem_succeeds() { #[serial] async fn test_replace_succeeds() { test_with_vault( - |client, - old_vault_wallet, - new_vault_wallet, - oracle_agent, - old_vault_id, - old_vault_provider| async move { + |old_vault_wallet, new_vault_wallet, oracle_agent, old_vault_id, old_vault_provider| async move { let (new_vault_id, new_vault_provider) = - create_vault(client.clone(), AccountKeyring::Eve, DEFAULT_WRAPPED_CURRENCY).await; + create_vault(AccountKeyring::Eve, DEFAULT_WRAPPED_CURRENCY).await; - let user_provider = setup_provider(client.clone(), AccountKeyring::Dave).await; + let user_provider = setup_provider(AccountKeyring::Dave).await; let vault_ids: Vec = vec![new_vault_id.clone(), old_vault_id.clone()].into_iter().collect(); @@ -227,11 +222,11 @@ async fn test_replace_succeeds() { #[serial] async fn test_withdraw_replace_succeeds() { test_with_vault( - |client, _vault_wallet, user_wallet, oracle_agent, old_vault_id, old_vault_provider| async move { + |_vault_wallet, user_wallet, oracle_agent, old_vault_id, old_vault_provider| async move { let (new_vault_id, new_vault_provider) = - create_vault(client.clone(), AccountKeyring::Eve, DEFAULT_WRAPPED_CURRENCY).await; + create_vault(AccountKeyring::Eve, DEFAULT_WRAPPED_CURRENCY).await; - let user_provider = setup_provider(client.clone(), AccountKeyring::Dave).await; + let user_provider = setup_provider(AccountKeyring::Dave).await; let issue_amount = upscaled_compatible_amount(100); @@ -294,14 +289,14 @@ async fn test_cancel_scheduler_succeeds() { // issue and replace cancellation is tested through the vault's cancellation service. // cancel_redeem is called manually test_with_vault( - |client, vault_wallet, user_wallet, oracle_agent, old_vault_id, old_vault_provider| async move { - let parachain_rpc = setup_provider(client.clone(), AccountKeyring::Bob).await; + |vault_wallet, user_wallet, oracle_agent, old_vault_id, old_vault_provider| async move { + let parachain_rpc = setup_provider(AccountKeyring::Bob).await; - let root_provider = setup_provider(client.clone(), AccountKeyring::Alice).await; - let user_provider = setup_provider(client.clone(), AccountKeyring::Dave).await; + let root_provider = setup_provider(AccountKeyring::Alice).await; + let user_provider = setup_provider(AccountKeyring::Dave).await; let (new_vault_id, new_vault_provider) = - create_vault(client.clone(), AccountKeyring::Eve, DEFAULT_WRAPPED_CURRENCY).await; + create_vault(AccountKeyring::Eve, DEFAULT_WRAPPED_CURRENCY).await; let issue_amount = upscaled_compatible_amount(200); @@ -467,8 +462,8 @@ async fn test_cancel_scheduler_succeeds() { #[tokio::test(flavor = "multi_thread")] #[serial] async fn test_issue_cancel_succeeds() { - test_with_vault(|client, vault_wallet, _user_wallet, _, vault_id, vault_provider| async move { - let user_provider = setup_provider(client.clone(), AccountKeyring::Dave).await; + test_with_vault(|vault_wallet, _user_wallet, _, vault_id, vault_provider| async move { + let user_provider = setup_provider(AccountKeyring::Dave).await; let issue_set = Arc::new(RwLock::new(IssueRequestsMap::new())); let memos_to_issue_ids = Arc::new(RwLock::new(IssueIdLookup::new())); @@ -554,8 +549,8 @@ async fn test_issue_cancel_succeeds() { #[serial] async fn test_issue_overpayment_succeeds() { test_with_vault( - |client, _vault_wallet, user_wallet, oracle_agent, vault_id, vault_provider| async move { - let user_provider = setup_provider(client.clone(), AccountKeyring::Dave).await; + |_vault_wallet, user_wallet, oracle_agent, vault_id, vault_provider| async move { + let user_provider = setup_provider(AccountKeyring::Dave).await; let public_key = default_destination_as_binary(); @@ -644,8 +639,8 @@ async fn test_issue_overpayment_succeeds() { #[serial] async fn test_automatic_issue_execution_succeeds() { test_with_vault( - |client, vault_wallet, user_wallet, oracle_agent, vault_id, vault_provider| async move { - let user_provider = setup_provider(client.clone(), AccountKeyring::Dave).await; + |vault_wallet, user_wallet, oracle_agent, vault_id, vault_provider| async move { + let user_provider = setup_provider(AccountKeyring::Dave).await; let issue_amount = upscaled_compatible_amount(1000); let vault_collateral = get_required_vault_collateral_for_issue( @@ -752,9 +747,9 @@ async fn test_automatic_issue_execution_succeeds() { #[serial] async fn test_automatic_issue_execution_succeeds_for_other_vault() { test_with_vault( - |client, vault_wallet, user_wallet, oracle_agent, vault1_id, vault1_provider| async move { - let user_provider = setup_provider(client.clone(), AccountKeyring::Dave).await; - let vault2_provider = setup_provider(client.clone(), AccountKeyring::Eve).await; + |vault_wallet, user_wallet, oracle_agent, vault1_id, vault1_provider| async move { + let user_provider = setup_provider(AccountKeyring::Dave).await; + let vault2_provider = setup_provider(AccountKeyring::Eve).await; let vault2_id = VaultId::new( AccountKeyring::Eve.into(), DEFAULT_TESTING_CURRENCY, @@ -897,8 +892,8 @@ async fn test_automatic_issue_execution_succeeds_for_other_vault() { #[serial] async fn test_execute_open_requests_succeeds() { test_with_vault( - |client, vault_wallet, user_wallet, oracle_agent, vault_id, vault_provider| async move { - let user_provider = setup_provider(client.clone(), AccountKeyring::Dave).await; + |vault_wallet, user_wallet, oracle_agent, vault_id, vault_provider| async move { + let user_provider = setup_provider(AccountKeyring::Dave).await; let vault_ids = vec![vault_id.clone()]; let vault_id_manager = @@ -1011,11 +1006,10 @@ async fn test_execute_open_requests_succeeds() { #[serial] async fn test_off_chain_liquidation() { test_with_vault( - |client, vault_wallet, user_wallet, oracle_agent, vault_id, vault_provider| async move { + |vault_wallet, user_wallet, oracle_agent, vault_id, vault_provider| async move { // Bob is set as an authorized oracle in the chain_spec - let authorized_oracle_provider = - setup_provider(client.clone(), AccountKeyring::Bob).await; - let user_provider = setup_provider(client.clone(), AccountKeyring::Dave).await; + let authorized_oracle_provider = setup_provider(AccountKeyring::Bob).await; + let user_provider = setup_provider(AccountKeyring::Dave).await; let issue_amount = upscaled_compatible_amount(100); let vault_collateral = get_required_vault_collateral_for_issue( @@ -1063,9 +1057,9 @@ async fn test_off_chain_liquidation() { #[tokio::test(flavor = "multi_thread")] async fn test_shutdown() { - test_with(|client, vault_wallet, _| async move { - let sudo_provider = setup_provider(client.clone(), AccountKeyring::Alice).await; - let user_provider = setup_provider(client.clone(), AccountKeyring::Dave).await; + test_with(|vault_wallet, _| async move { + let sudo_provider = setup_provider(AccountKeyring::Alice).await; + let user_provider = setup_provider(AccountKeyring::Dave).await; let sudo_vault_id = VaultId::new( AccountKeyring::Alice.into(), @@ -1122,8 +1116,8 @@ async fn test_shutdown() { #[tokio::test(flavor = "multi_thread")] #[serial] async fn test_requests_with_incompatible_amounts_fail() { - test_with_vault(|client, vault_wallet, _user_wallet, _, vault_id, vault_provider| async move { - let user_provider = setup_provider(client.clone(), AccountKeyring::Dave).await; + test_with_vault(|vault_wallet, _user_wallet, _, vault_id, vault_provider| async move { + let user_provider = setup_provider(AccountKeyring::Dave).await; // We define an incompatible amount let incompatible_amount = upscaled_compatible_amount(100) + 1;