mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 03:41:34 +00:00
manifest: disallow null groups, fix #3522
IsValid() is used by both compiler and ContractManagement then. Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
parent
f0ae14e4db
commit
e861aeec2e
4 changed files with 15 additions and 4 deletions
|
@ -712,7 +712,8 @@ func TestSystemRuntimeNotify_HFBasilisk(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
m := &manifest.Manifest{
|
||||
Name: "ctr",
|
||||
Name: "ctr",
|
||||
Groups: []manifest.Group{},
|
||||
ABI: manifest.ABI{
|
||||
Methods: []manifest.Method{
|
||||
{
|
||||
|
|
|
@ -52,7 +52,8 @@ func TestManagement_DeployUpdate_HFBasilisk(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
m := &manifest.Manifest{
|
||||
Name: "ctr",
|
||||
Name: "ctr",
|
||||
Groups: []manifest.Group{},
|
||||
ABI: manifest.ABI{
|
||||
Methods: []manifest.Method{
|
||||
{
|
||||
|
@ -87,7 +88,8 @@ func TestManagement_CallInTheSameBlock(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
m := &manifest.Manifest{
|
||||
Name: "ctr",
|
||||
Name: "ctr",
|
||||
Groups: []manifest.Group{},
|
||||
ABI: manifest.ABI{
|
||||
Methods: []manifest.Method{
|
||||
{
|
||||
|
|
|
@ -40,6 +40,9 @@ func (g *Group) IsValid(h util.Uint160) error {
|
|||
// AreValid checks for groups correctness and uniqueness.
|
||||
// If the contract hash is empty, then hash-related checks are omitted.
|
||||
func (g Groups) AreValid(h util.Uint160) error {
|
||||
if g == nil {
|
||||
return errors.New("null groups")
|
||||
}
|
||||
if !h.Equals(util.Uint160{}) {
|
||||
for i := range g {
|
||||
err := g[i].IsValid(h)
|
||||
|
|
|
@ -19,6 +19,10 @@ func TestGroupJSONInOut(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGroupsAreValid(t *testing.T) {
|
||||
var gps Groups
|
||||
|
||||
require.Error(t, gps.AreValid(util.Uint160{})) // null
|
||||
|
||||
h := util.Uint160{42, 42, 42}
|
||||
priv, err := keys.NewPrivateKey()
|
||||
require.NoError(t, err)
|
||||
|
@ -29,7 +33,8 @@ func TestGroupsAreValid(t *testing.T) {
|
|||
gcorrect := Group{pub, priv.Sign(h.BytesBE())}
|
||||
gcorrect2 := Group{pub2, priv2.Sign(h.BytesBE())}
|
||||
gincorrect := Group{pub, priv.Sign(h.BytesLE())}
|
||||
gps := Groups{gcorrect}
|
||||
|
||||
gps = Groups{gcorrect}
|
||||
require.NoError(t, gps.AreValid(h))
|
||||
|
||||
gps = Groups{gincorrect}
|
||||
|
|
Loading…
Reference in a new issue