prysm-pulse/beacon-chain/blockchain/service_norace_test.go

33 lines
858 B
Go
Raw Normal View History

package blockchain
import (
"context"
"io/ioutil"
"testing"
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/testing/require"
"github.com/prysmaticlabs/prysm/testing/util"
"github.com/sirupsen/logrus"
)
func init() {
logrus.SetLevel(logrus.DebugLevel)
logrus.SetOutput(ioutil.Discard)
}
func TestChainService_SaveHead_DataRace(t *testing.T) {
beaconDB := testDB.SetupDB(t)
s := &Service{
cfg: &config{BeaconDB: beaconDB},
}
b, err := wrapper.WrappedSignedBeaconBlock(util.NewBeaconBlock())
2022-04-06 23:36:52 +00:00
st, _ := util.DeterministicGenesisState(t, 1)
require.NoError(t, err)
go func() {
2022-04-06 23:36:52 +00:00
require.NoError(t, s.saveHead(context.Background(), [32]byte{}, b, st))
}()
2022-04-06 23:36:52 +00:00
require.NoError(t, s.saveHead(context.Background(), [32]byte{}, b, st))
}