From 99a016b2086134f3a9659224d98ae0c6e9c094c3 Mon Sep 17 00:00:00 2001 From: Alejandro Martinez Andres <11448715+al3mart@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:21:18 +0100 Subject: [PATCH] test(wallet-integration): remove sign_call_data test --- crates/pop-cli/src/common/wallet.rs | 60 ----------------------------- 1 file changed, 60 deletions(-) diff --git a/crates/pop-cli/src/common/wallet.rs b/crates/pop-cli/src/common/wallet.rs index 4bfffa6d..b0065838 100644 --- a/crates/pop-cli/src/common/wallet.rs +++ b/crates/pop-cli/src/common/wallet.rs @@ -29,63 +29,3 @@ pub async fn wait_for_signature(call_data: Vec, url: String) -> anyhow::Resu let signed_payload = wallet.state.lock().await.signed_payload.clone(); Ok(signed_payload) } - -#[cfg(test)] -mod tests { - use super::*; - use subxt::utils::to_hex; - - // TODO: delete this test. - // This is a helper test for an actual running pop CLI. - // It can serve as the "frontend" to query the payload, sign it - // and submit back to the CLI. - #[tokio::test] - async fn sign_call_data() -> anyhow::Result<()> { - use subxt::{config::DefaultExtrinsicParamsBuilder as Params, tx::Payload}; - // This struct implements the [`Payload`] trait and is used to submit - // pre-encoded SCALE call data directly, without the dynamic construction of transactions. - struct CallData(Vec); - - impl Payload for CallData { - fn encode_call_data_to( - &self, - _: &subxt::Metadata, - out: &mut Vec, - ) -> Result<(), subxt::ext::subxt_core::Error> { - out.extend_from_slice(&self.0); - Ok(()) - } - } - - use subxt_signer::sr25519::dev; - let payload = reqwest::get(&format!("{}/payload", "http://127.0.0.1:9090")) - .await - .expect("Failed to get payload") - .json::() - .await - .expect("Failed to parse payload"); - - let url = "ws://localhost:9944"; - let rpc_client = subxt::backend::rpc::RpcClient::from_url(url).await?; - let client = - subxt::OnlineClient::::from_rpc_client(rpc_client).await?; - - let signer = dev::alice(); - - let payload = CallData(payload.call_data()); - let ext_params = Params::new().build(); - let signed = client.tx().create_signed(&payload, &signer, ext_params).await?; - - let _response = reqwest::Client::new() - .post(&format!("{}/submit", "http://localhost:9090")) - .json(&to_hex(signed.encoded())) - .send() - .await - .expect("Failed to submit payload") - .text() - .await - .expect("Failed to parse JSON response"); - - Ok(()) - } -}