2019-09-23 19:24:42 +00:00
|
|
|
package blockchain
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
2019-11-27 05:08:18 +00:00
|
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
2019-09-23 19:24:42 +00:00
|
|
|
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.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.BeaconBlock{Slot: 777},
|
|
|
|
[32]byte{},
|
|
|
|
)
|
|
|
|
}()
|
|
|
|
s.HeadRoot()
|
|
|
|
}
|
|
|
|
|
|
|
|
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.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.BeaconBlock{Slot: 777},
|
|
|
|
[32]byte{},
|
|
|
|
)
|
|
|
|
}()
|
2019-11-19 16:12:50 +00:00
|
|
|
s.HeadState(context.Background())
|
2019-09-23 19:24:42 +00:00
|
|
|
}
|