mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-05 03:06:16 +00:00
core: add Close() to blockchainer, implement it to properly close chain
Before it the deferred function in Run() was actually never able to properly close the Store, so we weren't synching the latest state to the disk.
This commit is contained in:
parent
d33083e1e1
commit
b05754deac
8 changed files with 50 additions and 23 deletions
|
@ -155,3 +155,23 @@ func TestGetTransaction(t *testing.T) {
|
|||
assert.NoError(t, bc.persist())
|
||||
}
|
||||
}
|
||||
|
||||
func TestClose(t *testing.T) {
|
||||
defer func() {
|
||||
r := recover()
|
||||
assert.NotNil(t, r)
|
||||
}()
|
||||
bc := newTestChain(t)
|
||||
blocks := makeBlocks(10)
|
||||
for i := 0; i < len(blocks); i++ {
|
||||
require.NoError(t, bc.AddBlock(blocks[i]))
|
||||
}
|
||||
bc.Close()
|
||||
// It's a hack, but we use internal knowledge of MemoryStore
|
||||
// implementation which makes it completely unusable (up to panicing)
|
||||
// after Close().
|
||||
_ = bc.store.Put([]byte{0}, []byte{1})
|
||||
|
||||
// This should never be executed.
|
||||
assert.Nil(t, t)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue