neoneo-go/pkg/core/storage/store_test.go
Roman Khimov 4c39b6600d *: store application long along with tx/block
Two times less keys inserted into the DB per tx leads to ~13% TPS
improvement. We also drop one goroutine with it which isn't bad as well.
2021-12-09 15:39:26 +03:00

45 lines
747 B
Go

package storage
import (
"testing"
"github.com/stretchr/testify/assert"
)
var (
prefixes = []KeyPrefix{
DataExecutable,
STAccount,
STStorage,
IXHeaderHashList,
SYSCurrentBlock,
SYSCurrentHeader,
SYSVersion,
}
expected = []uint8{
0x01,
0x40,
0x70,
0x80,
0xc0,
0xc1,
0xf0,
}
)
func TestAppendPrefix(t *testing.T) {
for i := 0; i < len(expected); i++ {
value := []byte{0x01, 0x02}
prefix := AppendPrefix(prefixes[i], value)
assert.Equal(t, KeyPrefix(expected[i]), KeyPrefix(prefix[0]))
}
}
func TestAppendPrefixInt(t *testing.T) {
for i := 0; i < len(expected); i++ {
value := 2000
prefix := AppendPrefixInt(prefixes[i], value)
assert.Equal(t, KeyPrefix(expected[i]), KeyPrefix(prefix[0]))
}
}