Skip to content

Commit f8843fa

Browse files
author
ffranr
authored
Merge pull request #734 from lightninglabs/proof-courier-cleanup
proof courier: general cleanup and refactor, re-try after restart
2 parents 76bb5ae + 016016b commit f8843fa

File tree

11 files changed

+655
-379
lines changed

11 files changed

+655
-379
lines changed

itest/send_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ import (
2121
"github.com/stretchr/testify/require"
2222
)
2323

24+
var (
25+
transferTypeSend = taprpc.ProofTransferType_PROOF_TRANSFER_TYPE_SEND
26+
)
27+
2428
// testBasicSendUnidirectional tests that we can properly send assets back and
2529
// forth between nodes.
2630
func testBasicSendUnidirectional(t *harnessTest) {
@@ -619,7 +623,7 @@ func testReattemptFailedSendHashmailCourier(t *harnessTest) {
619623
switch eventTyped := event.Event.(type) {
620624
case *taprpc.SendAssetEvent_ProofTransferBackoffWaitEvent:
621625
ev := eventTyped.ProofTransferBackoffWaitEvent
622-
if ev.TransferType != taprpc.ProofTransferType_PROOF_TRANSFER_TYPE_SEND {
626+
if ev.TransferType != transferTypeSend {
623627
return false
624628
}
625629

@@ -726,7 +730,7 @@ func testReattemptFailedSendUniCourier(t *harnessTest) {
726730
switch eventTyped := event.Event.(type) {
727731
case *taprpc.SendAssetEvent_ProofTransferBackoffWaitEvent:
728732
ev := eventTyped.ProofTransferBackoffWaitEvent
729-
if ev.TransferType != taprpc.ProofTransferType_PROOF_TRANSFER_TYPE_SEND {
733+
if ev.TransferType != transferTypeSend {
730734
return false
731735
}
732736

@@ -1000,7 +1004,7 @@ func testOfflineReceiverEventuallyReceives(t *harnessTest) {
10001004
// node. We therefore expect to receive
10011005
// deliver transfer type backoff wait events
10021006
// for sending transfers.
1003-
if ev.TransferType != taprpc.ProofTransferType_PROOF_TRANSFER_TYPE_SEND {
1007+
if ev.TransferType != transferTypeSend {
10041008
return false
10051009
}
10061010

itest/tapd_harness.go

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,19 @@ var (
4747
"allow the postgres fixture to run in total. Needs "+
4848
"to be increased for long-running tests.")
4949

50-
// defaultBackoffConfig is the default backoff config we'll use for
51-
// sending proofs.
52-
defaultBackoffConfig = proof.BackoffCfg{
50+
// defaultHashmailBackoffConfig is the default backoff config we'll use
51+
// for sending proofs with the hashmail courier.
52+
defaultHashmailBackoffConfig = proof.BackoffCfg{
53+
BackoffResetWait: time.Second,
54+
NumTries: 5,
55+
InitialBackoff: 300 * time.Millisecond,
56+
MaxBackoff: 600 * time.Millisecond,
57+
}
58+
59+
// defaultUniverseRpcBackoffConfig is the default backoff config we'll
60+
// use for sending proofs with the universe RPC courier.
61+
defaultUniverseRpcBackoffConfig = proof.BackoffCfg{
62+
SkipInitDelay: true,
5363
BackoffResetWait: time.Second,
5464
NumTries: 5,
5565
InitialBackoff: 300 * time.Millisecond,
@@ -66,7 +76,7 @@ const (
6676
// defaultProofTransferReceiverAckTimeout is the default itest specific
6777
// timeout we'll use for waiting for a receiver to acknowledge a proof
6878
// transfer.
69-
defaultProofTransferReceiverAckTimeout = 15 * time.Second
79+
defaultProofTransferReceiverAckTimeout = 5 * time.Second
7080
)
7181

7282
// tapdHarness is a test harness that holds everything that is needed to
@@ -209,9 +219,11 @@ func newTapdHarness(t *testing.T, ht *harnessTest, cfg tapdConfig,
209219
// Populate proof courier specific config fields.
210220
//
211221
// Use passed in backoff config or default config.
212-
backoffCfg := defaultBackoffConfig
222+
hashmailBackoffCfg := defaultHashmailBackoffConfig
223+
universeRpcBackoffCfg := defaultUniverseRpcBackoffConfig
213224
if opts.proofSendBackoffCfg != nil {
214-
backoffCfg = *opts.proofSendBackoffCfg
225+
hashmailBackoffCfg = *opts.proofSendBackoffCfg
226+
universeRpcBackoffCfg = *opts.proofSendBackoffCfg
215227
}
216228

217229
// Used passed in proof receiver ack timeout or default.
@@ -220,12 +232,12 @@ func newTapdHarness(t *testing.T, ht *harnessTest, cfg tapdConfig,
220232
receiverAckTimeout = *opts.proofReceiverAckTimeout
221233
}
222234

223-
// TODO(ffranr): Disentangle the hashmail config from the universe RPC
224-
// courier config. Right now, the universe courier takes the backoff
225-
// config from the hashmail courier config.
226235
finalCfg.HashMailCourier = &proof.HashMailCourierCfg{
227236
ReceiverAckTimeout: receiverAckTimeout,
228-
BackoffCfg: &backoffCfg,
237+
BackoffCfg: &hashmailBackoffCfg,
238+
}
239+
finalCfg.UniverseRpcCourier = &proof.UniverseRpcCourierCfg{
240+
BackoffCfg: &universeRpcBackoffCfg,
229241
}
230242

231243
switch typedProofCourier := (opts.proofCourier).(type) {
@@ -243,7 +255,6 @@ func newTapdHarness(t *testing.T, ht *harnessTest, cfg tapdConfig,
243255

244256
default:
245257
finalCfg.DefaultProofCourierAddr = ""
246-
finalCfg.HashMailCourier = nil
247258
}
248259

249260
ht.t.Logf("Using proof courier address: %v",

0 commit comments

Comments
 (0)