diff --git a/pkg/lexroundtrip/roundtrip_test.go b/pkg/lexroundtrip/roundtrip_test.go index a96c2854..a8cda5d5 100644 --- a/pkg/lexroundtrip/roundtrip_test.go +++ b/pkg/lexroundtrip/roundtrip_test.go @@ -31,12 +31,16 @@ func TestAdapterRegistryRoundtrip(t *testing.T) { } enc := buf.Bytes() - // $type must have been stamped by the adapter. - if orig.LexiconTypeID != "place.stream.livestream" { - t.Errorf("adapter did not stamp $type, got %q", orig.LexiconTypeID) + // Marshal stamps $type on a copy: the original record must NOT be + // mutated (a marshal that writes to the record is a data race for + // records marshaled concurrently). + if orig.LexiconTypeID != "" { + t.Errorf("marshal mutated the record's LexiconTypeID to %q", orig.LexiconTypeID) } // Decode via the glex runtime registry, exactly like the firehose does. + // Registry dispatch succeeding is itself proof $type was stamped into + // the encoded bytes. decoded, err := glex.CborDecodeValue(enc) if err != nil { t.Fatalf("CborDecodeValue: %v", err) @@ -45,6 +49,9 @@ func TestAdapterRegistryRoundtrip(t *testing.T) { if !ok { t.Fatalf("decoded to %T, want *placestream.Livestream", decoded) } + if ls.LexiconTypeID != "place.stream.livestream" { + t.Errorf("decoded $type: got %q, want place.stream.livestream", ls.LexiconTypeID) + } if ls.Title != orig.Title || ls.CreatedAt != orig.CreatedAt { t.Errorf("scalar mismatch: got title=%q created=%q", ls.Title, ls.CreatedAt) }