Merge pull request #2452 from nspcc-dev/fix-rules
core: consider Rules witness scope as valid
This commit is contained in:
commit
9ad9700aef
2 changed files with 8 additions and 2 deletions
|
@ -39,7 +39,7 @@ func (c *Signer) EncodeBinary(bw *io.BinWriter) {
|
||||||
func (c *Signer) DecodeBinary(br *io.BinReader) {
|
func (c *Signer) DecodeBinary(br *io.BinReader) {
|
||||||
br.ReadBytes(c.Account[:])
|
br.ReadBytes(c.Account[:])
|
||||||
c.Scopes = WitnessScope(br.ReadB())
|
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")
|
br.Err = errors.New("unknown witness scope")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,20 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/internal/testserdes"
|
"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/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCosignerEncodeDecode(t *testing.T) {
|
func TestCosignerEncodeDecode(t *testing.T) {
|
||||||
|
pk, err := keys.NewPrivateKey()
|
||||||
|
require.NoError(t, err)
|
||||||
expected := &Signer{
|
expected := &Signer{
|
||||||
Account: util.Uint160{1, 2, 3, 4, 5},
|
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}},
|
AllowedContracts: []util.Uint160{{1, 2, 3, 4}, {6, 7, 8, 9}},
|
||||||
|
AllowedGroups: []*keys.PublicKey{pk.PublicKey()},
|
||||||
|
Rules: []WitnessRule{{Action: WitnessAllow, Condition: ConditionCalledByEntry{}}},
|
||||||
}
|
}
|
||||||
actual := &Signer{}
|
actual := &Signer{}
|
||||||
testserdes.EncodeDecodeBinary(t, expected, actual)
|
testserdes.EncodeDecodeBinary(t, expected, actual)
|
||||||
|
|
Loading…
Reference in a new issue