Update bindings demo clients to the new event handling API
[ldk-c-bindings] / lightning-c-bindings / demo.c
index 2a45e4644157a903313c419fa09632563e2db205..a9556303fa3d1a0e826fbcff69625a38f8124b03 100644 (file)
@@ -35,6 +35,11 @@ LDKCVec_MonitorEventZ monitors_pending_monitor_events(const void *this_arg) {
        return empty_htlc_vec;
 }
 
+void never_handle_event(const void *this_arg, struct LDKEvent event) {
+       // Note that we never actually generate any events to handle in the code below.
+       assert(false);
+}
+
 int main() {
        uint8_t node_seed[32];
        memset(node_seed, 0, 32);
@@ -82,9 +87,9 @@ int main() {
        CVec_ChannelDetailsZ_free(channels);
 
        LDKEventsProvider prov = ChannelManager_as_EventsProvider(&cm);
-       LDKCVec_EventZ events = (prov.get_and_clear_pending_events)(prov.this_arg);
-       assert((unsigned long)events.data < 4096); // There's an offset, but it should still be an offset against null in the 0 page
-       assert(events.datalen == 0);
+       // Check that no events were generated by asserting if any events are passed to never_handle_event.
+       LDKEventHandler handler = { .handle_event = never_handle_event, .free = NULL };
+       (prov.process_pending_events)(prov.this_arg, handler);
 
        ChannelManager_free(cm);
        KeysManager_free(keys);