Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proof courier: general cleanup and refactor, re-try after restart #734

Merged
merged 10 commits into from
Jan 4, 2024
10 changes: 7 additions & 3 deletions itest/send_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import (
"github.com/stretchr/testify/require"
)

var (
transferTypeSend = taprpc.ProofTransferType_PROOF_TRANSFER_TYPE_SEND
)

// testBasicSendUnidirectional tests that we can properly send assets back and
// forth between nodes.
func testBasicSendUnidirectional(t *harnessTest) {
Expand Down Expand Up @@ -619,7 +623,7 @@ func testReattemptFailedSendHashmailCourier(t *harnessTest) {
switch eventTyped := event.Event.(type) {
case *taprpc.SendAssetEvent_ProofTransferBackoffWaitEvent:
ev := eventTyped.ProofTransferBackoffWaitEvent
if ev.TransferType != taprpc.ProofTransferType_PROOF_TRANSFER_TYPE_SEND {
if ev.TransferType != transferTypeSend {
return false
}

Expand Down Expand Up @@ -726,7 +730,7 @@ func testReattemptFailedSendUniCourier(t *harnessTest) {
switch eventTyped := event.Event.(type) {
case *taprpc.SendAssetEvent_ProofTransferBackoffWaitEvent:
ev := eventTyped.ProofTransferBackoffWaitEvent
if ev.TransferType != taprpc.ProofTransferType_PROOF_TRANSFER_TYPE_SEND {
if ev.TransferType != transferTypeSend {
return false
}

Expand Down Expand Up @@ -1000,7 +1004,7 @@ func testOfflineReceiverEventuallyReceives(t *harnessTest) {
// node. We therefore expect to receive
// deliver transfer type backoff wait events
// for sending transfers.
if ev.TransferType != taprpc.ProofTransferType_PROOF_TRANSFER_TYPE_SEND {
if ev.TransferType != transferTypeSend {
return false
}

Expand Down
33 changes: 22 additions & 11 deletions itest/tapd_harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,19 @@ var (
"allow the postgres fixture to run in total. Needs "+
"to be increased for long-running tests.")

// defaultBackoffConfig is the default backoff config we'll use for
// sending proofs.
defaultBackoffConfig = proof.BackoffCfg{
// defaultHashmailBackoffConfig is the default backoff config we'll use
// for sending proofs with the hashmail courier.
defaultHashmailBackoffConfig = proof.BackoffCfg{
BackoffResetWait: time.Second,
NumTries: 5,
InitialBackoff: 300 * time.Millisecond,
MaxBackoff: 600 * time.Millisecond,
}

// defaultUniverseRpcBackoffConfig is the default backoff config we'll
// use for sending proofs with the universe RPC courier.
defaultUniverseRpcBackoffConfig = proof.BackoffCfg{
SkipInitDelay: true,
BackoffResetWait: time.Second,
NumTries: 5,
InitialBackoff: 300 * time.Millisecond,
Expand All @@ -66,7 +76,7 @@ const (
// defaultProofTransferReceiverAckTimeout is the default itest specific
// timeout we'll use for waiting for a receiver to acknowledge a proof
// transfer.
defaultProofTransferReceiverAckTimeout = 15 * time.Second
defaultProofTransferReceiverAckTimeout = 5 * time.Second
)

// tapdHarness is a test harness that holds everything that is needed to
Expand Down Expand Up @@ -209,9 +219,11 @@ func newTapdHarness(t *testing.T, ht *harnessTest, cfg tapdConfig,
// Populate proof courier specific config fields.
//
// Use passed in backoff config or default config.
backoffCfg := defaultBackoffConfig
hashmailBackoffCfg := defaultHashmailBackoffConfig
universeRpcBackoffCfg := defaultUniverseRpcBackoffConfig
if opts.proofSendBackoffCfg != nil {
backoffCfg = *opts.proofSendBackoffCfg
hashmailBackoffCfg = *opts.proofSendBackoffCfg
universeRpcBackoffCfg = *opts.proofSendBackoffCfg
}

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

// TODO(ffranr): Disentangle the hashmail config from the universe RPC
// courier config. Right now, the universe courier takes the backoff
// config from the hashmail courier config.
finalCfg.HashMailCourier = &proof.HashMailCourierCfg{
ReceiverAckTimeout: receiverAckTimeout,
BackoffCfg: &backoffCfg,
BackoffCfg: &hashmailBackoffCfg,
}
finalCfg.UniverseRpcCourier = &proof.UniverseRpcCourierCfg{
BackoffCfg: &universeRpcBackoffCfg,
}

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

default:
finalCfg.DefaultProofCourierAddr = ""
finalCfg.HashMailCourier = nil
}

ht.t.Logf("Using proof courier address: %v",
Expand Down
Loading