mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
* make registerSubscribers idempotent * clean up debugging changes * test fix * rm unused var * sobbing noises * naming feedback and separate test for digestActionDone * gazelle * manu's feedback * refactor to enable immediate sub after init sync * preston comment re panic causing db corruption risk * ensure we check that we're 1 epoch past the fork * manu feedback --------- Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
41 lines
845 B
Go
41 lines
845 B
Go
package sync
|
|
|
|
import (
|
|
"fmt"
|
|
"slices"
|
|
"testing"
|
|
)
|
|
|
|
func TestDigestActionDone(t *testing.T) {
|
|
digests := [][4]byte{
|
|
{0, 0, 0, 0},
|
|
{1, 2, 3, 4},
|
|
{4, 3, 2, 1},
|
|
}
|
|
actions := []oncePerDigest{
|
|
registerGossipOnce,
|
|
unregisterGossipOnce,
|
|
registerRpcOnce,
|
|
unregisterRpcOnce,
|
|
}
|
|
testCombos := func(d [][4]byte, a []oncePerDigest) {
|
|
s := &Service{}
|
|
for _, digest := range d {
|
|
for _, action := range a {
|
|
t.Run(fmt.Sprintf("digest=%#x/action=%d", digest, action), func(t *testing.T) {
|
|
if s.digestActionDone(digest, action) {
|
|
t.Fatal("expected first call to return false")
|
|
}
|
|
if !s.digestActionDone(digest, action) {
|
|
t.Fatal("expected second call to return true")
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|
|
testCombos(digests, actions)
|
|
slices.Reverse(digests)
|
|
slices.Reverse(actions)
|
|
testCombos(digests, actions)
|
|
}
|