Merge pull request #3140 from nspcc-dev/fix-wildcard-trusts-deserialization
smartcontract: fix wildcard trusts deserialization
This commit is contained in:
commit
3628b824e1
2 changed files with 11 additions and 1 deletions
|
@ -55,6 +55,16 @@ func TestContractStateToFromSI(t *testing.T) {
|
||||||
t.Run("Convertible", func(t *testing.T) {
|
t.Run("Convertible", func(t *testing.T) {
|
||||||
contractDecoded := new(Contract)
|
contractDecoded := new(Contract)
|
||||||
testserdes.ToFromStackItem(t, contract, contractDecoded)
|
testserdes.ToFromStackItem(t, contract, contractDecoded)
|
||||||
|
|
||||||
|
t.Run("preserve wildcard trusts", func(t *testing.T) {
|
||||||
|
contract.Manifest.Trusts.Value = nil
|
||||||
|
require.True(t, contract.Manifest.Trusts.IsWildcard())
|
||||||
|
actual := new(Contract)
|
||||||
|
item, err := contract.ToStackItem()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NoError(t, actual.FromStackItem(item))
|
||||||
|
require.True(t, actual.Manifest.Trusts.IsWildcard())
|
||||||
|
})
|
||||||
})
|
})
|
||||||
t.Run("JSON", func(t *testing.T) {
|
t.Run("JSON", func(t *testing.T) {
|
||||||
contractDecoded := new(Contract)
|
contractDecoded := new(Contract)
|
||||||
|
|
|
@ -250,7 +250,7 @@ func (m *Manifest) FromStackItem(item stackitem.Item) error {
|
||||||
m.Permissions[i] = *p
|
m.Permissions[i] = *p
|
||||||
}
|
}
|
||||||
if _, ok := str[6].(stackitem.Null); ok {
|
if _, ok := str[6].(stackitem.Null); ok {
|
||||||
m.Trusts.Restrict()
|
m.Trusts = WildPermissionDescs{Value: nil} // wildcard by default
|
||||||
} else {
|
} else {
|
||||||
if str[6].Type() != stackitem.ArrayT {
|
if str[6].Type() != stackitem.ArrayT {
|
||||||
return errors.New("invalid Trusts stackitem type")
|
return errors.New("invalid Trusts stackitem type")
|
||||||
|
|
Loading…
Reference in a new issue