8000 test: wait for virtual bus capture before ISO-TP retention checks by tomrford · Pull Request #56 · tomrford/gocan · GitHub
[go: up one dir, main page]

Skip to content
8000
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion isotp/isotp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ func TestSendAndReceivePairedLinks(t *testing.T) {

sent := make(chan error, 1)
for index, payload := range payloads {
// Other virtual buses record RX copies after Send returns. Wait
// until those appends finish so retention snapshots are stable.
synctest.Wait()
start := capture.End()
go func() { sent <- sender.Send(ctx, payload) }()
synctest.Wait()
Expand Down Expand Up @@ -365,7 +368,10 @@ func TestSendAndReceivePairedLinks(t *testing.T) {
if err := <-result; !errors.Is(err, context.Canceled) {
t.Fatalf("queued Begin: %v", err)
}
if duringQueue != want || sender.RetentionCursor() != want {
if duringQueue != want {
t.Fatal("queued operation changed send retention")
}
if sender.RetentionCursor() != want {
t.Fatal("queued cancellation changed send retention")
}
if err := capture.Prune(sender.RetentionCursor(), receiver.Cursor()); err != nil {
Expand All @@ -382,6 +388,7 @@ func TestSendAndReceivePairedLinks(t *testing.T) {
if err := <-sent; err != nil {
t.Fatalf("Send payload %d: %v", index, err)
}
synctest.Wait()
if sender.RetentionCursor() != capture.End() || receiver.RetentionCursor() != capture.End() {
t.Fatal("completed transfer retained history")
}
Expand All @@ -394,6 +401,7 @@ func TestSendAndReceivePairedLinks(t *testing.T) {
if err := <-sent; !errors.Is(err, context.Canceled) {
t.Fatalf("cancelled Send: %v", err)
}
synctest.Wait()
if sender.RetentionCursor() != capture.End() {
t.Fatal("cancelled Send retained history")
}
Expand Down
0