MCPcopy Create free account
hub / github.com/devlongs/gean / TestHashTreeRootStateWithValidators

Function TestHashTreeRootStateWithValidators

common/ssz/containers_test.go:282–316  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

280}
281
282func TestHashTreeRootStateWithValidators(t *testing.T) {
283 justifiedSlots, _ := types.BitlistFromBits([]bool{true}, 262144)
284 justificationVotes, _ := types.BitlistFromBits([]bool{}, 262144*4096)
285
286 var pubkey1, pubkey2 types.Bytes52
287 pubkey1[0] = 0xAA
288 pubkey2[0] = 0xBB
289
290 state := &types.State{
291 Config: types.Config{GenesisTime: 1700000000},
292 Slot: types.Slot(100),
293 LatestBlockHeader: types.BlockHeader{
294 Slot: types.Slot(99),
295 ProposerIndex: types.ValidatorIndex(0),
296 ParentRoot: types.Root{},
297 StateRoot: types.Root{},
298 BodyRoot: types.Root{},
299 },
300 LatestJustified: types.Checkpoint{},
301 LatestFinalized: types.Checkpoint{},
302 HistoricalRoots: []types.Root{},
303 JustifiedSlots: justifiedSlots,
304 Validators: []types.Validator{
305 {Pubkey: pubkey1, Index: types.ValidatorIndex(0)},
306 {Pubkey: pubkey2, Index: types.ValidatorIndex(1)},
307 },
308 JustificationRoots: []types.Root{},
309 JustificationVotes: justificationVotes,
310 }
311
312 root := HashTreeRootState(state, 262144, 4096)
313 if root == ZeroHash {
314 t.Error("expected non-zero root for state with validators")
315 }
316}

Callers

nothing calls this directly

Calls 4

BitlistFromBitsFunction · 0.92
SlotTypeAlias · 0.92
ValidatorIndexTypeAlias · 0.92
HashTreeRootStateFunction · 0.85

Tested by

no test coverage detected