Expose async monitor persistence for tests#4665
Conversation
Downstream tests need to exercise the same async monitor persistence path used by ChainMonitor::new_async_beta without reimplementing Persist. Add test-only constructors that let TestChainMonitor and AsyncPersister share the wake notifier so async completions drive the monitor update future. Co-Authored-By: HAL 9000
|
👋 I see @joostjager was un-assigned. |
|
I've now reviewed the entire PR diff thoroughly — all three files, all hunks, all new methods, the test, and the cfg gating logic. Summary of findings: The refactoring of No issues found. |
TheBlueMatt
left a comment
There was a problem hiding this comment.
Hmm, its not entirely clear to me why this is needed? Can you spell out what kind of test you want to write and why it needs this? In general downstream tests (and, really, any tests) should just block the KVStore write they want to block, IMO.
Yes see here: lightningdevkit/ldk-node#919 (comment) This will allow us to do: type TestMonitorPersister<K> = MonitorUpdatingPersisterAsync<
TestStoreRef<K>,
TestFutureSpawner,
&'static test_utils::TestLogger,
&'static test_utils::TestKeysInterface,
&'static test_utils::TestKeysInterface,
&'static test_utils::TestBroadcaster,
&'static test_utils::TestFeeEstimator,
>;
type TestAsyncPersister<K> = lightning::chain::chainmonitor::AsyncPersister<
TestStoreRef<K>,
TestFutureSpawner,
&'static test_utils::TestLogger,
&'static test_utils::TestKeysInterface,
&'static test_utils::TestKeysInterface,
&'static test_utils::TestBroadcaster,
&'static test_utils::TestFeeEstimator,
>;
(..)
let monitor_persister = TestMonitorPersister::new(
store,
TestFutureSpawner::new(Arc::clone(&runtime)),
&chanmon_cfg.logger,
max_pending_updates,
&chanmon_cfg.keys_manager,
&chanmon_cfg.keys_manager,
&chanmon_cfg.tx_broadcaster,
&chanmon_cfg.fee_estimator,
);
let event_notifier = Arc::new(Notifier::new());
let persister = lightning::chain::chainmonitor::AsyncPersister::new_test(
monitor_persister,
Arc::clone(&event_notifier),
);
(...)
test_utils::TestChainMonitor::new_with_event_notifier(
Some(&chanmon_cfg.chain_source),
&chanmon_cfg.tx_broadcaster,
&chanmon_cfg.logger,
&chanmon_cfg.fee_estimator,
&persister.persister,
&chanmon_cfg.keys_manager,
Arc::clone(&persister.event_notifier),
).. rather than duplicating code via our custom |
|
Are there some specific tests in LDK Node that need that struct vs just using the |
Downstream tests need to exercise the same async monitor persistence path used by ChainMonitor::new_async_beta without reimplementing Persist. Add test-only constructors that let TestChainMonitor and AsyncPersister share the wake notifier so async completions drive the monitor update future.
Co-Authored-By: HAL 9000