mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
699e7efc61
* Add to struct * Add implementations * Tests
33 lines
615 B
Go
33 lines
615 B
Go
package stategen
|
|
|
|
import "testing"
|
|
|
|
func TestEpochBoundaryRoot_CanSetGetDelete(t *testing.T) {
|
|
s := &State{
|
|
epochBoundarySlotToRoot: make(map[uint64][32]byte),
|
|
}
|
|
slot := uint64(100)
|
|
r := [32]byte{'A'}
|
|
|
|
_, exists := s.epochBoundaryRoot(slot)
|
|
if exists {
|
|
t.Fatal("should not be cached")
|
|
}
|
|
|
|
s.setEpochBoundaryRoot(slot, r)
|
|
|
|
rReceived, exists := s.epochBoundaryRoot(slot)
|
|
if !exists {
|
|
t.Fatal("should be cached")
|
|
}
|
|
if rReceived != r {
|
|
t.Error("did not cache right value")
|
|
}
|
|
|
|
s.deleteEpochBoundaryRoot(100)
|
|
_, exists = s.epochBoundaryRoot(slot)
|
|
if exists {
|
|
t.Fatal("should not be cached")
|
|
}
|
|
}
|