Skip to content

Commit 12fdbef

Browse files
committed
[TS] Update tests to LDK 0.0.123
1 parent b4df222 commit 12fdbef

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

node-net/test/test.mts

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ await new Promise<void>(resolve => {
5757
// Wait until the peers are connected and have exchanged the initial handshake
5858
var timer: ReturnType<typeof setInterval>;
5959
timer = setInterval(function() {
60-
if (a_pm.get_peer_node_ids().length == 1 && b_pm.get_peer_node_ids().length == 1) {
60+
if (a_pm.list_peers().length == 1 && b_pm.list_peers().length == 1) {
6161
resolve();
6262
clearInterval(timer);
6363
}
@@ -69,7 +69,7 @@ await new Promise<void>(resolve => {
6969
// Wait until A learns the connection is closed from the socket closure
7070
var timer: ReturnType<typeof setInterval>;
7171
timer = setInterval(function() {
72-
if (a_pm.get_peer_node_ids().length == 0 && b_pm.get_peer_node_ids().length == 0) {
72+
if (a_pm.list_peers().length == 0 && b_pm.list_peers().length == 0) {
7373
resolve();
7474
clearInterval(timer);
7575
}

ts/test/tests.mts

+24-22
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ tests.push(async () => {
3939
if (!(read_outpoint instanceof ldk.Result_OutPointDecodeErrorZ_OK)) return false;
4040
if (!read_outpoint.res.eq(outpoint)) return false;
4141
if (read_outpoint.res.hash() != outpoint.hash()) return false;
42-
const chan_id = read_outpoint.res.to_channel_id();
43-
if (chan_id.length != 32) return false;
44-
if (chan_id[31] != 4) return false;
42+
const chan_id = ldk.ChannelId.constructor_v1_from_funding_outpoint(read_outpoint.res);
43+
if (chan_id.get_a().length != 32) return false;
44+
if (chan_id.get_a()[31] != 4) return false;
4545
return true;
4646
});
4747

@@ -51,9 +51,9 @@ tests.push(async () => {
5151
if (!(read_outpoint instanceof ldk.Result_OutPointDecodeErrorZ_OK)) return false;
5252
if (!read_outpoint.res.eq(outpoint)) return false;
5353
if (read_outpoint.res.hash() != outpoint.hash()) return false;
54-
const chan_id = read_outpoint.res.to_channel_id();
55-
if (chan_id.length != 32) return false;
56-
if (chan_id[31] != 4) return false;
54+
const chan_id = ldk.ChannelId.constructor_v1_from_funding_outpoint(read_outpoint.res);
55+
if (chan_id.get_a().length != 32) return false;
56+
if (chan_id.get_a()[31] != 4) return false;
5757
return true;
5858
});
5959

@@ -184,13 +184,13 @@ tests.push(async () => {
184184
a.chan_man.as_ChannelMessageHandler().peer_connected(b.chan_man.get_our_node_id(), ldk.Init.constructor_new(features, ldk.Option_CVec_ThirtyTwoBytesZZ.constructor_none(), ldk.Option_SocketAddressZ.constructor_none()), false);
185185
b.chan_man.as_ChannelMessageHandler().peer_connected(a.chan_man.get_our_node_id(), ldk.Init.constructor_new(features, ldk.Option_CVec_ThirtyTwoBytesZZ.constructor_none(), ldk.Option_SocketAddressZ.constructor_none()), true);
186186

187-
const chan_create_err = a.chan_man.create_channel(b.chan_man.get_our_node_id(), BigInt(0), BigInt(400), BigInt(0), ldk.Option_ThirtyTwoBytesZ.constructor_none(), null);
187+
const chan_create_err = a.chan_man.create_channel(b.chan_man.get_our_node_id(), BigInt(0), BigInt(400), BigInt(0), null, null);
188188
if (chan_create_err.is_ok()) return false;
189-
if (!(chan_create_err instanceof ldk.Result_ThirtyTwoBytesAPIErrorZ_Err)) return false;
189+
if (!(chan_create_err instanceof ldk.Result_ChannelIdAPIErrorZ_Err)) return false;
190190
if (!(chan_create_err.err instanceof ldk.APIError_APIMisuseError)) return false;
191191
if (chan_create_err.err.err != "Channel value must be at least 1000 satoshis. It was 0") return false;
192192

193-
const chan_create_res = a.chan_man.create_channel(b.chan_man.get_our_node_id(), BigInt(1000000), BigInt(400), BigInt(0), ldk.Option_ThirtyTwoBytesZ.constructor_none(), null);
193+
const chan_create_res = a.chan_man.create_channel(b.chan_man.get_our_node_id(), BigInt(1000000), BigInt(400), BigInt(0), null, null);
194194
if (!chan_create_res.is_ok()) return false;
195195

196196
if (!exchange_messages(a.chan_man, b.chan_man)) return false;
@@ -283,17 +283,17 @@ tests.push(async () => {
283283
if (!(init_bytes instanceof ldk.Result_CVec_u8ZPeerHandleErrorZ_OK)) return false;
284284
assert(pm_b.read_event(sock_b, init_bytes.res) instanceof ldk.Result_boolPeerHandleErrorZ_OK);
285285

286-
assert(pm_a.get_peer_node_ids().length == 0);
287-
assert(pm_b.get_peer_node_ids().length == 0);
286+
assert(pm_a.list_peers().length == 0);
287+
assert(pm_b.list_peers().length == 0);
288288

289289
pm_b.process_events();
290290
pm_a.process_events();
291291
pm_b.process_events();
292292

293-
assert(pm_a.get_peer_node_ids().length == 1);
294-
assert(pm_b.get_peer_node_ids().length == 1);
293+
assert(pm_a.list_peers().length == 1);
294+
assert(pm_b.list_peers().length == 1);
295295

296-
const chan_create_res = a.chan_man.create_channel(b.node_id, BigInt(1000000), BigInt(400), BigInt(0), ldk.Option_ThirtyTwoBytesZ.constructor_none(), ldk.UserConfig.constructor_default());
296+
const chan_create_res = a.chan_man.create_channel(b.node_id, BigInt(1000000), BigInt(400), BigInt(0), null, ldk.UserConfig.constructor_default());
297297
if (!chan_create_res.is_ok()) return false;
298298
if (!update_done) return false;
299299

@@ -325,9 +325,10 @@ tests.push(async () => {
325325
debug_str(): string { return "Message Contents"; }
326326
} as ldk.OnionMessageContentsInterface)));
327327
},
328-
handle_custom_message(msg: ldk.OnionMessageContents) {
328+
handle_custom_message(msg: ldk.OnionMessageContents): ldk.Option_OnionMessageContentsZ {
329329
assert(msg.tlv_type() == 9998n);
330330
a_handled_msg = true;
331+
return ldk.Option_OnionMessageContentsZ.constructor_none();
331332
},
332333
release_pending_custom_messages(): ldk.ThreeTuple_OnionMessageContentsDestinationBlindedPathZ[] {
333334
return [];
@@ -338,7 +339,7 @@ tests.push(async () => {
338339
.constructor_new(a.net_graph, a.keys_manager.as_EntropySource()).as_MessageRouter();
339340
const underlying_om_a = ldk.OnionMessenger.constructor_new(
340341
a.keys_manager.as_EntropySource(), a.keys_manager.as_NodeSigner(), a.logger,
341-
a_msg_router, ignorer.as_OffersMessageHandler(), om_handler_a);
342+
a.chan_man.as_NodeIdLookUp(), a_msg_router, ignorer.as_OffersMessageHandler(), om_handler_a);
342343
const om_a = ldk.OnionMessageHandler.new_impl({
343344
handle_onion_message(peer_node_id: Uint8Array, msg: ldk.OnionMessage) {
344345
underlying_om_a.as_OnionMessageHandler().handle_onion_message(peer_node_id, msg);
@@ -372,9 +373,10 @@ tests.push(async () => {
372373
debug_str(): string { return "Message Contents"; }
373374
} as ldk.OnionMessageContentsInterface)));
374375
},
375-
handle_custom_message(msg: ldk.OnionMessageContents) {
376+
handle_custom_message(msg: ldk.OnionMessageContents): ldk.Option_OnionMessageContentsZ {
376377
assert(msg.tlv_type() == 9999n);
377378
b_handled_msg = true;
379+
return ldk.Option_OnionMessageContentsZ.constructor_none();
378380
},
379381
release_pending_custom_messages(): ldk.ThreeTuple_OnionMessageContentsDestinationBlindedPathZ[] {
380382
return [];
@@ -383,7 +385,7 @@ tests.push(async () => {
383385
const msg_router_b = ldk.DefaultMessageRouter
384386
.constructor_new(b.net_graph, b.keys_manager.as_EntropySource()).as_MessageRouter();
385387
const om_b = ldk.OnionMessenger.constructor_new(b.keys_manager.as_EntropySource(), b.keys_manager.as_NodeSigner(),
386-
b.logger, msg_router_b, ignorer.as_OffersMessageHandler(), om_handler_b);
388+
b.logger, b.chan_man.as_NodeIdLookUp(), msg_router_b, ignorer.as_OffersMessageHandler(), om_handler_b);
387389

388390
const pm_a = ldk.PeerManager.constructor_new(a.chan_man.as_ChannelMessageHandler(), ignorer.as_RoutingMessageHandler(),
389391
om_a, ignorer.as_CustomMessageHandler(), 0xdeadbeef,
@@ -432,15 +434,15 @@ tests.push(async () => {
432434
if (!(init_bytes instanceof ldk.Result_CVec_u8ZPeerHandleErrorZ_OK)) return false;
433435
assert(pm_b.read_event(sock_b, init_bytes.res) instanceof ldk.Result_boolPeerHandleErrorZ_OK);
434436

435-
assert(pm_a.get_peer_node_ids().length == 0);
436-
assert(pm_b.get_peer_node_ids().length == 0);
437+
assert(pm_a.list_peers().length == 0);
438+
assert(pm_b.list_peers().length == 0);
437439

438440
pm_b.process_events();
439441
pm_a.process_events();
440442
pm_b.process_events();
441443

442-
assert(pm_a.get_peer_node_ids().length == 1);
443-
assert(pm_b.get_peer_node_ids().length == 1);
444+
assert(pm_a.list_peers().length == 1);
445+
assert(pm_b.list_peers().length == 1);
444446

445447
underlying_om_a.send_onion_message(
446448
ldk.OnionMessageContents.new_impl({

0 commit comments

Comments
 (0)