|
4 | 4 | "testing" |
5 | 5 | "time" |
6 | 6 |
|
| 7 | + "github.com/jordanschalm/lockctx" |
7 | 8 | "github.com/stretchr/testify/assert" |
8 | 9 | "github.com/stretchr/testify/require" |
9 | 10 |
|
@@ -98,18 +99,15 @@ func TestBlockViewIndexLookup(t *testing.T) { |
98 | 99 | expected := flow.Identifier{0x01, 0x02, 0x03} |
99 | 100 |
|
100 | 101 | lockManager := storage.NewTestingLockManager() |
101 | | - lctx := lockManager.NewContext() |
102 | | - err := lctx.AcquireLock(storage.LockInsertBlock) |
103 | | - require.NoError(t, err) |
104 | | - defer lctx.Release() |
105 | 102 |
|
106 | | - err = db.WithReaderBatchWriter(func(rw storage.ReaderBatchWriter) error { |
107 | | - return operation.IndexCertifiedBlockByView(lctx, rw, view, expected) |
| 103 | + unittest.WithLock(t, lockManager, storage.LockInsertBlock, func(lctx lockctx.Context) error { |
| 104 | + return db.WithReaderBatchWriter(func(rw storage.ReaderBatchWriter) error { |
| 105 | + return operation.IndexCertifiedBlockByView(lctx, rw, view, expected) |
| 106 | + }) |
108 | 107 | }) |
109 | | - require.NoError(t, err) |
110 | 108 |
|
111 | 109 | var actual flow.Identifier |
112 | | - err = operation.LookupCertifiedBlockByView(db.Reader(), view, &actual) |
| 110 | + err := operation.LookupCertifiedBlockByView(db.Reader(), view, &actual) |
113 | 111 | require.NoError(t, err) |
114 | 112 |
|
115 | 113 | assert.Equal(t, expected, actual) |
|
0 commit comments