@@ -212,6 +212,31 @@ type internal ActorCreator =
212
212
return actors
213
213
}
214
214
215
+ static member sendGeewalletPayment alice bob = async {
216
+ let bobNodeId = bob.CM.KeysRepository.GetNodeSecret() .PubKey |> NodeId
217
+ let aliceNodeId = alice.CM.KeysRepository.GetNodeSecret() .PubKey |> NodeId
218
+
219
+ do ! Async.Sleep 1000
220
+ Console.WriteLine( " testing geewallet payment" )
221
+
222
+
223
+ let aliceToBobAmount = 1000 L |> LNMoney.MilliSatoshis
224
+ let geewalletPaymentCmd = {
225
+ Amount = aliceToBobAmount
226
+ }
227
+
228
+ // Send geewallet payment from alice to bob
229
+ let bobAcceptedGeewalletPaymentTask =
230
+ bob.EventAggregator.AwaitChannelEvent( function WeAcceptedGeewalletPayment _ -> Some () | _ -> None)
231
+ do !
232
+ alice.CM.AcceptCommandAsync({
233
+ NodeId = bobNodeId
234
+ ChannelCommand = ChannelCommand.GeewalletPayment geewalletPaymentCmd
235
+ }) .AsTask() |> Async.AwaitTask
236
+
237
+ let! r = bobAcceptedGeewalletPaymentTask
238
+ Expect.isSome r " timeout waiting for bob to accept geewallet payment"
239
+ }
215
240
216
241
[<Tests>]
217
242
let tests =
@@ -348,7 +373,7 @@ let tests =
348
373
349
374
do! alice.CM.AcceptCommandAsync({ NodeId = bobNodeId; ChannelCommand = ChannelCommand.AddHTLC addHtlcCmd }).AsTask() |> Async.AwaitTask
350
375
let! r = bobAcceptedAddHTLCTask
351
- Expect.isSome r "timeout"
376
+ Expect.isSome r "timeout waiting for bob to accept htlc "
352
377
353
378
354
379
do! Async.Sleep 1000
@@ -362,10 +387,12 @@ let tests =
362
387
bob.EventAggregator.AwaitChannelEvent(function WeAcceptedCommitmentSigned (revokeAndAck, commitments) -> Some (revokeAndAck, commitments) | _ -> None)
363
388
do! alice.CM.AcceptCommandAsync({ NodeId = bobNodeId; ChannelCommand = SignCommitment }).AsTask() |> Async.AwaitTask
364
389
let! r = aliceAcceptedSign
365
- Expect.isSome r "timeout"
390
+ Expect.isSome r "timeout waiting for alice to accept sign command "
366
391
let! r = bobAcceptedSign
392
+ Expect.isSome r "timeout waiting for bob to accept commitment signature"
367
393
let revokeAndAck, bobCommitments = r.Value
368
394
let! r = aliceAcceptedRevokeAndAck
395
+ Expect.isSome r "timeout waiting for alice to accept revoke_and_ack"
369
396
let aliceCommitments = r.Value
370
397
371
398
@@ -412,29 +439,36 @@ let tests =
412
439
""
413
440
*)
414
441
415
-
442
+ do ! ActorCreator.sendGeewalletPayment alice bob
416
443
417
444
do ! Async.Sleep 1000
418
- Console.WriteLine( " testing geewallet payment " )
445
+ Console.WriteLine( " alice signs her commit " )
419
446
447
+ let aliceAcceptedSign =
448
+ alice.EventAggregator.AwaitChannelEvent( function WeAcceptedCMDSign (_, commitments) -> Some commitments | _ -> None)
449
+ let bobAcceptedSign =
450
+ bob.EventAggregator.AwaitChannelEvent( function WeAcceptedCommitmentSigned ( revokeAndAck, commitments) -> Some ( revokeAndAck, commitments) | _ -> None)
451
+ do ! alice.CM.AcceptCommandAsync({ NodeId = bobNodeId; ChannelCommand = SignCommitment }). AsTask() |> Async.AwaitTask
452
+ let! r = aliceAcceptedSign
453
+ Expect.isSome r " timeout waiting for alice to accept sign command"
454
+ let! r = bobAcceptedSign
455
+ Expect.isSome r " timeout waiting for bob to accept commitment signature"
420
456
421
- let aliceToBobAmount = 1000 L |> LNMoney.MilliSatoshis
422
- let geewalletPaymentCmd = {
423
- Amount = aliceToBobAmount
424
- }
457
+ do ! Async.Sleep 1000
458
+ Console.WriteLine( " finishing geewallet payment test" )
459
+ }
425
460
426
- // Send geewallet payment from alice to bob
427
- let bobAcceptedGeewalletPaymentTask =
428
- bob.EventAggregator.AwaitChannelEvent( function WeAcceptedGeewalletPayment _ -> Some () | _ -> None)
429
- do !
430
- alice.CM.AcceptCommandAsync({
431
- NodeId = bobNodeId
432
- ChannelCommand = ChannelCommand.GeewalletPayment geewalletPaymentCmd
433
- }) .AsTask() |> Async.AwaitTask
461
+ ptestAsync " Send geewallet payment with revoke_and_ack" {
462
+ do ! Async.Sleep 1000
434
463
435
- let! r = bobAcceptedGeewalletPaymentTask
436
- Expect.isSome r " timeout waiting for bob to accept geewallet payment"
464
+ Console.WriteLine( " starting geewallet payment test" )
465
+ let alice = ActorCreator.getAlice()
466
+ let bob = ActorCreator.getBob()
467
+ let! actors = ActorCreator.initiateOpenedChannel( alice, bob)
468
+ let bobNodeId = bob.CM.KeysRepository.GetNodeSecret() .PubKey |> NodeId
469
+ let aliceNodeId = alice.CM.KeysRepository.GetNodeSecret() .PubKey |> NodeId
437
470
471
+ do ! ActorCreator.sendGeewalletPayment alice bob
438
472
439
473
do ! Async.Sleep 1000
440
474
Console.WriteLine( " alice signs her commit" )
@@ -447,18 +481,19 @@ let tests =
447
481
bob.EventAggregator.AwaitChannelEvent( function WeAcceptedCommitmentSigned ( revokeAndAck, commitments) -> Some ( revokeAndAck, commitments) | _ -> None)
448
482
do ! alice.CM.AcceptCommandAsync({ NodeId = bobNodeId; ChannelCommand = SignCommitment }). AsTask() |> Async.AwaitTask
449
483
let! r = aliceAcceptedSign
450
- Expect.isSome r " timeout"
484
+ Expect.isSome r " timeout waiting for alice to accept sign command "
451
485
let! r = bobAcceptedSign
486
+ Expect.isSome r " timeout waiting for bob to accept commitment signature"
452
487
let revokeAndAck , bobCommitments = r.Value
488
+ Expect.isSome r " timeout waiting for alice to accept revoke_and_ack"
453
489
let! r = aliceAcceptedRevokeAndAck
454
490
let aliceCommitments = r.Value
455
491
456
-
457
492
do ! Async.Sleep 1000
458
493
Console.WriteLine( sprintf " alice now has: %s sat" ( aliceCommitments.LocalCommit.Spec.ToLocal.ToString()))
459
- Console.WriteLine( " finishing geewallet payment test" )
494
+ Console.WriteLine( " finishing geewallet payment with revoke_and_ack test" )
460
495
}
461
-
496
+
462
497
ptestAsync " Normal channel operation" {
463
498
let alice = ActorCreator.getAlice()
464
499
let bob = ActorCreator.getBob()
0 commit comments