prysm-pulse/beacon-chain/blockchain/chain_info_norace_test.go
Victor Farazdagi 748d513c62
proper error checking and type assertions (#5424)
* proper error checking and type assertions
2020-04-14 16:41:09 +00:00

74 lines
1.5 KiB
Go

package blockchain
import (
"context"
"testing"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
)
func TestHeadSlot_DataRace(t *testing.T) {
db := testDB.SetupDB(t)
defer testDB.TeardownDB(t, db)
s := &Service{
beaconDB: db,
}
go func() {
if err := s.saveHead(context.Background(), [32]byte{}, ); err != nil {
t.Fatal(err)
}
}()
s.HeadSlot()
}
func TestHeadRoot_DataRace(t *testing.T) {
db := testDB.SetupDB(t)
defer testDB.TeardownDB(t, db)
s := &Service{
beaconDB: db,
head: &head{root: [32]byte{'A'}},
}
go func() {
if err := s.saveHead(context.Background(), [32]byte{}, ); err != nil {
t.Fatal(err)
}
}()
if _, err := s.HeadRoot(context.Background()); err != nil {
t.Fatal(err)
}
}
func TestHeadBlock_DataRace(t *testing.T) {
db := testDB.SetupDB(t)
defer testDB.TeardownDB(t, db)
s := &Service{
beaconDB: db,
head: &head{block: &ethpb.SignedBeaconBlock{}},
}
go func() {
if err := s.saveHead(context.Background(), [32]byte{}, ); err != nil {
t.Fatal(err)
}
}()
if _, err := s.HeadBlock(context.Background()); err != nil {
t.Fatal(err)
}
}
func TestHeadState_DataRace(t *testing.T) {
db := testDB.SetupDB(t)
defer testDB.TeardownDB(t, db)
s := &Service{
beaconDB: db,
}
go func() {
if err := s.saveHead(context.Background(), [32]byte{}, ); err != nil {
t.Fatal(err)
}
}()
if _, err := s.HeadState(context.Background()); err != nil {
t.Fatal(err)
}
}