core: consider Rules witness scope as valid

This commit is contained in:
Anna Shaleva 2022-04-27 12:46:43 +03:00
parent 8983d25f7f
commit 35d930951c
2 changed files with 8 additions and 2 deletions

View file

@ -39,7 +39,7 @@ func (c *Signer) EncodeBinary(bw *io.BinWriter) {
func (c *Signer) DecodeBinary(br *io.BinReader) {
br.ReadBytes(c.Account[:])
c.Scopes = WitnessScope(br.ReadB())
if c.Scopes & ^(Global|CalledByEntry|CustomContracts|CustomGroups|None) != 0 {
if c.Scopes & ^(Global|CalledByEntry|CustomContracts|CustomGroups|Rules|None) != 0 {
br.Err = errors.New("unknown witness scope")
return
}

View file

@ -4,14 +4,20 @@ import (
"testing"
"github.com/nspcc-dev/neo-go/internal/testserdes"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/stretchr/testify/require"
)
func TestCosignerEncodeDecode(t *testing.T) {
pk, err := keys.NewPrivateKey()
require.NoError(t, err)
expected := &Signer{
Account: util.Uint160{1, 2, 3, 4, 5},
Scopes: CustomContracts,
Scopes: CustomContracts | CustomGroups | Rules,
AllowedContracts: []util.Uint160{{1, 2, 3, 4}, {6, 7, 8, 9}},
AllowedGroups: []*keys.PublicKey{pk.PublicKey()},
Rules: []WitnessRule{{Action: WitnessAllow, Condition: ConditionCalledByEntry{}}},
}
actual := &Signer{}
testserdes.EncodeDecodeBinary(t, expected, actual)