mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-30 09:33:36 +00:00
parent
7121686571
commit
d7502debba
2 changed files with 9 additions and 3 deletions
|
@ -396,8 +396,12 @@ func putWithContextAndFlags(ic *interop.Context, stc *StorageContext, key []byte
|
||||||
if si == nil {
|
if si == nil {
|
||||||
si = &state.StorageItem{}
|
si = &state.StorageItem{}
|
||||||
sizeInc = len(key) + len(value)
|
sizeInc = len(key) + len(value)
|
||||||
} else if len(value) > len(si.Value) {
|
} else if len(value) != 0 {
|
||||||
sizeInc = len(value) - len(si.Value)
|
if len(value) <= len(si.Value) {
|
||||||
|
sizeInc = (len(value)-1)/4 + 1
|
||||||
|
} else {
|
||||||
|
sizeInc = (len(si.Value)-1)/4 + 1 + len(value) - len(si.Value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !ic.VM.AddGas(int64(sizeInc) * StoragePrice) {
|
if !ic.VM.AddGas(int64(sizeInc) * StoragePrice) {
|
||||||
return errGasLimitExceeded
|
return errGasLimitExceeded
|
||||||
|
|
|
@ -364,7 +364,9 @@ func TestStoragePut(t *testing.T) {
|
||||||
err := storagePut(ic)
|
err := storagePut(ic)
|
||||||
require.True(t, errors.Is(err, errGasLimitExceeded), "got: %v", err)
|
require.True(t, errors.Is(err, errGasLimitExceeded), "got: %v", err)
|
||||||
})
|
})
|
||||||
initVM(t, []byte{4}, []byte{5, 6, 7, 8}, 2*StoragePrice)
|
initVM(t, []byte{4}, []byte{5, 6, 7, 8}, 3*StoragePrice)
|
||||||
|
require.NoError(t, storagePut(ic))
|
||||||
|
initVM(t, []byte{4}, []byte{5, 6}, StoragePrice)
|
||||||
require.NoError(t, storagePut(ic))
|
require.NoError(t, storagePut(ic))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue