From 9e7406e03e8c752655408de0715c282aa881a627 Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Mon, 26 Aug 2024 21:07:59 +0200 Subject: [PATCH] core/services/ocr/plugins/llo: fix onchain cache test race (#14232) --- .../llo/onchain_channel_definition_cache_integration_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/services/ocr2/plugins/llo/onchain_channel_definition_cache_integration_test.go b/core/services/ocr2/plugins/llo/onchain_channel_definition_cache_integration_test.go index 6103fbbaf49..d084e51531c 100644 --- a/core/services/ocr2/plugins/llo/onchain_channel_definition_cache_integration_test.go +++ b/core/services/ocr2/plugins/llo/onchain_channel_definition_cache_integration_test.go @@ -58,6 +58,7 @@ func (h *mockHTTPClient) SetResponse(resp *http.Response, err error) { type MockReadCloser struct { data []byte + mu sync.RWMutex reader *bytes.Reader } @@ -70,11 +71,15 @@ func NewMockReadCloser(data []byte) *MockReadCloser { // Read reads from the underlying data func (m *MockReadCloser) Read(p []byte) (int, error) { + m.mu.RLock() + defer m.mu.RUnlock() return m.reader.Read(p) } // Close resets the reader to the beginning of the data func (m *MockReadCloser) Close() error { + m.mu.Lock() + defer m.mu.Unlock() m.reader.Seek(0, io.SeekStart) return nil }