Skip to content

Commit

Permalink
itest: add assertion to ensure recv node publishes recv complete event
Browse files Browse the repository at this point in the history
This commit adds an assertion function which blocks until the receiver
tapd node publishes an asset receive complete event.
  • Loading branch information
ffranr committed Nov 13, 2023
1 parent ea3029c commit 0674091
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions itest/send_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,10 @@ func testReattemptFailedReceiveUniCourier(t *harnessTest) {
// proof(s).
t.Logf("Attempting to confirm asset received by receiver node")
AssertNonInteractiveRecvComplete(t.t, receiveTapd, 1)

// Confirm that the sender tapd node eventually receives the asset
// transfer and publishes an asset recv complete event.
assertAssetRecvCompleteEvent(t, ctxb, 5*time.Second, eventNtfns)
}

// testOfflineReceiverEventuallyReceives tests that a receiver node will
Expand Down Expand Up @@ -967,6 +971,28 @@ func assertAssetRecvNtfsEvent(t *harnessTest, ctx context.Context,
expectedCount, countFound)
}

// assertAssetRecvNtfsEvent asserts that the given asset receive complete event
// notification was received. This function will block until the event is
// received or the event stream is closed.
func assertAssetRecvCompleteEvent(t *harnessTest, ctxb context.Context,
timeout time.Duration,
eventNtfns taprpc.TaprootAssets_SubscribeReceiveAssetEventNtfnsClient) {

ctx, cancel := context.WithTimeout(ctxb, timeout)
defer cancel()

eventSelector := func(event *taprpc.ReceiveAssetEvent) bool {
switch event.Event.(type) {
case *taprpc.ReceiveAssetEvent_AssetReceiveCompleteEvent:
return true
default:
return false
}
}

assertAssetRecvNtfsEvent(t, ctx, eventNtfns, eventSelector, 1)
}

// testMultiInputSendNonInteractiveSingleID tests that we can properly
// non-interactively send a single asset from multiple inputs.
//
Expand Down

0 comments on commit 0674091

Please sign in to comment.