mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-09 03:01:19 +00:00
97905c3e79
* Different files * Preston's feedback
67 lines
1.8 KiB
Go
67 lines
1.8 KiB
Go
package operations
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/go-bitfield"
|
|
dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/shared/params"
|
|
)
|
|
|
|
func TestReceiveBlkRemoveOps_Ok(t *testing.T) {
|
|
beaconDB := dbutil.SetupDB(t)
|
|
defer dbutil.TeardownDB(t, beaconDB)
|
|
s := NewService(context.Background(), &Config{BeaconDB: beaconDB})
|
|
|
|
attestations := make([]*ethpb.Attestation, 10)
|
|
for i := 0; i < len(attestations); i++ {
|
|
attestations[i] = ðpb.Attestation{
|
|
Data: ðpb.AttestationData{
|
|
Crosslink: ðpb.Crosslink{
|
|
Shard: uint64(i),
|
|
},
|
|
Source: ðpb.Checkpoint{},
|
|
Target: ðpb.Checkpoint{},
|
|
},
|
|
AggregationBits: bitfield.Bitlist{0b11},
|
|
}
|
|
if err := s.beaconDB.SaveAttestation(context.Background(), attestations[i]); err != nil {
|
|
t.Fatalf("Failed to save attestation: %v", err)
|
|
}
|
|
}
|
|
|
|
headBlockRoot := [32]byte{1, 2, 3}
|
|
if err := beaconDB.SaveHeadBlockRoot(context.Background(), headBlockRoot); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := beaconDB.SaveState(context.Background(), &pb.BeaconState{
|
|
Slot: 15,
|
|
CurrentCrosslinks: []*ethpb.Crosslink{{
|
|
StartEpoch: 0,
|
|
DataRoot: params.BeaconConfig().ZeroHash[:]}}}, headBlockRoot); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
block := ðpb.BeaconBlock{
|
|
Body: ðpb.BeaconBlockBody{
|
|
Attestations: attestations,
|
|
},
|
|
}
|
|
|
|
s.incomingProcessedBlock <- block
|
|
if err := s.handleProcessedBlock(context.Background(), block); err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
atts, err := s.AttestationPool(context.Background(), 15)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(atts) != 0 {
|
|
t.Errorf("Attestation pool should be empty but got a length of %d", len(atts))
|
|
}
|
|
}
|