mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-14 05:58:19 +00:00
test attestations are equal (#2274)
This commit is contained in:
parent
a9da23f444
commit
8a6b55e93c
@ -2,6 +2,7 @@ package rpc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -253,6 +254,15 @@ func TestPendingAttestations_FiltersExpiredAttestations(t *testing.T) {
|
|||||||
len(res.PendingAttestations),
|
len(res.PendingAttestations),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expectedAtts := []*pbp2p.Attestation{
|
||||||
|
{Data: &pbp2p.AttestationData{Slot: currentSlot - 5, JustifiedEpoch: expectedEpoch}},
|
||||||
|
{Data: &pbp2p.AttestationData{Slot: currentSlot - 2, JustifiedEpoch: expectedEpoch}},
|
||||||
|
{Data: &pbp2p.AttestationData{Slot: currentSlot, JustifiedEpoch: expectedEpoch}},
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(res.PendingAttestations, expectedAtts) {
|
||||||
|
t.Error("Did not receive expected attestations")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPendingAttestations_OK(t *testing.T) {
|
func TestPendingAttestations_OK(t *testing.T) {
|
||||||
@ -345,6 +355,8 @@ func TestPendingAttestations_FiltersCanonicalAttestations(t *testing.T) {
|
|||||||
t.Fatalf("couldnt update chainhead: %v", err)
|
t.Fatalf("couldnt update chainhead: %v", err)
|
||||||
}
|
}
|
||||||
for _, atts := range opService.pendingAttestations {
|
for _, atts := range opService.pendingAttestations {
|
||||||
|
// Insert all of the attestations, since last 3 attestations are same slot number
|
||||||
|
// the last 2 get overridden, and only the last 1 is canonical.
|
||||||
proposerServer.chainService.InsertsCanonical(atts.Data.Slot, atts.Data.BeaconBlockRootHash32)
|
proposerServer.chainService.InsertsCanonical(atts.Data.Slot, atts.Data.BeaconBlockRootHash32)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,4 +376,13 @@ func TestPendingAttestations_FiltersCanonicalAttestations(t *testing.T) {
|
|||||||
len(res.PendingAttestations),
|
len(res.PendingAttestations),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expectedAtts := []*pbp2p.Attestation{
|
||||||
|
{Data: &pbp2p.AttestationData{Slot: currentSlot - 5, JustifiedEpoch: expectedEpoch, BeaconBlockRootHash32: []byte{'A'}}},
|
||||||
|
{Data: &pbp2p.AttestationData{Slot: currentSlot - 2, JustifiedEpoch: expectedEpoch, BeaconBlockRootHash32: []byte{'B'}}},
|
||||||
|
{Data: &pbp2p.AttestationData{Slot: currentSlot, JustifiedEpoch: expectedEpoch, BeaconBlockRootHash32: []byte{'E'}}},
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(res.PendingAttestations, expectedAtts) {
|
||||||
|
t.Error("Did not receive expected attestations")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user