mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
96a110a193
* validation without signature * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * validation and update funcs * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge branch 'master' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * change order error handling * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * ivan feedback * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * add tests to blocks utils * terence feedback * reduce visibility * Merge branch 'master' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign # Conflicts: # validator/client/polling/validator_attest.go # validator/client/polling/validator_propose.go * fix metrics * fix error * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * copy behaviour to streaming * Merge branch 'slashing_protection_no_sign' of github.com:prysmaticlabs/prysm into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign * Merge refs/heads/master into slashing_protection_no_sign
102 lines
3.0 KiB
Go
102 lines
3.0 KiB
Go
package slashingprotection
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
eth "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
mockSlasher "github.com/prysmaticlabs/prysm/validator/testing"
|
|
)
|
|
|
|
func TestService_VerifyAttestation(t *testing.T) {
|
|
s := &Service{slasherClient: mockSlasher.MockSlasher{SlashAttestation: true}}
|
|
att := ð.IndexedAttestation{
|
|
AttestingIndices: []uint64{1, 2},
|
|
Data: ð.AttestationData{
|
|
Slot: 5,
|
|
CommitteeIndex: 2,
|
|
BeaconBlockRoot: []byte("great block"),
|
|
Source: ð.Checkpoint{
|
|
Epoch: 4,
|
|
Root: []byte("good source"),
|
|
},
|
|
Target: ð.Checkpoint{
|
|
Epoch: 10,
|
|
Root: []byte("good target"),
|
|
},
|
|
},
|
|
}
|
|
if s.VerifyAttestation(context.Background(), att) {
|
|
t.Error("Expected verify attestation to fail verification")
|
|
}
|
|
s = &Service{slasherClient: mockSlasher.MockSlasher{SlashAttestation: false}}
|
|
if !s.VerifyAttestation(context.Background(), att) {
|
|
t.Error("Expected verify attestation to pass verification")
|
|
}
|
|
}
|
|
|
|
func TestService_CommitAttestation(t *testing.T) {
|
|
s := &Service{slasherClient: mockSlasher.MockSlasher{SlashAttestation: true}}
|
|
att := ð.IndexedAttestation{
|
|
AttestingIndices: []uint64{1, 2},
|
|
Data: ð.AttestationData{
|
|
Slot: 5,
|
|
CommitteeIndex: 2,
|
|
BeaconBlockRoot: []byte("great block"),
|
|
Source: ð.Checkpoint{
|
|
Epoch: 4,
|
|
Root: []byte("good source"),
|
|
},
|
|
Target: ð.Checkpoint{
|
|
Epoch: 10,
|
|
Root: []byte("good target"),
|
|
},
|
|
},
|
|
}
|
|
if s.CommitAttestation(context.Background(), att) {
|
|
t.Error("Expected commit attestation to fail verification")
|
|
}
|
|
s = &Service{slasherClient: mockSlasher.MockSlasher{SlashAttestation: false}}
|
|
if !s.CommitAttestation(context.Background(), att) {
|
|
t.Error("Expected commit attestation to pass verification")
|
|
}
|
|
}
|
|
|
|
func TestService_CommitBlock(t *testing.T) {
|
|
s := &Service{slasherClient: mockSlasher.MockSlasher{SlashBlock: true}}
|
|
blk := ð.SignedBeaconBlockHeader{
|
|
Header: ð.BeaconBlockHeader{
|
|
Slot: 0,
|
|
ProposerIndex: 0,
|
|
ParentRoot: []byte("parent"),
|
|
StateRoot: []byte("state"),
|
|
BodyRoot: []byte("body"),
|
|
},
|
|
}
|
|
if s.CommitBlock(context.Background(), blk) {
|
|
t.Error("Expected commit block to fail verification")
|
|
}
|
|
s = &Service{slasherClient: mockSlasher.MockSlasher{SlashBlock: false}}
|
|
if !s.CommitBlock(context.Background(), blk) {
|
|
t.Error("Expected commit block to pass verification")
|
|
}
|
|
}
|
|
|
|
func TestService_VerifyBlock(t *testing.T) {
|
|
s := &Service{slasherClient: mockSlasher.MockSlasher{SlashBlock: true}}
|
|
blk := ð.BeaconBlockHeader{
|
|
Slot: 0,
|
|
ProposerIndex: 0,
|
|
ParentRoot: []byte("parent"),
|
|
StateRoot: []byte("state"),
|
|
BodyRoot: []byte("body"),
|
|
}
|
|
if s.VerifyBlock(context.Background(), blk) {
|
|
t.Error("Expected verify block to fail verification")
|
|
}
|
|
s = &Service{slasherClient: mockSlasher.MockSlasher{SlashBlock: false}}
|
|
if !s.VerifyBlock(context.Background(), blk) {
|
|
t.Error("Expected verify block to pass verification")
|
|
}
|
|
}
|