core/rawdb: test that writing during readonly fails

This commit is contained in:
Martin Holst Swende
2022-01-10 09:21:17 +01:00
committed by Sina Mahmoodi
parent 8f42a64920
commit 114a81e0d6

View File

@@ -903,4 +903,13 @@ func TestFreezerReadonlyBasics(t *testing.T) {
if !bytes.Equal(v, exp) { if !bytes.Equal(v, exp) {
t.Errorf("retrieved value is incorrect") t.Errorf("retrieved value is incorrect")
} }
// Now write some data. This should fail either during AppendRaw or Commit
batch := f.newBatch()
writeErr := batch.AppendRaw(32, make([]byte, 1))
if writeErr == nil {
writeErr = batch.commit()
}
if writeErr == nil {
t.Fatalf("Writing to readonly table should fail")
}
} }