QSP-9 Prevent Casting to Int if Possible (#6349)

* no cast to int

* fix up significant casting issues

* more casting

* even more casting fixes

* more casts

* fix subnets

* back to ints

* final touches

* broken test fix

* add in blocks test fix

* unskip

* revert bytes fixes

* casting fixes

* Update beacon-chain/db/kv/state.go

* Update beacon-chain/db/kv/blocks.go

* fmt

* slash:

* fix val tests

* fix up conf

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: Victor Farazdagi <simple.square@gmail.com>
This commit is contained in:
Raul Jordan
2020-06-26 11:07:00 -05:00
committed by GitHub
parent 78465e2549
commit 252f758baa
43 changed files with 138 additions and 125 deletions

View File

@@ -53,18 +53,18 @@ func TestShuffleList_OK(t *testing.T) {
func TestSplitIndices_OK(t *testing.T) {
var l []uint64
validators := 64000
for i := 0; i < validators; i++ {
l = append(l, uint64(i))
numValidators := uint64(64000)
for i := uint64(0); i < numValidators; i++ {
l = append(l, i)
}
split := SplitIndices(l, params.BeaconConfig().SlotsPerEpoch)
if len(split) != int(params.BeaconConfig().SlotsPerEpoch) {
if uint64(len(split)) != params.BeaconConfig().SlotsPerEpoch {
t.Errorf("Split list failed due to incorrect length, wanted:%v, got:%v", params.BeaconConfig().SlotsPerEpoch, len(split))
}
for _, s := range split {
if len(s) != validators/int(params.BeaconConfig().SlotsPerEpoch) {
t.Errorf("Split list failed due to incorrect length, wanted:%v, got:%v", validators/int(params.BeaconConfig().SlotsPerEpoch), len(s))
if uint64(len(s)) != numValidators/params.BeaconConfig().SlotsPerEpoch {
t.Errorf("Split list failed due to incorrect length, wanted:%v, got:%v", numValidators/params.BeaconConfig().SlotsPerEpoch, len(s))
}
}
}