Persist transactions (#51)

* added account_state + changed ECPoint to PublicKey

* account state persist

* in depth test for existing accounts.

* implemented GetTransaction.

* added enrollment TX

* added persist of accounts and unspent coins

* bumped version -> 0.32.0
This commit is contained in:
Anthony De Meulemeester 2018-03-21 17:11:04 +01:00 committed by GitHub
parent a67728628e
commit 52fa41a12a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 930 additions and 66 deletions

View file

@ -122,6 +122,21 @@ func TestHasBlock(t *testing.T) {
assert.False(t, bc.HasBlock(newBlock.Hash()))
}
func TestGetTransaction(t *testing.T) {
block := getDecodedBlock(t, 1)
bc := newTestChain(t)
assert.Nil(t, bc.AddBlock(block))
assert.Nil(t, bc.persistBlock(block))
tx, height, err := bc.GetTransaction(block.Transactions[0].Hash())
if err != nil {
t.Fatal(err)
}
assert.Equal(t, block.Index, height)
assert.Equal(t, block.Transactions[0], tx)
}
func newTestChain(t *testing.T) *Blockchain {
startHash, _ := util.Uint256DecodeString("a")
chain, err := NewBlockchain(storage.NewMemoryStore(), startHash)