github.com/nspcc-dev/neo-go@v0.105.2-0.20240517133400-6be757af3eba/pkg/core/storage/store_test.go (about) 1 package storage 2 3 import ( 4 "testing" 5 6 "github.com/nspcc-dev/neo-go/pkg/core/storage/dboper" 7 "github.com/stretchr/testify/require" 8 ) 9 10 func TestBatchToOperations(t *testing.T) { 11 b := &MemBatch{ 12 Put: []KeyValueExists{ 13 {KeyValue: KeyValue{Key: []byte{byte(STStorage), 0x01}, Value: []byte{0x01}}}, 14 {KeyValue: KeyValue{Key: []byte{byte(DataMPT), 0x02}, Value: []byte{0x02}}}, 15 {KeyValue: KeyValue{Key: []byte{byte(STStorage), 0x03}, Value: []byte{0x03}}, Exists: true}, 16 }, 17 Deleted: []KeyValueExists{ 18 {KeyValue: KeyValue{Key: []byte{byte(STStorage), 0x04}, Value: []byte{0x04}}}, 19 {KeyValue: KeyValue{Key: []byte{byte(DataMPT), 0x05}, Value: []byte{0x05}}}, 20 {KeyValue: KeyValue{Key: []byte{byte(STStorage), 0x06}, Value: []byte{0x06}}, Exists: true}, 21 }, 22 } 23 o := []dboper.Operation{ 24 {State: "Added", Key: []byte{0x01}, Value: []byte{0x01}}, 25 {State: "Changed", Key: []byte{0x03}, Value: []byte{0x03}}, 26 {State: "Deleted", Key: []byte{0x06}}, 27 } 28 require.Equal(t, o, BatchToOperations(b)) 29 }