From 81733d9de4f322a574842c528f2eaa38cec11a4a Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Thu, 29 Aug 2024 19:34:15 +0200 Subject: [PATCH] core/services/ocr2/plugins/llo: use write lock during mock read closer Reads (#14276) --- ...nchain_channel_definition_cache_integration_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 d084e51531c..6067887681c 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,7 +58,7 @@ func (h *mockHTTPClient) SetResponse(resp *http.Response, err error) { type MockReadCloser struct { data []byte - mu sync.RWMutex + mu sync.Mutex reader *bytes.Reader } @@ -71,8 +71,8 @@ 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() + m.mu.Lock() + defer m.mu.Unlock() return m.reader.Read(p) } @@ -80,8 +80,8 @@ func (m *MockReadCloser) Read(p []byte) (int, error) { func (m *MockReadCloser) Close() error { m.mu.Lock() defer m.mu.Unlock() - m.reader.Seek(0, io.SeekStart) - return nil + _, err := m.reader.Seek(0, io.SeekStart) + return err } func Test_ChannelDefinitionCache_Integration(t *testing.T) {