prysm-pulse/beacon-chain/blockchain/schema_test.go
Nishant Das 4891f68929
Persist Blocks and State in DB (#440)
* 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
2018-09-03 00:44:03 +08:00

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