mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-04 00:44:27 +00:00
80 lines
1.6 KiB
Go
80 lines
1.6 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,
|
|
canonicalRoots: make(map[uint64][]byte),
|
|
}
|
|
go func() {
|
|
s.saveHead(
|
|
context.Background(),
|
|
ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Slot: 777}},
|
|
[32]byte{},
|
|
)
|
|
}()
|
|
s.HeadSlot()
|
|
}
|
|
|
|
func TestHeadRoot_DataRace(t *testing.T) {
|
|
db := testDB.SetupDB(t)
|
|
defer testDB.TeardownDB(t, db)
|
|
s := &Service{
|
|
beaconDB: db,
|
|
canonicalRoots: make(map[uint64][]byte),
|
|
}
|
|
go func() {
|
|
s.saveHead(
|
|
context.Background(),
|
|
ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Slot: 777}},
|
|
[32]byte{},
|
|
)
|
|
}()
|
|
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,
|
|
canonicalRoots: make(map[uint64][]byte),
|
|
}
|
|
go func() {
|
|
s.saveHead(
|
|
context.Background(),
|
|
ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Slot: 777}},
|
|
[32]byte{},
|
|
)
|
|
}()
|
|
s.HeadBlock()
|
|
}
|
|
|
|
func TestHeadState_DataRace(t *testing.T) {
|
|
db := testDB.SetupDB(t)
|
|
defer testDB.TeardownDB(t, db)
|
|
s := &Service{
|
|
beaconDB: db,
|
|
canonicalRoots: make(map[uint64][]byte),
|
|
}
|
|
go func() {
|
|
s.saveHead(
|
|
context.Background(),
|
|
ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Slot: 777}},
|
|
[32]byte{},
|
|
)
|
|
}()
|
|
s.HeadState(context.Background())
|
|
}
|