mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-12 20:50:05 +00:00
bfbff885fe
* Implemented new fork choice service and helpers * Added rest of the tests * Lint * Add back helpers test * Add benchmark tests * Add yaml driven framework tests * Reformatted to doc, helpers and metrics.go * include new getter for block * create block filters from indices * give every block index a unique bucket * construct block indices by bucket mmap * almost done save for the block filters * include block filters, need a few more small touches for fetching the proper indices by bucket * full functionality to filter by parent root * tests pass when using the same logic as attestations * todo * proper todo formatting * first minimum slot range filter * slot range filters pass * more filter criteria passing * tests passing * add todos * all block tests pass and work * rem fmt * range retrieval test * fixed test conditions * Implemented new receive block methods * Comments * Remove mark evil block * instantiate the other buckets * simplify bucket lookups * deprecate non map code * revamp to remove old index prefixes * create indices from data * create indices from data * fetch block roots by slot range * better abstractions * simpler abstractions * roots rename * comment * preston feedback * Fixed existing tests * allow blocks without parent root * Cleaned up a few things * Removed todo * Lint * Cleaned up a few things * A few functions don't need to be exported * Gaz * Fixed visibility * Review feedback * Review feedback part1 * Raul's feedback, refactored OnBlock and OnAttestation to its own file * Fixed grammar * Lint * Renamed to receive_block.go * Use time.Time * Preston's feedback, removed OnTick and Store.time * Dont have to cast it to kv * add block caching layer * runlock * lockinggg * Fixed * Avoid 2 fetches of the same data * latest votes map * Gaz * Test passes * Lint * Fixed db set up * Fixed all the tests * Gazelle * Added tests * Remove todo * remove kv * Last clean up * Last clean up Last clean up * Lint * Preston's feedback * Starting * Gazelle
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package blockchain
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"testing"
|
|
|
|
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
|
)
|
|
|
|
// Ensure ChainService implements chain info interface.
|
|
var _ = ChainInfoRetriever(&ChainService{})
|
|
|
|
func TestFinalizedCheckpt_CanRetrieve(t *testing.T) {
|
|
db := testDB.SetupDB(t)
|
|
defer testDB.TeardownDB(t, db)
|
|
ctx := context.Background()
|
|
|
|
c := setupBeaconChain(t, db, nil)
|
|
|
|
s := &pb.BeaconState{}
|
|
if err := c.forkChoiceStore.GenesisStore(ctx, s); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if c.FinalizedCheckpt().Epoch != 0 {
|
|
t.Errorf("Finalized epoch at genesis should be 0, got: %d", c.FinalizedCheckpt().Epoch)
|
|
}
|
|
}
|
|
|
|
func TestHeadSlot_CanRetrieve(t *testing.T) {
|
|
c := &ChainService{}
|
|
c.headSlot = 100
|
|
if c.HeadSlot() != 100 {
|
|
t.Errorf("Wanted head slot: %d, got: %d", 100, c.HeadSlot())
|
|
}
|
|
}
|
|
|
|
func TestHeadRoot_CanRetrieve(t *testing.T) {
|
|
c := &ChainService{canonicalRoots: make(map[uint64][]byte)}
|
|
c.headSlot = 100
|
|
c.canonicalRoots[c.headSlot] = []byte{'A'}
|
|
if !bytes.Equal([]byte{'A'}, c.HeadRoot()) {
|
|
t.Errorf("Wanted head root: %v, got: %d", []byte{'A'}, c.HeadRoot())
|
|
}
|
|
}
|
|
|
|
func TestCanonicalRoot_CanRetrieve(t *testing.T) {
|
|
c := &ChainService{canonicalRoots: make(map[uint64][]byte)}
|
|
slot := uint64(123)
|
|
c.canonicalRoots[slot] = []byte{'B'}
|
|
if !bytes.Equal([]byte{'B'}, c.CanonicalRoot(slot)) {
|
|
t.Errorf("Wanted head root: %v, got: %d", []byte{'A'}, c.CanonicalRoot(slot))
|
|
}
|
|
}
|