@@ -54,20 +54,9 @@ func testBasicSendUnidirectional(t *harnessTest) {
54
54
55
55
broadcastState := tapfreighter .SendStateBroadcast .String ()
56
56
targetEventSelector := func (event * taprpc.SendAssetEvent ) bool {
57
- switch eventTyped := event .Event .(type ) {
58
- case * taprpc.SendAssetEvent_ExecuteSendStateEvent :
59
- ev := eventTyped .ExecuteSendStateEvent
60
-
61
- // Log send state execution.
62
- timestamp := time .UnixMicro (ev .Timestamp )
63
- t .Logf ("Executing send state (%v): %v" ,
64
- timestamp .Format (time .RFC3339Nano ),
65
- ev .SendState )
66
-
67
- return ev .SendState == broadcastState
68
- }
69
-
70
- return false
57
+ return AssertSendEventExecuteSendState (
58
+ t , event , broadcastState ,
59
+ )
71
60
}
72
61
73
62
timeout := 2 * defaultProofTransferReceiverAckTimeout
@@ -168,20 +157,9 @@ func testRestartReceiverCheckBalance(t *harnessTest) {
168
157
169
158
broadcastState := tapfreighter .SendStateBroadcast .String ()
170
159
targetEventSelector := func (event * taprpc.SendAssetEvent ) bool {
171
- switch eventTyped := event .Event .(type ) {
172
- case * taprpc.SendAssetEvent_ExecuteSendStateEvent :
173
- ev := eventTyped .ExecuteSendStateEvent
174
-
175
- // Log send state execution.
176
- timestamp := time .UnixMicro (ev .Timestamp )
177
- t .Logf ("Executing send state (%v): %v" ,
178
- timestamp .Format (time .RFC3339Nano ),
179
- ev .SendState )
180
-
181
- return ev .SendState == broadcastState
182
- }
183
-
184
- return false
160
+ return AssertSendEventExecuteSendState (
161
+ t , event , broadcastState ,
162
+ )
185
163
}
186
164
187
165
timeout := 2 * defaultProofTransferReceiverAckTimeout
@@ -620,18 +598,9 @@ func testReattemptFailedSendHashmailCourier(t *harnessTest) {
620
598
// Define a target event selector to match the backoff wait
621
599
// event. This function selects for a specific event type.
622
600
targetEventSelector := func (event * taprpc.SendAssetEvent ) bool {
623
- switch eventTyped := event .Event .(type ) {
624
- case * taprpc.SendAssetEvent_ProofTransferBackoffWaitEvent :
625
- ev := eventTyped .ProofTransferBackoffWaitEvent
626
- if ev .TransferType != transferTypeSend {
627
- return false
628
- }
629
-
630
- t .Logf ("Found event ntfs: %v" , ev )
631
- return true
632
- }
633
-
634
- return false
601
+ return AssertSendEventProofTransferBackoffWaitTypeSend (
602
+ t , event ,
603
+ )
635
604
}
636
605
637
606
// Expected number of events is one less than the number of
@@ -727,18 +696,9 @@ func testReattemptFailedSendUniCourier(t *harnessTest) {
727
696
// Define a target event selector to match the backoff wait
728
697
// event. This function selects for a specific event type.
729
698
targetEventSelector := func (event * taprpc.SendAssetEvent ) bool {
730
- switch eventTyped := event .Event .(type ) {
731
- case * taprpc.SendAssetEvent_ProofTransferBackoffWaitEvent :
732
- ev := eventTyped .ProofTransferBackoffWaitEvent
733
- if ev .TransferType != transferTypeSend {
734
- return false
735
- }
736
-
737
- t .Logf ("Found event ntfs: %v" , ev )
738
- return true
739
- }
740
-
741
- return false
699
+ return AssertSendEventProofTransferBackoffWaitTypeSend (
700
+ t , event ,
701
+ )
742
702
}
743
703
744
704
// Expected number of events is one less than the number of
@@ -889,22 +849,21 @@ func testReattemptFailedReceiveUniCourier(t *harnessTest) {
889
849
// Define a target event selector to match the backoff wait event. This
890
850
// function selects for a specific event type.
891
851
targetEventSelector := func (event * taprpc.ReceiveAssetEvent ) bool {
892
- switch eventTyped := event .Event .(type ) {
893
- case * taprpc.ReceiveAssetEvent_ProofTransferBackoffWaitEvent :
894
- ev := eventTyped .ProofTransferBackoffWaitEvent
895
-
896
- // We are attempting to identify receive transfer types.
897
- // Skip the event if it is not a receiving transfer
898
- // type.
899
- if ev .TransferType != taprpc .ProofTransferType_PROOF_TRANSFER_TYPE_RECEIVE {
900
- return false
901
- }
852
+ ev := event .GetProofTransferBackoffWaitEvent ()
853
+ if ev == nil {
854
+ return false
855
+ }
902
856
903
- t .Logf ("Found event ntfs: %v" , ev )
904
- return true
857
+ // We are attempting to identify receive transfer types.
858
+ // Skip the event if it is not a receiving transfer
859
+ // type.
860
+ typeRecv := taprpc .ProofTransferType_PROOF_TRANSFER_TYPE_RECEIVE
861
+ if ev .TransferType != typeRecv {
862
+ return false
905
863
}
906
864
907
- return false
865
+ t .Logf ("Found event ntfs: %v" , ev )
866
+ return true
908
867
}
909
868
910
869
// Expected minimum number of events to receive.
@@ -996,23 +955,12 @@ func testOfflineReceiverEventuallyReceives(t *harnessTest) {
996
955
// Define a target event selector to match the backoff wait
997
956
// event. This function selects for a specific event type.
998
957
targetEventSelector := func (event * taprpc.SendAssetEvent ) bool {
999
- switch eventTyped := event .Event .(type ) {
1000
- case * taprpc.SendAssetEvent_ProofTransferBackoffWaitEvent :
1001
- ev := eventTyped .ProofTransferBackoffWaitEvent
1002
-
1003
- // We're listening for events on the sender
1004
- // node. We therefore expect to receive
1005
- // deliver transfer type backoff wait events
1006
- // for sending transfers.
1007
- if ev .TransferType != transferTypeSend {
1008
- return false
1009
- }
1010
-
1011
- t .Logf ("Found event ntfs: %v" , ev )
1012
- return true
1013
- }
1014
-
1015
- return false
958
+ // We're listening for events on the sender node. We
959
+ // therefore expect to receive deliver transfer type
960
+ // backoff wait events for sending transfers.
961
+ return AssertSendEventProofTransferBackoffWaitTypeSend (
962
+ t , event ,
963
+ )
1016
964
}
1017
965
1018
966
// Lower bound number of proof delivery attempts.
0 commit comments