Browse Source

little fixes

pull/102/head
Ethan Buchman 10 years ago
committed by Jae Kwon
parent
commit
26d64412b3
2 changed files with 16 additions and 11 deletions
  1. +6
    -0
      permission/types/permissions.go
  2. +10
    -11
      state/permissions_test.go

+ 6
- 0
permission/types/permissions.go 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
} }


+ 10
- 11
state/permissions_test.go 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)


Loading…
Cancel
Save