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 27, 2023
1 parent a3cddca commit 6cacee9
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions itest/send_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,13 @@ 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.
t.Logf("Check for asset recv complete event from receiver tapd node")
assertAssetRecvCompleteEvent(
t, ctxb, 5*time.Second, recvAddr.Encoded, eventNtfns,
)
}

// testOfflineReceiverEventuallyReceives tests that a receiver node will
Expand Down Expand Up @@ -1157,6 +1164,29 @@ 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, encodedAddr string,
eventNtfns taprpc.TaprootAssets_SubscribeReceiveAssetEventNtfnsClient) {

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

eventSelector := func(event *taprpc.ReceiveAssetEvent) bool {
switch eventTyped := event.Event.(type) {
case *taprpc.ReceiveAssetEvent_AssetReceiveCompleteEvent:
ev := eventTyped.AssetReceiveCompleteEvent
return encodedAddr == ev.Address.Encoded
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 6cacee9

Please sign in to comment.