neoneo-go/pkg/core/storage/store_test.go
Roman Khimov 522229d731 storage: drop AppendPrefix/AppendPrefixInt APIs
We're not using them anymore and they allocate.
2022-02-18 14:59:59 +03:00

28 lines
953 B
Go

package storage
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestBatchToOperations(t *testing.T) {
b := &MemBatch{
Put: []KeyValueExists{
{KeyValue: KeyValue{Key: []byte{byte(STStorage), 0x01}, Value: []byte{0x01}}},
{KeyValue: KeyValue{Key: []byte{byte(DataMPT), 0x02}, Value: []byte{0x02}}},
{KeyValue: KeyValue{Key: []byte{byte(STStorage), 0x03}, Value: []byte{0x03}}, Exists: true},
},
Deleted: []KeyValueExists{
{KeyValue: KeyValue{Key: []byte{byte(STStorage), 0x04}, Value: []byte{0x04}}},
{KeyValue: KeyValue{Key: []byte{byte(DataMPT), 0x05}, Value: []byte{0x05}}},
{KeyValue: KeyValue{Key: []byte{byte(STStorage), 0x06}, Value: []byte{0x06}}, Exists: true},
},
}
o := []Operation{
{State: "Added", Key: []byte{0x01}, Value: []byte{0x01}},
{State: "Changed", Key: []byte{0x03}, Value: []byte{0x03}},
{State: "Deleted", Key: []byte{0x06}},
}
require.Equal(t, o, BatchToOperations(b))
}