@@ -369,32 +369,50 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
369
369
logBalance (t .t , nodes , assetID , "initial" )
370
370
371
371
// ------------
372
- // Test case 1: Send a direct keysend payment from Charlie to Dave.
372
+ // Test case 1: Send a direct keysend payment from Charlie to Dave,
373
+ // sending the whole balance.
373
374
// ------------
374
- const keySendAmount = 1000
375
+ keySendAmount := charlieFundingAmount
375
376
sendAssetKeySendPayment (
376
- t .t , charlie , dave , keySendAmount , assetID , fn .None [int64 ](),
377
+ t .t , charlie , dave , charlieFundingAmount , assetID ,
378
+ fn .None [int64 ](),
377
379
)
378
380
logBalance (t .t , nodes , assetID , "after keysend" )
379
381
380
382
charlieAssetBalance -= keySendAmount
381
383
daveAssetBalance += keySendAmount
382
384
383
- // We should be able to send the 1000 assets back immediately, because
385
+ // We should be able to send 1000 assets back immediately, because
384
386
// there is enough on-chain balance on Dave's side to be able to create
385
387
// an HTLC. We use an invoice to execute another code path.
388
+ const charlieInvoiceAmount = 1_000
386
389
invoiceResp := createAssetInvoice (
387
- t .t , dave , charlie , keySendAmount , assetID ,
390
+ t .t , dave , charlie , charlieInvoiceAmount , assetID ,
388
391
)
389
392
payInvoiceWithAssets (t .t , dave , charlie , invoiceResp , assetID , true )
393
+ logBalance (t .t , nodes , assetID , "after invoice back" )
390
394
391
- charlieAssetBalance += keySendAmount
392
- daveAssetBalance -= keySendAmount
395
+ charlieAssetBalance += charlieInvoiceAmount
396
+ daveAssetBalance -= charlieInvoiceAmount
393
397
394
- // We should also be able to do a non-asset (BTC only) keysend payment.
398
+ // We should also be able to do a non-asset (BTC only) keysend payment
399
+ // from Charlie to Dave. This'll also replenish the BTC balance of
400
+ // Dave, making it possible to send another asset HTLC below, sending
401
+ // all assets back to Charlie (so we have enough balance for further
402
+ // tests).
395
403
sendKeySendPayment (t .t , charlie , dave , 2000 , nil )
396
404
logBalance (t .t , nodes , assetID , "after BTC only keysend" )
397
405
406
+ // Let's keysend the rest of the balance back to Charlie.
407
+ sendAssetKeySendPayment (
408
+ t .t , dave , charlie , charlieFundingAmount - charlieInvoiceAmount ,
409
+ assetID , fn .None [int64 ](),
410
+ )
411
+ logBalance (t .t , nodes , assetID , "after keysend back" )
412
+
413
+ charlieAssetBalance += charlieFundingAmount - charlieInvoiceAmount
414
+ daveAssetBalance -= charlieFundingAmount - charlieInvoiceAmount
415
+
398
416
// ------------
399
417
// Test case 2: Pay a normal invoice from Dave by Charlie, making it
400
418
// a direct channel invoice payment with no RFQ SCID present in the
0 commit comments