Skip to content

Commit 7ebd5df

Browse files
committed
[C#] Update tests to latest upstream LDK API
1 parent 9559614 commit 7ebd5df

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

c_sharp/test/src/tests.cs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,20 @@ public void log(Record record) {
5454
}
5555

5656
class TestPersister : PersistInterface {
57-
public ChannelMonitorUpdateStatus persist_new_channel(OutPoint channel_id, ChannelMonitor data, MonitorUpdateId update_id) {
57+
public ChannelMonitorUpdateStatus persist_new_channel(OutPoint channel_id, ChannelMonitor data) {
5858
return ChannelMonitorUpdateStatus.LDKChannelMonitorUpdateStatus_Completed;
5959
}
60-
public ChannelMonitorUpdateStatus update_persisted_channel(OutPoint channel_id, ChannelMonitorUpdate update, ChannelMonitor data, MonitorUpdateId update_id) {
60+
public ChannelMonitorUpdateStatus update_persisted_channel(OutPoint channel_id, ChannelMonitorUpdate update, ChannelMonitor data) {
6161
return ChannelMonitorUpdateStatus.LDKChannelMonitorUpdateStatus_Completed;
6262
}
6363
public void archive_persisted_channel(OutPoint channel_id) { }
6464
}
6565

6666
class TestEventHandler : EventHandlerInterface {
6767
public List<Event> events = new List<Event>();
68-
public void handle_event(Event ev) {
68+
public Result_NoneReplayEventZ handle_event(Event ev) {
6969
events.Add(ev);
70+
return Result_NoneReplayEventZ.ok();
7071
}
7172
}
7273
static Event get_event(ChannelManager manager) {
@@ -90,23 +91,26 @@ public Result_RouteLightningErrorZ find_route(byte[] payer, RouteParameters para
9091
public Result_RouteLightningErrorZ find_route_with_id(byte[] payer, RouteParameters param, ChannelDetails[] chans, InFlightHtlcs htlcs, byte[] payment_hash, byte[] payment_id) {
9192
return inner.as_Router().find_route_with_id(payer, param, chans, htlcs, payment_hash, payment_id);
9293
}
93-
public Result_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ create_blinded_payment_paths(byte[] recipient, ChannelDetails[] first_hops, ReceiveTlvs tlvs, long amount_msats) {
94-
Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ info_path = UtilMethods.BlindedPath_one_hop_for_payment(recipient, tlvs, 40, entropy);
95-
TwoTuple_BlindedPayInfoBlindedPathZ hop = ((Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ.Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_OK)info_path).res;
96-
TwoTuple_BlindedPayInfoBlindedPathZ[] hops = new TwoTuple_BlindedPayInfoBlindedPathZ[1];
94+
public Result_CVec_BlindedPaymentPathZNoneZ create_blinded_payment_paths(byte[] recipient, ChannelDetails[] first_hops, ReceiveTlvs tlvs, long amount_msats) {
95+
Result_BlindedPaymentPathNoneZ info_path = BlindedPaymentPath.one_hop(recipient, tlvs, 40, entropy);
96+
BlindedPaymentPath hop = ((Result_BlindedPaymentPathNoneZ.Result_BlindedPaymentPathNoneZ_OK)info_path).res;
97+
BlindedPaymentPath[] hops = new BlindedPaymentPath[1];
9798
hops[0] = hop;
98-
return Result_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ.ok(hops);
99+
return Result_CVec_BlindedPaymentPathZNoneZ.ok(hops);
99100
}
100101

101102
public Result_OnionMessagePathNoneZ find_path(byte[] sender, byte[][] peers, Destination dest) {
102103
return inner.as_MessageRouter().find_path(sender, peers, dest);
103104
}
104-
public Result_CVec_BlindedPathZNoneZ create_blinded_paths(byte[] recipient, byte[][] peers) {
105-
Result_BlindedPathNoneZ path = BlindedPath.one_hop_for_message(recipient, entropy);
105+
public Result_CVec_BlindedMessagePathZNoneZ create_blinded_paths(byte[] recipient, MessageContext ctx, byte[][] peers) {
106+
Result_BlindedMessagePathNoneZ path = BlindedMessagePath.one_hop(recipient, ctx, entropy);
106107
Assert(path.is_ok(), 2);
107-
BlindedPath[] paths = new BlindedPath[1];
108-
paths[0] = ((Result_BlindedPathNoneZ.Result_BlindedPathNoneZ_OK)path).res;
109-
return Result_CVec_BlindedPathZNoneZ.ok(paths);
108+
BlindedMessagePath[] paths = new BlindedMessagePath[1];
109+
paths[0] = ((Result_BlindedMessagePathNoneZ.Result_BlindedMessagePathNoneZ_OK)path).res;
110+
return Result_CVec_BlindedMessagePathZNoneZ.ok(paths);
111+
}
112+
public Result_CVec_BlindedMessagePathZNoneZ create_compact_blinded_paths(byte[] recipient, MessageContext ctx, MessageForwardNode[] peers) {
113+
return this.create_blinded_paths(recipient, ctx, new byte[0][]);
110114
}
111115
}
112116

@@ -145,7 +149,7 @@ public Node(byte seed) {
145149

146150
manager = ChannelManager.of(estimator, chain_monitor.as_Watch(), ldk_broadcaster, router, logger, keys.as_EntropySource(), keys.as_NodeSigner(), keys.as_SignerProvider(), config, chain_params, 42);
147151

148-
messenger = OnionMessenger.of(keys.as_EntropySource(), keys.as_NodeSigner(), logger, manager.as_NodeIdLookUp(), MessageRouter.new_impl(router_wrapper), manager.as_OffersMessageHandler(), IgnoringMessageHandler.of().as_CustomOnionMessageHandler());
152+
messenger = OnionMessenger.of(keys.as_EntropySource(), keys.as_NodeSigner(), logger, manager.as_NodeIdLookUp(), MessageRouter.new_impl(router_wrapper), manager.as_OffersMessageHandler(), IgnoringMessageHandler.of().as_AsyncPaymentsMessageHandler(), IgnoringMessageHandler.of().as_CustomOnionMessageHandler());
149153
}
150154
}
151155

@@ -305,7 +309,7 @@ static void NodeTest() {
305309

306310
// Now that we have a channel, pay using a BOLT12 offer!
307311

308-
Result_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ builder_res = node_b.manager.create_offer_builder();
312+
Result_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ builder_res = node_b.manager.create_offer_builder(Option_u64Z.none());
309313
Assert(builder_res.is_ok(), 29);
310314
Result_OfferBolt12SemanticErrorZ offer_res = ((Result_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ.Result_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ_OK)builder_res).res.build();
311315
Assert(offer_res.is_ok(), 30);

0 commit comments

Comments
 (0)