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 re-examined the full PR including the surrounding code that the diff touches: the The notifier plumbing in the test-only constructors faithfully matches the production 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 |
8b5d23a to
64b065a
Compare
|
Updated to line-wrap commit messages. |
|
Still left with the above question. I don't love exposing this if there's an alternative way to do it downstream. |
Excuse the delay! We use this in our AFAIU, having a test-only path to allow constructing async-persisted variants of |
|
I'm still confused. I can't try to play with this cause not sure what |
|
Hi @tnull, Thanks for your contributions to After too many struggles with bugs, outages, contributor bans, and, finally, a multi-week CI ban, the rust-lightning project is moving off of GitHub for day-to-day development. You can still file issues and access the git tree here, but PRs will now take place exclusively at https://git.rust-bitcoin.org/. As such, this PR has been migrated to https://git.rust-bitcoin.org/lightningdevkit/rust-lightning/pulls/4665 If you log in using GitHub (or otherwise link your GitHub account from https://git.rust-bitcoin.org/user/settings/security), ownership of your PRs, issues, and comments will automatically transfer. To push updates to this PR, you'll need to use |
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