mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 19:29:39 +00:00
smartcontract: add CallFlag.Has() helper
This commit is contained in:
parent
ebbf0321b2
commit
532262827d
2 changed files with 19 additions and 0 deletions
|
@ -13,3 +13,8 @@ const (
|
|||
ReadOnly = AllowStates | AllowCall | AllowNotify
|
||||
All = ReadOnly | AllowModifyStates
|
||||
)
|
||||
|
||||
// Has returns true iff all bits set in cf are also set in f.
|
||||
func (f CallFlag) Has(cf CallFlag) bool {
|
||||
return f&cf == cf
|
||||
}
|
||||
|
|
14
pkg/smartcontract/call_flags_test.go
Normal file
14
pkg/smartcontract/call_flags_test.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
package smartcontract
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestCallFlag_Has(t *testing.T) {
|
||||
require.True(t, AllowCall.Has(AllowCall))
|
||||
require.True(t, (AllowCall | AllowNotify).Has(AllowCall))
|
||||
require.False(t, (AllowCall).Has(AllowCall|AllowNotify))
|
||||
require.True(t, All.Has(ReadOnly))
|
||||
}
|
Loading…
Reference in a new issue