mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 12:27:18 +00:00
4891f68929
* Persist Dag * Add schema * Add new message * add mapping * Adding check to save block * Removing blocks mapping * Make changes to block processing * Change from mapping to a slice of hashes * Adding tests to core * adding more tests * Fixing service test * Add comments and fix bazel * fix lint * fix conflicts * addressing review comments * Removing references to active * fixing tests with active state * Protytype for #440: Persist blocks and latest state in DB * simplify code * removing block registry * fix test * adding block removal/iterator * Addressing review comments * Addressing comments * removing extra line * making vars private and adding canonical key * fix lint * splitting methods * adding more changes * lint * improving coverage * removing decodeslotnumber * gazelle * remove todos * addressing preston's comments * remove slotnumber * lint
27 lines
651 B
Go
27 lines
651 B
Go
package blockchain
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
)
|
|
|
|
func TestBlockKeys(t *testing.T) {
|
|
|
|
testhash := [32]byte{1, 2, 4, 5, 6, 7, 8, 9, 10}
|
|
testkey := append(blockPrefix, testhash[:]...)
|
|
generatedKey := blockKey(testhash)
|
|
|
|
if !bytes.Equal(testkey, generatedKey) {
|
|
t.Errorf("block keys are not the same %v, %v", testkey, generatedKey)
|
|
}
|
|
|
|
testslotnumber := uint64(4)
|
|
expectedKey := append(canonicalPrefix, encodeSlotNumber(testslotnumber)...)
|
|
generatedkey := canonicalBlockKey(testslotnumber)
|
|
|
|
if !bytes.Equal(generatedkey, expectedKey) {
|
|
t.Errorf("expected and generated canonical keys are not equal %v, %v", expectedKey, generatedKey)
|
|
}
|
|
|
|
}
|