test: events: fix race when recording tipsets (#10665)

fixes #10664
This commit is contained in:
Steven Allen 2023-04-13 17:20:34 -07:00 committed by GitHub
parent a7379e2cce
commit 3f74840b67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -174,13 +174,16 @@ func (fcs *fakeCS) makeTs(t *testing.T, parents []cid.Cid, h abi.ChainEpoch, msg
},
})
require.NoError(t, err)
fcs.mu.Lock()
defer fcs.mu.Unlock()
if fcs.tipsets == nil {
fcs.tipsets = map[types.TipSetKey]*types.TipSet{}
}
fcs.tipsets[ts.Key()] = ts
require.NoError(t, err)
return ts
}