compiler: always ensure manifest passes base check
This commit is contained in:
parent
94f6a9ee61
commit
725e8779a1
5 changed files with 27 additions and 11 deletions
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue