2019-09-23 19:24:42 +00:00
|
|
|
package blockchain
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-04-18 20:42:07 +00:00
|
|
|
"io"
|
2019-09-23 19:24:42 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
2022-04-06 11:05:53 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
2021-09-23 18:53:46 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/testing/require"
|
2022-04-06 11:05:53 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/testing/util"
|
2019-09-23 19:24:42 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
logrus.SetLevel(logrus.DebugLevel)
|
2022-04-18 20:42:07 +00:00
|
|
|
logrus.SetOutput(io.Discard)
|
2019-09-23 19:24:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestChainService_SaveHead_DataRace(t *testing.T) {
|
2020-12-18 19:12:30 +00:00
|
|
|
beaconDB := testDB.SetupDB(t)
|
2019-09-23 19:24:42 +00:00
|
|
|
s := &Service{
|
2021-10-18 17:48:05 +00:00
|
|
|
cfg: &config{BeaconDB: beaconDB},
|
2019-09-23 19:24:42 +00:00
|
|
|
}
|
2022-04-06 11:05:53 +00:00
|
|
|
b, err := wrapper.WrappedSignedBeaconBlock(util.NewBeaconBlock())
|
2022-04-06 23:36:52 +00:00
|
|
|
st, _ := util.DeterministicGenesisState(t, 1)
|
2022-04-06 11:05:53 +00:00
|
|
|
require.NoError(t, err)
|
2019-09-23 19:24:42 +00:00
|
|
|
go func() {
|
2022-04-06 23:36:52 +00:00
|
|
|
require.NoError(t, s.saveHead(context.Background(), [32]byte{}, b, st))
|
2019-09-23 19:24:42 +00:00
|
|
|
}()
|
2022-04-06 23:36:52 +00:00
|
|
|
require.NoError(t, s.saveHead(context.Background(), [32]byte{}, b, st))
|
2019-09-23 19:24:42 +00:00
|
|
|
}
|