-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathhypernode_test.rs
More file actions
62 lines (50 loc) · 1.88 KB
/
hypernode_test.rs
File metadata and controls
62 lines (50 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use crate::test_helpers::{
bitcoin_helpers::pay_for_order_as_taker,
fixtures::{TestConfig, TestFixture},
hypernode_helpers::spawn_and_wait_for_hypernode,
order_helpers::{create_default_order, OrderBuilder},
swap_helpers::run_complete_swap_flow,
};
#[tokio::test]
async fn test_hypernode_simple_swap() {
// Setup test environment
let fixture = TestFixture::new().await;
// Spawn hypernode to process the payment
let hypernode_handle = spawn_and_wait_for_hypernode(&fixture).await;
// Create an order
let order = create_default_order(&fixture).await;
println!("Created order with index: {}", order.index);
// Pay for the order as taker
pay_for_order_as_taker(&fixture, &order).await;
// Wait for swap to complete
run_complete_swap_flow(&fixture, order.index.to::<u64>()).await;
println!("Swap completed successfully!");
// Cleanup
hypernode_handle.abort();
}
#[tokio::test]
async fn test_hypernode_multiple_swaps() {
// Setup with multiple makers
let config = TestConfig {
auto_mine_ethereum: true,
num_additional_makers: 1,
};
let fixture = TestFixture::with_config(config).await;
// Spawn hypernode first
let hypernode_handle = spawn_and_wait_for_hypernode(&fixture).await;
// First swap with default maker
let order1 = create_default_order(&fixture).await;
pay_for_order_as_taker(&fixture, &order1).await;
run_complete_swap_flow(&fixture, order1.index.to::<u64>()).await;
println!("First swap completed!");
// Second swap with additional maker
let order2 = OrderBuilder::new()
.with_salt([0x55; 32])
.create_as_maker(&fixture, 1)
.await;
pay_for_order_as_taker(&fixture, &order2).await;
run_complete_swap_flow(&fixture, order2.index.to::<u64>()).await;
println!("Second swap completed!");
// Cleanup
hypernode_handle.abort();
}