@@ -130,6 +130,28 @@ impl FeeEstimator for FuzzEstimator {
130130 }
131131}
132132
133+ impl lightning_0_2:: chain:: chaininterface:: FeeEstimator for FuzzEstimator {
134+ fn get_est_sat_per_1000_weight (
135+ & self , conf_target : lightning_0_2:: chain:: chaininterface:: ConfirmationTarget ,
136+ ) -> u32 {
137+ match conf_target {
138+ lightning_0_2:: chain:: chaininterface:: ConfirmationTarget :: MaximumFeeEstimate
139+ | lightning_0_2:: chain:: chaininterface:: ConfirmationTarget :: UrgentOnChainSweep => {
140+ MAX_FEE
141+ } ,
142+ lightning_0_2:: chain:: chaininterface:: ConfirmationTarget :: ChannelCloseMinimum
143+ | lightning_0_2:: chain:: chaininterface:: ConfirmationTarget :: AnchorChannelFee
144+ | lightning_0_2:: chain:: chaininterface:: ConfirmationTarget :: MinAllowedAnchorChannelRemoteFee
145+ | lightning_0_2:: chain:: chaininterface:: ConfirmationTarget :: MinAllowedNonAnchorChannelRemoteFee
146+ | lightning_0_2:: chain:: chaininterface:: ConfirmationTarget :: OutputSpendingFee => 253 ,
147+ lightning_0_2:: chain:: chaininterface:: ConfirmationTarget :: NonAnchorChannelFee => {
148+ let val = self . ret_val . load ( atomic:: Ordering :: Relaxed ) ;
149+ cmp:: min ( val, MAX_FEE )
150+ } ,
151+ }
152+ }
153+ }
154+
133155impl FuzzEstimator {
134156 fn feerate_sat_per_kw ( & self ) -> FeeRate {
135157 let feerate = self . ret_val . load ( atomic:: Ordering :: Acquire ) ;
@@ -182,6 +204,14 @@ impl BroadcasterInterface for TestBroadcaster {
182204 }
183205}
184206
207+ impl lightning_0_2:: chain:: chaininterface:: BroadcasterInterface for TestBroadcaster {
208+ fn broadcast_transactions ( & self , txs : & [ & bitcoin:: Transaction ] ) {
209+ for tx in txs {
210+ self . txn_broadcasted . borrow_mut ( ) . push ( ( * tx) . clone ( ) ) ;
211+ }
212+ }
213+ }
214+
185215struct ChainState {
186216 blocks : Vec < ( Header , Vec < Transaction > ) > ,
187217 confirmed_txids : HashSet < Txid > ,
@@ -290,6 +320,20 @@ impl TestChainMonitor {
290320 latest_monitors : Mutex :: new ( new_hash_map ( ) ) ,
291321 }
292322 }
323+ fn do_watch_channel_bytes (
324+ & self , channel_id_bytes : [ u8 ; 32 ] , monitor_id : u64 , serialized_monitor : Vec < u8 > ,
325+ ) {
326+ let channel_id = ChannelId ( channel_id_bytes) ;
327+ let state = LatestMonitorState {
328+ persisted_monitor_id : monitor_id,
329+ persisted_monitor : serialized_monitor,
330+ pending_monitors : Vec :: new ( ) ,
331+ } ;
332+ let mut latest_monitors = self . latest_monitors . lock ( ) . unwrap ( ) ;
333+ if latest_monitors. insert ( channel_id, state) . is_some ( ) {
334+ panic ! ( "Already had monitor pre-watch_channel" ) ;
335+ }
336+ }
293337}
294338impl chain:: Watch < TestChannelSigner > for TestChainMonitor {
295339 fn watch_channel (
@@ -299,22 +343,8 @@ impl chain::Watch<TestChannelSigner> for TestChainMonitor {
299343 monitor. write ( & mut ser) . unwrap ( ) ;
300344 let monitor_id = monitor. get_latest_update_id ( ) ;
301345 let res = self . chain_monitor . watch_channel ( channel_id, monitor) ;
302- let state = match res {
303- Ok ( chain:: ChannelMonitorUpdateStatus :: Completed ) => LatestMonitorState {
304- persisted_monitor_id : monitor_id,
305- persisted_monitor : ser. 0 ,
306- pending_monitors : Vec :: new ( ) ,
307- } ,
308- Ok ( chain:: ChannelMonitorUpdateStatus :: InProgress ) => LatestMonitorState {
309- persisted_monitor_id : monitor_id,
310- persisted_monitor : Vec :: new ( ) ,
311- pending_monitors : vec ! [ ( monitor_id, ser. 0 ) ] ,
312- } ,
313- Ok ( chain:: ChannelMonitorUpdateStatus :: UnrecoverableError ) => panic ! ( ) ,
314- Err ( ( ) ) => panic ! ( ) ,
315- } ;
316- if self . latest_monitors . lock ( ) . unwrap ( ) . insert ( channel_id, state) . is_some ( ) {
317- panic ! ( "Already had monitor pre-watch_channel" ) ;
346+ if res == Ok ( chain:: ChannelMonitorUpdateStatus :: Completed ) {
347+ self . do_watch_channel_bytes ( channel_id. 0 , monitor_id, ser. 0 ) ;
318348 }
319349 res
320350 }
@@ -368,6 +398,41 @@ impl chain::Watch<TestChannelSigner> for TestChainMonitor {
368398 }
369399}
370400
401+ impl lightning_0_2:: chain:: Watch < lightning_0_2:: util:: test_channel_signer:: TestChannelSigner >
402+ for TestChainMonitor
403+ {
404+ fn watch_channel (
405+ & self , channel_id : lightning_0_2:: ln:: types:: ChannelId ,
406+ monitor : lightning_0_2:: chain:: channelmonitor:: ChannelMonitor <
407+ lightning_0_2:: util:: test_channel_signer:: TestChannelSigner ,
408+ > ,
409+ ) -> Result < lightning_0_2:: chain:: ChannelMonitorUpdateStatus , ( ) > {
410+ let mut ser = Vec :: new ( ) ;
411+ lightning_0_2:: util:: ser:: Writeable :: write ( & monitor, & mut ser) . unwrap ( ) ;
412+ let monitor_id = monitor. get_latest_update_id ( ) ;
413+ self . do_watch_channel_bytes ( channel_id. 0 , monitor_id, ser) ;
414+
415+ Ok ( lightning_0_2:: chain:: ChannelMonitorUpdateStatus :: Completed )
416+ }
417+ fn update_channel (
418+ & self , _channel_id : lightning_0_2:: ln:: types:: ChannelId ,
419+ _update : & lightning_0_2:: chain:: channelmonitor:: ChannelMonitorUpdate ,
420+ ) -> lightning_0_2:: chain:: ChannelMonitorUpdateStatus {
421+ lightning_0_2:: chain:: ChannelMonitorUpdateStatus :: Completed
422+ }
423+
424+ fn release_pending_monitor_events (
425+ & self ,
426+ ) -> Vec < (
427+ lightning_0_2:: chain:: transaction:: OutPoint ,
428+ lightning_0_2:: ln:: types:: ChannelId ,
429+ Vec < lightning_0_2:: chain:: channelmonitor:: MonitorEvent > ,
430+ PublicKey ,
431+ ) > {
432+ Vec :: new ( )
433+ }
434+ }
435+
371436struct KeyProvider {
372437 node_secret : SecretKey ,
373438 rand_bytes_id : atomic:: AtomicU32 ,
0 commit comments