fix sandbox for liana-gui tests
This commit is contained in:
parent
bf8c2eaf4f
commit
c76109e09c
@ -651,7 +651,8 @@ impl DescriptorEditModal for EditThresholdModal {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use iced_runtime::command::Action;
|
||||
use iced::futures::StreamExt;
|
||||
use iced_runtime::{task::into_stream, Action};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
@ -674,10 +675,11 @@ mod tests {
|
||||
pub async fn update(&self, message: Message) {
|
||||
let mut hws = HardwareWallets::new(PathBuf::from_str("/").unwrap(), Network::Bitcoin);
|
||||
let cmd = self.step.lock().unwrap().update(&mut hws, message);
|
||||
for action in cmd.actions() {
|
||||
if let Action::Future(f) = action {
|
||||
let msg = f.await;
|
||||
let _cmd = self.step.lock().unwrap().update(&mut hws, msg);
|
||||
if let Some(mut stream) = into_stream(cmd) {
|
||||
while let Some(action) = stream.next().await {
|
||||
if let Action::Output(msg) = action {
|
||||
let _cmd = self.step.lock().unwrap().update(&mut hws, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ impl Loader {
|
||||
if self.internal_bitcoind.is_some() {
|
||||
let log_path = internal_bitcoind_debug_log_path(&self.datadir_path, self.network);
|
||||
iced::Subscription::run_with_id("bitcoind_log", get_bitcoind_log(log_path))
|
||||
.map(|msg| Message::BitcoindLog(msg))
|
||||
.map(Message::BitcoindLog)
|
||||
} else {
|
||||
Subscription::none()
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
use iced::futures::StreamExt;
|
||||
use std::sync::Arc;
|
||||
|
||||
use iced_runtime::command::Action;
|
||||
use iced_runtime::{task::into_stream, Action};
|
||||
|
||||
use crate::{
|
||||
app::{cache::Cache, message::Message, state::State, wallet::Wallet},
|
||||
@ -11,7 +12,7 @@ pub struct Sandbox<S: State> {
|
||||
state: S,
|
||||
}
|
||||
|
||||
impl<S: State + Send + 'static> Sandbox<S> {
|
||||
impl<S: State + 'static> Sandbox<S> {
|
||||
pub fn new(state: S) -> Self {
|
||||
Self { state }
|
||||
}
|
||||
@ -27,13 +28,13 @@ impl<S: State + Send + 'static> Sandbox<S> {
|
||||
message: Message,
|
||||
) -> Self {
|
||||
let cmd = self.state.update(daemon.clone(), cache, message);
|
||||
for action in cmd.actions() {
|
||||
if let Action::Future(f) = action {
|
||||
let msg = f.await;
|
||||
let _cmd = self.state.update(daemon.clone(), cache, msg);
|
||||
if let Some(mut stream) = into_stream(cmd) {
|
||||
while let Some(action) = stream.next().await {
|
||||
if let Action::Output(msg) = action {
|
||||
let _cmd = self.state.update(daemon.clone(), cache, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
@ -44,10 +45,11 @@ impl<S: State + Send + 'static> Sandbox<S> {
|
||||
wallet: Arc<Wallet>,
|
||||
) -> Self {
|
||||
let cmd = self.state.reload(daemon.clone(), wallet);
|
||||
for action in cmd.actions() {
|
||||
if let Action::Future(f) = action {
|
||||
let msg = f.await;
|
||||
self = self.update(daemon.clone(), cache, msg).await;
|
||||
if let Some(mut stream) = into_stream(cmd) {
|
||||
while let Some(action) = stream.next().await {
|
||||
if let Action::Output(msg) = action {
|
||||
let _cmd = self.state.update(daemon.clone(), cache, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user