prysm-pulse/beacon-chain/state/stategen/epoch_boundary_root_test.go
terence tsao 699e7efc61
Add epoch boundary root map (#4993)
* Add to struct

* Add implementations

* Tests
2020-03-03 13:07:34 -06:00

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")
}
}