prysm-pulse/beacon-chain/blockchain/schema_test.go

27 lines
654 B
Go
Raw Normal View History

package blockchain
import (
"bytes"
"testing"
)
func TestBlockKeys(t *testing.T) {
testhash := [32]byte{1, 2, 4, 5, 6, 7, 8, 9, 10}
2018-09-14 05:07:30 +00:00
testkey := append(testhash[:], blockSuffix...)
generatedKey := blockKey(testhash)
if !bytes.Equal(testkey, generatedKey) {
t.Errorf("block keys are not the same %v, %v", testkey, generatedKey)
}
testslotnumber := uint64(4)
2018-09-14 05:07:30 +00:00
expectedKey := append(encodeSlotNumber(testslotnumber)[:], canonicalSuffix...)
generatedkey := canonicalBlockKey(testslotnumber)
if !bytes.Equal(generatedkey, expectedKey) {
t.Errorf("expected and generated canonical keys are not equal %v, %v", expectedKey, generatedKey)
}
}