Skip to content

Commit 1d5388a

Browse files
committed
chore(test): Ensure dlc channel is settled in close position test
Verifies that #2126 is fixed
1 parent 33bb515 commit 1d5388a

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

Diff for: crates/tests-e2e/src/coordinator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ pub enum ChannelState {
122122
Cancelled,
123123
}
124124

125-
#[derive(Deserialize, Debug)]
125+
#[derive(Deserialize, Debug, PartialEq)]
126126
pub enum SignedChannelState {
127127
Established,
128128
SettledOffered,

Diff for: crates/tests-e2e/tests/e2e_close_position.rs

+39
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use native::trade::order::api::NewOrder;
66
use native::trade::order::api::OrderType;
77
use native::trade::position::PositionState;
88
use tests_e2e::app::submit_order;
9+
use tests_e2e::coordinator::SignedChannelState;
910
use tests_e2e::setup;
1011
use tests_e2e::setup::dummy_order;
1112
use tests_e2e::wait_until;
@@ -89,6 +90,34 @@ async fn can_open_close_open_close_position() {
8990
.unwrap();
9091
tracing::info!(%app_off_chain_balance, "Opened second position");
9192

93+
// rolling over before closing the second position
94+
tracing::info!("Rollover second position");
95+
let coordinator = test.coordinator;
96+
let app_pubkey = api::get_node_id().0;
97+
let dlc_channels = coordinator.get_dlc_channels().await.unwrap();
98+
let dlc_channel = dlc_channels
99+
.into_iter()
100+
.find(|chan| chan.counter_party == app_pubkey)
101+
.unwrap();
102+
103+
coordinator
104+
.rollover(&dlc_channel.dlc_channel_id.unwrap())
105+
.await
106+
.unwrap();
107+
108+
wait_until!(test
109+
.app
110+
.rx
111+
.position()
112+
.map(|p| PositionState::Rollover == p.position_state)
113+
.unwrap_or(false));
114+
wait_until!(test
115+
.app
116+
.rx
117+
.position()
118+
.map(|p| PositionState::Open == p.position_state)
119+
.unwrap_or(false));
120+
92121
tracing::info!("Closing second position");
93122

94123
let closing_order = NewOrder {
@@ -100,6 +129,16 @@ async fn can_open_close_open_close_position() {
100129

101130
wait_until!(test.app.rx.position_close().is_some());
102131

132+
wait_until!({
133+
let dlc_channels = coordinator.get_dlc_channels().await.unwrap();
134+
let dlc_channel = dlc_channels
135+
.into_iter()
136+
.find(|chan| chan.counter_party == app_pubkey)
137+
.unwrap();
138+
139+
Some(SignedChannelState::Settled) == dlc_channel.signed_channel_state
140+
});
141+
103142
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
104143

105144
// - App off-chain balance is 1_235_000 sats (reserve + margin - 3_750 fee).

0 commit comments

Comments
 (0)