native: enforce contract manifest UTF-8 validity

Refs. #1699.
This commit is contained in:
Roman Khimov 2021-02-08 23:14:35 +03:00
parent dc3967ae7b
commit 62ef5a8dc7
2 changed files with 12 additions and 0 deletions

View file

@ -1,6 +1,7 @@
package core
import (
"bytes"
"encoding/json"
"math/big"
"testing"
@ -177,6 +178,13 @@ func TestContractDeploy(t *testing.T) {
require.NoError(t, err)
checkFAULTState(t, res)
})
t.Run("non-utf8 manifest", func(t *testing.T) {
manifB := bytes.Replace(manif1, []byte("TestMain"), []byte("\xff\xfe\xfd"), 1) // Replace name.
res, err := invokeContractMethod(bc, 11_00000000, mgmtHash, "deploy", nef1b, manifB)
require.NoError(t, err)
checkFAULTState(t, res)
})
t.Run("invalid manifest", func(t *testing.T) {
pkey, err := keys.NewPrivateKey()
require.NoError(t, err)