Skip to content

Commit 9f0738b

Browse files
committed
test: TransactionDirect status in sidecar
1 parent d1b3f6a commit 9f0738b

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

boltzr/src/chain/mrh_watcher.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ impl MrhWatcher {
6262
let update = SwapStatus {
6363
id: routing_hint.swapId.clone(),
6464
status: SwapUpdateStatus::TransactionDirect.to_string(),
65-
zero_conf_rejected: None,
6665
transaction: Some(TransactionInfo {
6766
id: tx.txid_hex(),
6867
hex: Some(tx.serialize().to_lower_hex_string()),
@@ -111,7 +110,6 @@ mod test {
111110

112111
#[tokio::test]
113112
async fn test_listen() {
114-
// Create broadcast channels
115113
let (swap_status_update_tx, mut swap_status_update_rx) = broadcast::channel(256);
116114
let (tx_sender, tx_receiver) = broadcast::channel(256);
117115

@@ -145,7 +143,10 @@ mod test {
145143
let received_update = swap_status_update_rx.recv().await.unwrap();
146144

147145
assert_eq!(received_update.id, "123");
148-
assert_eq!(received_update.status, "transaction.direct");
146+
assert_eq!(
147+
received_update.status,
148+
SwapUpdateStatus::TransactionDirect.to_string()
149+
);
149150
assert!(received_update.transaction.is_some());
150151

151152
let transaction_info = received_update.transaction.unwrap();

test/integration/sidecar/Sidecar.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,30 @@ describe('Sidecar', () => {
7474
);
7575
});
7676

77+
test(`should handle status ${SwapUpdateEvent.TransactionDirect}`, async () => {
78+
const update = new sidecarrpc.SwapUpdate();
79+
update.setId('test-swap');
80+
update.setStatus(SwapUpdateEvent.TransactionDirect);
81+
const transactionInfo = new sidecarrpc.SwapUpdate.TransactionInfo();
82+
transactionInfo.setId('txid');
83+
transactionInfo.setHex('hex');
84+
update.setTransactionInfo(transactionInfo as any);
85+
86+
await sidecar['handleSentSwapUpdate'](update);
87+
88+
expect(eventHandler.nursery.emit).toHaveBeenCalledTimes(1);
89+
expect(eventHandler.nursery.emit).toHaveBeenCalledWith('swap.update', {
90+
id: update.getId(),
91+
status: {
92+
status: SwapUpdateEvent.TransactionDirect,
93+
transaction: {
94+
id: transactionInfo.getId(),
95+
hex: transactionInfo.getHex(),
96+
},
97+
},
98+
});
99+
});
100+
77101
test.each`
78102
status
79103
${SwapUpdateEvent.InvoicePaid}

0 commit comments

Comments
 (0)