forked from TrueCloudLab/neoneo-go
Revert "native: ignore decoding errors during cache init"
This reverts commit 822722bd2e
.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
6824bd9f40
commit
1d189fd90c
3 changed files with 11 additions and 9 deletions
|
@ -219,7 +219,6 @@ func TestBlockchain_StartFromExistingDB(t *testing.T) {
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
require.True(t, strings.Contains(err.Error(), "can't init MPT at height"), err)
|
require.True(t, strings.Contains(err.Error(), "can't init MPT at height"), err)
|
||||||
})
|
})
|
||||||
/* See #2801
|
|
||||||
t.Run("failed native Management initialisation", func(t *testing.T) {
|
t.Run("failed native Management initialisation", func(t *testing.T) {
|
||||||
ps = newPS(t)
|
ps = newPS(t)
|
||||||
|
|
||||||
|
@ -234,9 +233,8 @@ func TestBlockchain_StartFromExistingDB(t *testing.T) {
|
||||||
|
|
||||||
_, _, _, err := chain.NewMultiWithCustomConfigAndStoreNoCheck(t, customConfig, cache)
|
_, _, _, err := chain.NewMultiWithCustomConfigAndStoreNoCheck(t, customConfig, cache)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
require.True(t, strings.Contains(err.Error(), "can't init cache for Management native contract"), err)
|
require.True(t, strings.Contains(err.Error(), "can't init natives cache: failed to initialize cache for ContractManagement"), err)
|
||||||
})
|
})
|
||||||
*/
|
|
||||||
t.Run("invalid native contract activation", func(t *testing.T) {
|
t.Run("invalid native contract activation", func(t *testing.T) {
|
||||||
ps = newPS(t)
|
ps = newPS(t)
|
||||||
|
|
||||||
|
|
|
@ -619,13 +619,19 @@ func (m *Management) InitializeCache(blockHeight uint32, d *dao.Simple) error {
|
||||||
nep17: make(map[util.Uint160]struct{}),
|
nep17: make(map[util.Uint160]struct{}),
|
||||||
}
|
}
|
||||||
|
|
||||||
d.Seek(m.ID, storage.SeekRange{Prefix: []byte{PrefixContract}}, func(k, v []byte) bool {
|
var initErr error
|
||||||
|
d.Seek(m.ID, storage.SeekRange{Prefix: []byte{PrefixContract}}, func(_, v []byte) bool {
|
||||||
var cs = new(state.Contract)
|
var cs = new(state.Contract)
|
||||||
if stackitem.DeserializeConvertible(v, cs) == nil {
|
initErr = stackitem.DeserializeConvertible(v, cs)
|
||||||
updateContractCache(cache, cs)
|
if initErr != nil {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
updateContractCache(cache, cs)
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
if initErr != nil {
|
||||||
|
return initErr
|
||||||
|
}
|
||||||
d.SetCache(m.ID, cache)
|
d.SetCache(m.ID, cache)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,14 +85,12 @@ func TestManagement_Initialize(t *testing.T) {
|
||||||
mgmt := newManagement()
|
mgmt := newManagement()
|
||||||
require.NoError(t, mgmt.InitializeCache(0, d))
|
require.NoError(t, mgmt.InitializeCache(0, d))
|
||||||
})
|
})
|
||||||
/* See #2801
|
|
||||||
t.Run("invalid contract state", func(t *testing.T) {
|
t.Run("invalid contract state", func(t *testing.T) {
|
||||||
d := dao.NewSimple(storage.NewMemoryStore(), false)
|
d := dao.NewSimple(storage.NewMemoryStore(), false)
|
||||||
mgmt := newManagement()
|
mgmt := newManagement()
|
||||||
d.PutStorageItem(mgmt.ID, []byte{PrefixContract}, state.StorageItem{0xFF})
|
d.PutStorageItem(mgmt.ID, []byte{PrefixContract}, state.StorageItem{0xFF})
|
||||||
require.Error(t, mgmt.InitializeCache(d))
|
require.Error(t, mgmt.InitializeCache(0, d))
|
||||||
})
|
})
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestManagement_GetNEP17Contracts(t *testing.T) {
|
func TestManagement_GetNEP17Contracts(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue