mirror of
https://github.com/status-im/status-go.git
synced 2025-01-09 06:12:55 +00:00
14c513bd5a
* Replace request ID when same request is restarted * Remove unnecessary changes * Execute all writes atomically only if request was processed succesfully * Fix linter * Fix shadowed errors * Fix spelling * Do not append same reference to a byte slice
24 lines
488 B
Go
24 lines
488 B
Go
package db
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestTxWritesOnCommit(t *testing.T) {
|
|
storage, err := NewMemoryLevelDBStorage()
|
|
tx := storage.NewTx()
|
|
require.NoError(t, err)
|
|
key := []byte{1}
|
|
val := []byte{1, 1}
|
|
require.NoError(t, tx.Put(key, val))
|
|
result, err := storage.Get(key)
|
|
require.Error(t, err)
|
|
require.Nil(t, result)
|
|
require.NoError(t, tx.Commit())
|
|
result, err = storage.Get(key)
|
|
require.NoError(t, err)
|
|
require.Equal(t, val, result)
|
|
}
|