Persistance (#53)

* added publish TX for backwards compat.

* lowered the prototick for faster block syncing

* print useragent on startup

* added createMultiRedeemScript for genesis block generation.

* building genesis block from scratch.

* implemented merkle tree.

* starting blockhain with generated genesis hash

* Fixed bug in unspent coin state.

* fixed broken tests after genesis block.

* removed log line.

* bumped version -> 0.34.0
This commit is contained in:
Anthony De Meulemeester 2018-03-25 12:45:54 +02:00 committed by GitHub
parent ad9333c74c
commit 94672cb9cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 955 additions and 187 deletions

View file

@ -3,8 +3,8 @@ package core
import (
"testing"
"github.com/CityOfZion/neo-go/config"
"github.com/CityOfZion/neo-go/pkg/core/storage"
"github.com/CityOfZion/neo-go/pkg/util"
"github.com/stretchr/testify/assert"
)
@ -20,7 +20,6 @@ func TestAddHeaders(t *testing.T) {
assert.Equal(t, 0, bc.blockCache.Len())
assert.Equal(t, h3.Index, bc.HeaderHeight())
assert.Equal(t, uint32(1), bc.storedHeaderCount)
assert.Equal(t, uint32(0), bc.BlockHeight())
assert.Equal(t, h3.Hash(), bc.CurrentHeaderHash())
@ -30,7 +29,6 @@ func TestAddHeaders(t *testing.T) {
}
assert.Equal(t, h3.Index, bc.HeaderHeight())
assert.Equal(t, uint32(1), bc.storedHeaderCount)
assert.Equal(t, uint32(0), bc.BlockHeight())
assert.Equal(t, h3.Hash(), bc.CurrentHeaderHash())
}
@ -53,12 +51,20 @@ func TestAddBlock(t *testing.T) {
assert.Equal(t, 3, bc.blockCache.Len())
assert.Equal(t, lastBlock.Index, bc.HeaderHeight())
assert.Equal(t, lastBlock.Hash(), bc.CurrentHeaderHash())
assert.Equal(t, uint32(1), bc.storedHeaderCount)
t.Log(bc.blockCache)
if err := bc.persist(); err != nil {
t.Fatal(err)
}
for _, block := range blocks {
key := storage.AppendPrefix(storage.DataBlock, block.Hash().BytesReverse())
if _, err := bc.Get(key); err != nil {
t.Fatalf("block %s not persisted", block.Hash())
}
}
assert.Equal(t, lastBlock.Index, bc.BlockHeight())
assert.Equal(t, lastBlock.Hash(), bc.CurrentHeaderHash())
assert.Equal(t, 0, bc.blockCache.Len())
@ -138,8 +144,11 @@ func TestGetTransaction(t *testing.T) {
}
func newTestChain(t *testing.T) *Blockchain {
startHash, _ := util.Uint256DecodeString("a")
chain, err := NewBlockchain(storage.NewMemoryStore(), startHash)
cfg, err := config.Load("../../config", config.ModePrivNet)
if err != nil {
t.Fatal(err)
}
chain, err := NewBlockchain(storage.NewMemoryStore(), cfg.ProtocolConfiguration)
if err != nil {
t.Fatal(err)
}