diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 13266c65c..f0b4650e2 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -1455,7 +1455,9 @@ func (bc *Blockchain) GetEnrollments() ([]state.Validator, error) { // GetTestVM returns a VM and a Store setup for a test run of some sort of code. func (bc *Blockchain) GetTestVM(tx *transaction.Transaction) *vm.VM { - systemInterop := bc.newInteropContext(trigger.Application, bc.dao, nil, tx) + d := bc.dao.GetWrapped().(*dao.Simple) + d.MPT = nil + systemInterop := bc.newInteropContext(trigger.Application, d, nil, tx) vm := systemInterop.SpawnVM() vm.SetPriceGetter(getPrice) return vm diff --git a/pkg/core/dao/dao.go b/pkg/core/dao/dao.go index 22030a974..af746cef4 100644 --- a/pkg/core/dao/dao.go +++ b/pkg/core/dao/dao.go @@ -367,8 +367,10 @@ func (dao *Simple) PutStorageItem(id int32, key []byte, si *state.StorageItem) e return buf.Err } v := buf.Bytes() - if err := dao.MPT.Put(stKey[1:], v); err != nil && err != mpt.ErrNotFound { - return err + if dao.MPT != nil { + if err := dao.MPT.Put(stKey[1:], v); err != nil && err != mpt.ErrNotFound { + return err + } } return dao.Store.Put(stKey, v) } @@ -377,8 +379,10 @@ func (dao *Simple) PutStorageItem(id int32, key []byte, si *state.StorageItem) e // given key from the store. func (dao *Simple) DeleteStorageItem(id int32, key []byte) error { stKey := makeStorageItemKey(id, key) - if err := dao.MPT.Delete(stKey[1:]); err != nil && err != mpt.ErrNotFound { - return err + if dao.MPT != nil { + if err := dao.MPT.Delete(stKey[1:]); err != nil && err != mpt.ErrNotFound { + return err + } } return dao.Store.Delete(stKey) }