File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
internal/test/ouroboros_mock Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -187,9 +187,12 @@ func (c *Connection) processInputEntry(entry ConversationEntry) error {
187187 if msg == nil {
188188 return fmt .Errorf ("received unknown message type: %d" , msgType )
189189 }
190- // Set CBOR for expected message to match received to make comparison easier
191- entry .InputMessage .SetCbor (msg .Cbor ())
192- // Compare received message to expected message
190+
191+ // Compare received message to expected message, excluding the cbor content
192+ //
193+ // As changing the CBOR of the expected message is not thread-safe, we instead clear the
194+ // CBOR of the received message
195+ msg .SetCbor (nil )
193196 if ! reflect .DeepEqual (msg , entry .InputMessage ) {
194197 return fmt .Errorf (
195198 "parsed message does not match expected value: got %#v, expected %#v" ,
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ type MessageBase struct {
3131
3232// SetCbor stores the original CBOR that was parsed
3333func (m * MessageBase ) SetCbor (data []byte ) {
34+ if data == nil {
35+ m .rawCbor = nil
36+ return
37+ }
3438 m .rawCbor = make ([]byte , len (data ))
3539 copy (m .rawCbor , data )
3640}
You can’t perform that action at this time.
0 commit comments