forked from TrueCloudLab/neoneo-go
a67728628e
* Created test_data folder with block json files for testing + create separate file for block base. * Fixed bug in WriteVarUint + Trim logic + unit tests * Refactored store and add more tests for it. * restore headerList from chain file * Fix tx decode bug + lots of housekeeping. * Implemented Node restore state from chain file. * Created standalone package for storage. Added couple more methods to Batch and Store interfaces. * Block persisting + tests * bumped version -> 0.31.0
41 lines
603 B
Go
41 lines
603 B
Go
package storage
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetPut(t *testing.T) {
|
|
var (
|
|
s = NewMemoryStore()
|
|
key = []byte("sparse")
|
|
value = []byte("rocks")
|
|
)
|
|
|
|
s.Put(key, value)
|
|
|
|
newVal, err := s.Get(key)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
assert.Equal(t, value, newVal)
|
|
}
|
|
|
|
func TestPutBatch(t *testing.T) {
|
|
var (
|
|
s = NewMemoryStore()
|
|
key = []byte("sparse")
|
|
value = []byte("rocks")
|
|
batch = s.Batch()
|
|
)
|
|
|
|
batch.Put(key, value)
|
|
|
|
s.PutBatch(batch)
|
|
newVal, err := s.Get(key)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
assert.Equal(t, value, newVal)
|
|
}
|