diff --git a/permission/types/permissions.go b/permission/types/permissions.go index 6310a6754..0451960f5 100644 --- a/permission/types/permissions.go +++ b/permission/types/permissions.go @@ -63,6 +63,9 @@ func (p *BasePermissions) Get(ty PermFlag) (bool, error) { // Set a permission bit. Will set the permission's set bit to true. func (p *BasePermissions) Set(ty PermFlag, value bool) error { + if ty == 0 { + return ErrInvalidPermission(ty) + } p.SetBit |= ty if value { p.Perms |= ty @@ -74,6 +77,9 @@ func (p *BasePermissions) Set(ty PermFlag, value bool) error { // Set the permission's set bit to false func (p *BasePermissions) Unset(ty PermFlag) error { + if ty == 0 { + return ErrInvalidPermission(ty) + } p.SetBit &= ^ty return nil } diff --git a/state/permissions_test.go b/state/permissions_test.go index 30794a51a..1eadc0e6a 100644 --- a/state/permissions_test.go +++ b/state/permissions_test.go @@ -61,6 +61,16 @@ x - unknown output, without create (fail) x - unknown output, with create (pass) +- SNative (CallTx, CALL): + - for each of CallTx, Call +x - call each snative without permission, fails +x - call each snative with permission, pass + - list: +x - base: has,set,unset +x - globals: set +x - roles: has, add, rm + + */ // keys @@ -786,17 +796,6 @@ func TestCreateAccountPermission(t *testing.T) { } -/* -- SNative (CallTx, CALL): - - for each of CallTx, Call - - call each snative without permission, fails - - call each snative with permission, pass - - list: - - base: has,set,unset - - globals: set - - roles: has, add, r -*/ - func TestSNativeCALL(t *testing.T) { stateDB := dbm.GetDB("state") genDoc := newBaseGenDoc(PermsAllFalse, PermsAllFalse)