little fixes

This commit is contained in:
Ethan Buchman
2015-05-21 19:56:40 -04:00
committed by Jae Kwon
parent 32e02acb0c
commit 26d64412b3
2 changed files with 16 additions and 11 deletions

View File

@ -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. // Set a permission bit. Will set the permission's set bit to true.
func (p *BasePermissions) Set(ty PermFlag, value bool) error { func (p *BasePermissions) Set(ty PermFlag, value bool) error {
if ty == 0 {
return ErrInvalidPermission(ty)
}
p.SetBit |= ty p.SetBit |= ty
if value { if value {
p.Perms |= ty p.Perms |= ty
@ -74,6 +77,9 @@ func (p *BasePermissions) Set(ty PermFlag, value bool) error {
// Set the permission's set bit to false // Set the permission's set bit to false
func (p *BasePermissions) Unset(ty PermFlag) error { func (p *BasePermissions) Unset(ty PermFlag) error {
if ty == 0 {
return ErrInvalidPermission(ty)
}
p.SetBit &= ^ty p.SetBit &= ^ty
return nil return nil
} }

View File

@ -61,6 +61,16 @@ x - unknown output, without create (fail)
x - unknown output, with create (pass) 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 // 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) { func TestSNativeCALL(t *testing.T) {
stateDB := dbm.GetDB("state") stateDB := dbm.GetDB("state")
genDoc := newBaseGenDoc(PermsAllFalse, PermsAllFalse) genDoc := newBaseGenDoc(PermsAllFalse, PermsAllFalse)