mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
84916672c6
* replace eth2 types * replace protos * regen proto * replace * gaz * deps * amend * regen proto * mod * gaz * gaz * ensure build * ssz * add dep * no more eth2 types * no more eth2 * remg * all builds * buidl * tidy * clean * fmt * val serv * gaz Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
72 lines
2.3 KiB
Go
72 lines
2.3 KiB
Go
package slasher
|
|
|
|
import (
|
|
"testing"
|
|
|
|
slashertypes "github.com/prysmaticlabs/prysm/beacon-chain/slasher/types"
|
|
types "github.com/prysmaticlabs/prysm/consensus-types/primitives"
|
|
"github.com/prysmaticlabs/prysm/testing/require"
|
|
)
|
|
|
|
func Test_attestationsQueue(t *testing.T) {
|
|
t.Run("push_and_dequeue", func(tt *testing.T) {
|
|
attQueue := newAttestationsQueue()
|
|
wantedAtts := []*slashertypes.IndexedAttestationWrapper{
|
|
createAttestationWrapper(t, 0, 1, []uint64{1}, make([]byte, 32)),
|
|
createAttestationWrapper(t, 1, 2, []uint64{1}, make([]byte, 32)),
|
|
}
|
|
attQueue.push(wantedAtts[0])
|
|
attQueue.push(wantedAtts[1])
|
|
require.DeepEqual(t, 2, attQueue.size())
|
|
|
|
received := attQueue.dequeue()
|
|
require.DeepEqual(t, 0, attQueue.size())
|
|
require.DeepEqual(t, wantedAtts, received)
|
|
})
|
|
|
|
t.Run("extend_and_dequeue", func(tt *testing.T) {
|
|
attQueue := newAttestationsQueue()
|
|
wantedAtts := []*slashertypes.IndexedAttestationWrapper{
|
|
createAttestationWrapper(t, 0, 1, []uint64{1}, make([]byte, 32)),
|
|
createAttestationWrapper(t, 1, 2, []uint64{1}, make([]byte, 32)),
|
|
}
|
|
attQueue.extend(wantedAtts)
|
|
require.DeepEqual(t, 2, attQueue.size())
|
|
|
|
received := attQueue.dequeue()
|
|
require.DeepEqual(t, 0, attQueue.size())
|
|
require.DeepEqual(t, wantedAtts, received)
|
|
})
|
|
}
|
|
|
|
func Test_blocksQueue(t *testing.T) {
|
|
t.Run("push_and_dequeue", func(tt *testing.T) {
|
|
blkQueue := newBlocksQueue()
|
|
wantedBlks := []*slashertypes.SignedBlockHeaderWrapper{
|
|
createProposalWrapper(t, 0, types.ValidatorIndex(1), make([]byte, 32)),
|
|
createProposalWrapper(t, 1, types.ValidatorIndex(1), make([]byte, 32)),
|
|
}
|
|
blkQueue.push(wantedBlks[0])
|
|
blkQueue.push(wantedBlks[1])
|
|
require.DeepEqual(t, 2, blkQueue.size())
|
|
|
|
received := blkQueue.dequeue()
|
|
require.DeepEqual(t, 0, blkQueue.size())
|
|
require.DeepEqual(t, wantedBlks, received)
|
|
})
|
|
|
|
t.Run("extend_and_dequeue", func(tt *testing.T) {
|
|
blkQueue := newBlocksQueue()
|
|
wantedBlks := []*slashertypes.SignedBlockHeaderWrapper{
|
|
createProposalWrapper(t, 0, types.ValidatorIndex(1), make([]byte, 32)),
|
|
createProposalWrapper(t, 1, types.ValidatorIndex(1), make([]byte, 32)),
|
|
}
|
|
blkQueue.extend(wantedBlks)
|
|
require.DeepEqual(t, 2, blkQueue.size())
|
|
|
|
received := blkQueue.dequeue()
|
|
require.DeepEqual(t, 0, blkQueue.size())
|
|
require.DeepEqual(t, wantedBlks, received)
|
|
})
|
|
}
|