compiler: always ensure manifest passes base check

This commit is contained in:
Anna Shaleva 2022-07-14 15:36:21 +03:00
parent 94f6a9ee61
commit 725e8779a1
5 changed files with 27 additions and 11 deletions

View file

@ -38,11 +38,14 @@ 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 {
for i := range g {
err := g[i].IsValid(h)
if err != nil {
return err
if !h.Equals(util.Uint160{}) {
for i := range g {
err := g[i].IsValid(h)
if err != nil {
return err
}
}
}
if len(g) < 2 {

View file

@ -40,6 +40,9 @@ func TestGroupsAreValid(t *testing.T) {
gps = Groups{gcorrect, gcorrect}
require.Error(t, gps.AreValid(h))
gps = Groups{gincorrect}
require.NoError(t, gps.AreValid(util.Uint160{})) // empty hash.
}
func TestGroupsContains(t *testing.T) {

View file

@ -82,6 +82,7 @@ func (m *Manifest) CanCall(hash util.Uint160, toCall *Manifest, method string) b
// IsValid checks manifest internal consistency and correctness, one of the
// checks is for group signature correctness, contract hash is passed for it.
// If hash is empty, then hash-related checks are omitted.
func (m *Manifest) IsValid(hash util.Uint160) error {
var err error