@@ -118,10 +118,14 @@ type TestNodesResult = (
118118/// .with_networks(vec![Network::Bitcoin, Network::Testnet, Network::Regtest])
119119/// .build_clients_only();
120120pub struct LightningTestNodeBuilder {
121- node_count : usize , // Required - must be provided at creation.
122- initial_balance : u64 , // Always has a value (default: 100,000).
123- keysend_indices : Vec < usize > , // Always a vector (default: Vec filled with 0..node_count).
124- networks : Option < Vec < Network > > , // Can be None (default) or Some(networks).
121+ // The number of nodes in the network.
122+ node_count : usize ,
123+ // The balance to fund channels with, default: 100_000.
124+ initial_balance : u64 ,
125+ // The indexes of nodes that support keysend in the network.
126+ keysend_indices : Vec < usize > ,
127+ // The networks that that each node supports, length must equal node_count.
128+ networks : Option < Vec < Network > > ,
125129}
126130
127131impl LightningTestNodeBuilder {
@@ -131,9 +135,10 @@ impl LightningTestNodeBuilder {
131135 pub fn new ( node_count : usize ) -> Self {
132136 Self {
133137 node_count,
134- initial_balance : 100_000 , // Default 100k sats.
135- keysend_indices : ( 0 ..node_count) . collect ( ) , // Keysend for all nodes ON by default.
136- networks : Some ( vec ! [ Network :: Regtest ; node_count] ) , // Regtest network for all nodes by default.
138+ initial_balance : 100_000 ,
139+ // Turn keysend on by default.
140+ keysend_indices : ( 0 ..node_count) . collect ( ) ,
141+ networks : Some ( vec ! [ Network :: Regtest ; node_count] ) ,
137142 }
138143 }
139144
@@ -143,9 +148,8 @@ impl LightningTestNodeBuilder {
143148 self
144149 }
145150
146- /// Sets specific networks for each node.
147- /// Checks whether the number of networks matches node_count.
148- /// Returns self for method chaining.
151+ /// Sets specific networks for each node, asserting that the correct number of networks for
152+ /// was provided.
149153 pub fn with_networks ( mut self , networks : Vec < Network > ) -> Self {
150154 // Validate that we have the correct number of networks
151155 assert_eq ! (
@@ -157,17 +161,15 @@ impl LightningTestNodeBuilder {
157161 self
158162 }
159163
160- /// Builds only the client map, omitting node info.
161- /// Useful for network-specific testing. Returns a map of public keys to mocked
162- /// Lightning node clients.
164+ /// Builds only the client map, omitting node info. Useful for network-specific testing.
165+ /// Returns a map of public keys to mocked Lightning node clients.
163166 pub fn build_clients_only ( self ) -> HashMap < PublicKey , Arc < Mutex < dyn LightningNode > > > {
164167 let ( _, clients) = self . build_full ( ) ;
165168 clients
166169 }
167170
168- /// Builds the full test setup, including node info and clients.
169- /// Returns a tuple of node information and a map of public keys to mocked
170- /// Lightning node clients.
171+ /// Builds the full test setup, including node info and clients. Returns a tuple of node
172+ /// information and a map of public keys to mocked Lightning node clients.
171173 pub fn build_full ( self ) -> TestNodesResult {
172174 let nodes = create_nodes ( self . node_count , self . initial_balance ) ;
173175 let mut node_infos = Vec :: new ( ) ;
0 commit comments