mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
6b8ec26c56
* Nil check * Fixed tests * Covered rest of the codebase * Race tests Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
74 lines
1.3 KiB
Go
74 lines
1.3 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() {
|
|
s.saveHead(
|
|
context.Background(),
|
|
[32]byte{},
|
|
)
|
|
}()
|
|
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() {
|
|
s.saveHead(
|
|
context.Background(),
|
|
[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,
|
|
head: &head{block: ðpb.SignedBeaconBlock{}},
|
|
}
|
|
go func() {
|
|
s.saveHead(
|
|
context.Background(),
|
|
[32]byte{},
|
|
)
|
|
}()
|
|
s.HeadBlock(context.Background())
|
|
}
|
|
|
|
func TestHeadState_DataRace(t *testing.T) {
|
|
db := testDB.SetupDB(t)
|
|
defer testDB.TeardownDB(t, db)
|
|
s := &Service{
|
|
beaconDB: db,
|
|
}
|
|
go func() {
|
|
s.saveHead(
|
|
context.Background(),
|
|
[32]byte{},
|
|
)
|
|
}()
|
|
s.HeadState(context.Background())
|
|
}
|