mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 13:41:37 +00:00
core: unit tests blockchain state
This commit is contained in:
parent
d28f2dce05
commit
c03de88b41
1 changed files with 46 additions and 0 deletions
46
pkg/core/blockchain_state_test.go
Normal file
46
pkg/core/blockchain_state_test.go
Normal file
|
@ -0,0 +1,46 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/CityOfZion/neo-go/pkg/core/storage"
|
||||
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestNewBlockChainStateAndCommit(t *testing.T) {
|
||||
memCachedStore := storage.NewMemCachedStore(storage.NewMemoryStore())
|
||||
bcState := NewBlockChainState(memCachedStore)
|
||||
err := bcState.commit()
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestStoreAsBlock(t *testing.T) {
|
||||
memCachedStore := storage.NewMemCachedStore(storage.NewMemoryStore())
|
||||
bcState := NewBlockChainState(memCachedStore)
|
||||
|
||||
block := newBlock(0, newMinerTX())
|
||||
err := bcState.storeAsBlock(block, 0)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestStoreAsCurrentBlock(t *testing.T) {
|
||||
memCachedStore := storage.NewMemCachedStore(storage.NewMemoryStore())
|
||||
bcState := NewBlockChainState(memCachedStore)
|
||||
|
||||
block := newBlock(0, newMinerTX())
|
||||
err := bcState.storeAsCurrentBlock(block)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestStoreAsTransaction(t *testing.T) {
|
||||
memCachedStore := storage.NewMemCachedStore(storage.NewMemoryStore())
|
||||
bcState := NewBlockChainState(memCachedStore)
|
||||
|
||||
tx := &transaction.Transaction{
|
||||
Type: transaction.MinerType,
|
||||
Data: &transaction.MinerTX{},
|
||||
}
|
||||
err := bcState.storeAsTransaction(tx, 0)
|
||||
require.NoError(t, err)
|
||||
}
|
Loading…
Reference in a new issue