Skip to content

Commit 6cacee9

Browse files
committed
itest: add assertion to ensure recv node publishes recv complete event
This commit adds an assertion function which blocks until the receiver tapd node publishes an asset receive complete event.
1 parent a3cddca commit 6cacee9

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

itest/send_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,13 @@ func testReattemptFailedReceiveUniCourier(t *harnessTest) {
944944
// proof(s).
945945
t.Logf("Attempting to confirm asset received by receiver node")
946946
AssertNonInteractiveRecvComplete(t.t, receiveTapd, 1)
947+
948+
// Confirm that the sender tapd node eventually receives the asset
949+
// transfer and publishes an asset recv complete event.
950+
t.Logf("Check for asset recv complete event from receiver tapd node")
951+
assertAssetRecvCompleteEvent(
952+
t, ctxb, 5*time.Second, recvAddr.Encoded, eventNtfns,
953+
)
947954
}
948955

949956
// testOfflineReceiverEventuallyReceives tests that a receiver node will
@@ -1157,6 +1164,29 @@ func assertAssetRecvNtfsEvent(t *harnessTest, ctx context.Context,
11571164
expectedCount, countFound)
11581165
}
11591166

1167+
// assertAssetRecvNtfsEvent asserts that the given asset receive complete event
1168+
// notification was received. This function will block until the event is
1169+
// received or the event stream is closed.
1170+
func assertAssetRecvCompleteEvent(t *harnessTest, ctxb context.Context,
1171+
timeout time.Duration, encodedAddr string,
1172+
eventNtfns taprpc.TaprootAssets_SubscribeReceiveAssetEventNtfnsClient) {
1173+
1174+
ctx, cancel := context.WithTimeout(ctxb, timeout)
1175+
defer cancel()
1176+
1177+
eventSelector := func(event *taprpc.ReceiveAssetEvent) bool {
1178+
switch eventTyped := event.Event.(type) {
1179+
case *taprpc.ReceiveAssetEvent_AssetReceiveCompleteEvent:
1180+
ev := eventTyped.AssetReceiveCompleteEvent
1181+
return encodedAddr == ev.Address.Encoded
1182+
default:
1183+
return false
1184+
}
1185+
}
1186+
1187+
assertAssetRecvNtfsEvent(t, ctx, eventNtfns, eventSelector, 1)
1188+
}
1189+
11601190
// testMultiInputSendNonInteractiveSingleID tests that we can properly
11611191
// non-interactively send a single asset from multiple inputs.
11621192
//

0 commit comments

Comments
 (0)