mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
d077483577
* v3 import renamings * tidy * fmt * rev * Update beacon-chain/core/epoch/precompute/reward_penalty_test.go * Update beacon-chain/core/helpers/validators_test.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/iface/BUILD.bazel * Update beacon-chain/db/kv/kv.go * Update beacon-chain/db/kv/state.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/sync/initial-sync/service.go * fix deps * fix bad replacements * fix bad replacements * change back * gohashtree version * fix deps Co-authored-by: Nishant Das <nishdas93@gmail.com> Co-authored-by: Potuz <potuz@prysmaticlabs.com>
123 lines
2.5 KiB
Go
123 lines
2.5 KiB
Go
package monitor
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
|
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
|
logTest "github.com/sirupsen/logrus/hooks/test"
|
|
)
|
|
|
|
func TestProcessExitsFromBlockTrackedIndices(t *testing.T) {
|
|
hook := logTest.NewGlobal()
|
|
s := &Service{
|
|
TrackedValidators: map[types.ValidatorIndex]bool{
|
|
1: true,
|
|
2: true,
|
|
},
|
|
}
|
|
|
|
exits := []*ethpb.SignedVoluntaryExit{
|
|
{
|
|
Exit: ðpb.VoluntaryExit{
|
|
ValidatorIndex: 3,
|
|
Epoch: 1,
|
|
},
|
|
},
|
|
{
|
|
Exit: ðpb.VoluntaryExit{
|
|
ValidatorIndex: 2,
|
|
Epoch: 0,
|
|
},
|
|
},
|
|
}
|
|
|
|
block := ðpb.BeaconBlock{
|
|
Body: ðpb.BeaconBlockBody{
|
|
VoluntaryExits: exits,
|
|
},
|
|
}
|
|
|
|
wb, err := blocks.NewBeaconBlock(block)
|
|
require.NoError(t, err)
|
|
s.processExitsFromBlock(wb)
|
|
require.LogsContain(t, hook, "\"Voluntary exit was included\" Slot=0 ValidatorIndex=2")
|
|
}
|
|
|
|
func TestProcessExitsFromBlockUntrackedIndices(t *testing.T) {
|
|
hook := logTest.NewGlobal()
|
|
s := &Service{
|
|
TrackedValidators: map[types.ValidatorIndex]bool{
|
|
1: true,
|
|
2: true,
|
|
},
|
|
}
|
|
|
|
exits := []*ethpb.SignedVoluntaryExit{
|
|
{
|
|
Exit: ðpb.VoluntaryExit{
|
|
ValidatorIndex: 3,
|
|
Epoch: 1,
|
|
},
|
|
},
|
|
{
|
|
Exit: ðpb.VoluntaryExit{
|
|
ValidatorIndex: 4,
|
|
Epoch: 0,
|
|
},
|
|
},
|
|
}
|
|
|
|
block := ðpb.BeaconBlock{
|
|
Body: ðpb.BeaconBlockBody{
|
|
VoluntaryExits: exits,
|
|
},
|
|
}
|
|
|
|
wb, err := blocks.NewBeaconBlock(block)
|
|
require.NoError(t, err)
|
|
s.processExitsFromBlock(wb)
|
|
require.LogsDoNotContain(t, hook, "\"Voluntary exit was included\"")
|
|
}
|
|
|
|
func TestProcessExitP2PTrackedIndices(t *testing.T) {
|
|
hook := logTest.NewGlobal()
|
|
s := &Service{
|
|
TrackedValidators: map[types.ValidatorIndex]bool{
|
|
1: true,
|
|
2: true,
|
|
},
|
|
}
|
|
|
|
exit := ðpb.SignedVoluntaryExit{
|
|
Exit: ðpb.VoluntaryExit{
|
|
ValidatorIndex: 1,
|
|
Epoch: 1,
|
|
},
|
|
Signature: make([]byte, 96),
|
|
}
|
|
s.processExit(exit)
|
|
require.LogsContain(t, hook, "\"Voluntary exit was processed\" ValidatorIndex=1")
|
|
}
|
|
|
|
func TestProcessExitP2PUntrackedIndices(t *testing.T) {
|
|
hook := logTest.NewGlobal()
|
|
s := &Service{
|
|
TrackedValidators: map[types.ValidatorIndex]bool{
|
|
1: true,
|
|
2: true,
|
|
},
|
|
}
|
|
|
|
exit := ðpb.SignedVoluntaryExit{
|
|
Exit: ðpb.VoluntaryExit{
|
|
ValidatorIndex: 3,
|
|
Epoch: 1,
|
|
},
|
|
}
|
|
s.processExit(exit)
|
|
require.LogsDoNotContain(t, hook, "\"Voluntary exit was processed\"")
|
|
}
|