mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-28 19:31:34 +00:00
core: extend error message for contract state check
It will give us a clue on what's wrong with contract states if something unexpected happen. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
5c75ee13d0
commit
82993dab2b
2 changed files with 6 additions and 3 deletions
|
@ -12,6 +12,7 @@ import (
|
|||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
json "github.com/nspcc-dev/go-ordered-json"
|
||||
"github.com/nspcc-dev/neo-go/pkg/config"
|
||||
"github.com/nspcc-dev/neo-go/pkg/config/limits"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/block"
|
||||
|
@ -535,8 +536,10 @@ func (bc *Blockchain) init() error {
|
|||
return fmt.Errorf("failed to check native %s state against autogenerated one: %w", md.Name, err)
|
||||
}
|
||||
if !bytes.Equal(storedCSBytes, autogenCSBytes) {
|
||||
return fmt.Errorf("native %s: version mismatch (stored contract state differs from autogenerated one), "+
|
||||
"try to resynchronize the node from the genesis", md.Name)
|
||||
storedJ, _ := json.Marshal(storedCS)
|
||||
autogenJ, _ := json.Marshal(autogenCS)
|
||||
return fmt.Errorf("native %s: version mismatch for the latest hardfork %s (stored contract state differs from autogenerated one), "+
|
||||
"try to resynchronize the node from the genesis: %s vs %s", md.Name, current, string(storedJ), string(autogenJ))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -269,7 +269,7 @@ func TestBlockchain_StartFromExistingDB(t *testing.T) {
|
|||
|
||||
_, _, _, err = chain.NewMultiWithCustomConfigAndStoreNoCheck(t, customConfig, cache)
|
||||
require.Error(t, err)
|
||||
require.True(t, strings.Contains(err.Error(), fmt.Sprintf("native %s: version mismatch (stored contract state differs from autogenerated one)", nativenames.CryptoLib)), err)
|
||||
require.True(t, strings.Contains(err.Error(), fmt.Sprintf("native %s: version mismatch for the latest hardfork Cockatrice (stored contract state differs from autogenerated one)", nativenames.CryptoLib)), err)
|
||||
})
|
||||
|
||||
t.Run("good", func(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue