[#184] *: Move all panics on witness checks in common

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-11-29 15:21:40 +03:00 committed by Alex Vanin
parent ac89694eeb
commit 2ee2344e5f
12 changed files with 91 additions and 124 deletions

View file

@ -200,9 +200,7 @@ func Vote(epoch int, candidates []interop.PublicKey) {
} }
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("invalid invoker")
}
} }
curEpoch := currentEpoch(ctx) curEpoch := currentEpoch(ctx)

View file

@ -166,9 +166,7 @@ func TransferX(from, to interop.Hash160, amount int, details []byte) {
) )
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("this method must be invoked from inner ring")
}
} }
if notaryDisabled && !indirectCall { if notaryDisabled && !indirectCall {
@ -216,9 +214,7 @@ func Lock(txDetails []byte, from, to interop.Hash160, amount, until int) {
} }
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("this method must be invoked from inner ring")
}
} }
details := common.LockTransferDetails(txDetails) details := common.LockTransferDetails(txDetails)
@ -273,9 +269,7 @@ func NewEpoch(epochNum int) {
} }
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("this method must be invoked from inner ring")
}
} }
it := storage.Find(ctx, []byte{}, storage.KeysOnly) it := storage.Find(ctx, []byte{}, storage.KeysOnly)
@ -324,9 +318,7 @@ func Mint(to interop.Hash160, amount int, txDetails []byte) {
} }
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("this method must be invoked from inner ring")
}
} }
details := common.MintTransferDetails(txDetails) details := common.MintTransferDetails(txDetails)
@ -383,9 +375,7 @@ func Burn(from interop.Hash160, amount int, txDetails []byte) {
} }
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("this method must be invoked from inner ring")
}
} }
details := common.BurnTransferDetails(txDetails) details := common.BurnTransferDetails(txDetails)

39
common/witness.go Normal file
View file

@ -0,0 +1,39 @@
package common
import "github.com/nspcc-dev/neo-go/pkg/interop/runtime"
var (
// ErrAlphabetWitnessFailed appears when method must be
// called by Alphabet but was not.
ErrAlphabetWitnessFailed = "alphabet witness check failed"
// ErrOwnerWitnessFailed appears when method must be called
// by owner of some assets but was not.
ErrOwnerWitnessFailed = "owner witness check failed"
// ErrWitnessFailed appears when method must be called
// using certain public key but was not.
ErrWitnessFailed = "witness check failed"
)
// CheckAlphabetWitness checks witness of the passed caller.
// Panics with ErrAlphabetWitnessFailed message on fail.
func CheckAlphabetWitness(caller []byte) {
checkWitnessWithPanic(caller, ErrAlphabetWitnessFailed)
}
// CheckOwnerWitness checks witness of the passed caller.
// Panics with ErrOwnerWitnessFailed message on fail.
func CheckOwnerWitness(caller []byte) {
checkWitnessWithPanic(caller, ErrOwnerWitnessFailed)
}
// CheckWitness checks witness of the passed caller.
// Panics with ErrWitnessFailed message on fail.
func CheckWitness(caller []byte) {
checkWitnessWithPanic(caller, ErrWitnessFailed)
}
func checkWitnessWithPanic(caller []byte, panicMsg string) {
if !runtime.CheckWitness(caller) {
panic(panicMsg)
}
}

View file

@ -226,9 +226,7 @@ func PutNamed(container []byte, signature interop.Signature,
common.RemoveVotes(ctx, id) common.RemoveVotes(ctx, id)
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("alphabet witness check failed")
}
} }
// todo: check if new container with unique container id // todo: check if new container with unique container id
@ -333,9 +331,7 @@ func Delete(containerID []byte, signature interop.Signature, token []byte) {
common.RemoveVotes(ctx, id) common.RemoveVotes(ctx, id)
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("alphabet witness check failed")
}
} }
key := append([]byte(nnsHasAliasKey), containerID...) key := append([]byte(nnsHasAliasKey), containerID...)
@ -445,9 +441,7 @@ func SetEACL(eACL []byte, signature interop.Signature, publicKey interop.PublicK
common.RemoveVotes(ctx, id) common.RemoveVotes(ctx, id)
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("alphabet witness check failed")
}
} }
rule := ExtendedACL{ rule := ExtendedACL{
@ -492,9 +486,7 @@ func PutContainerSize(epoch int, cid []byte, usedSize int, pubKey interop.Public
panic(NotFoundError) panic(NotFoundError)
} }
if !runtime.CheckWitness(pubKey) { common.CheckWitness(pubKey)
panic("invalid witness of container size estimation")
}
if !isStorageNode(ctx, pubKey) { if !isStorageNode(ctx, pubKey) {
panic("method must be invoked by storage node from network map") panic("method must be invoked by storage node from network map")
@ -580,9 +572,7 @@ func NewEpoch(epochNum int) {
} }
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("method must be invoked by inner ring")
}
} }
candidates := keysToDelete(ctx, epochNum) candidates := keysToDelete(ctx, epochNum)
@ -610,9 +600,7 @@ func StartContainerEstimation(epoch int) {
} }
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("method must be invoked by inner ring")
}
} }
if notaryDisabled { if notaryDisabled {
@ -650,9 +638,7 @@ func StopContainerEstimation(epoch int) {
} }
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("method must be invoked by inner ring")
}
} }
if notaryDisabled { if notaryDisabled {

View file

@ -112,9 +112,7 @@ func Update(script []byte, manifest []byte, data interface{}) {
alphabetKeys := roles.GetDesignatedByRole(roles.NeoFSAlphabet, uint32(blockHeight)) alphabetKeys := roles.GetDesignatedByRole(roles.NeoFSAlphabet, uint32(blockHeight))
alphabetCommittee := common.Multiaddress(alphabetKeys, true) alphabetCommittee := common.Multiaddress(alphabetKeys, true)
if !runtime.CheckWitness(alphabetCommittee) { common.CheckAlphabetWitness(alphabetCommittee)
panic("only side chain committee can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.Call(interop.Hash160(management.Hash), "update",
contract.All, script, manifest, common.AppendVersion(data)) contract.All, script, manifest, common.AppendVersion(data))
@ -208,9 +206,7 @@ func InnerRingCandidateRemove(key interop.PublicKey) {
func InnerRingCandidateAdd(key interop.PublicKey) { func InnerRingCandidateAdd(key interop.PublicKey) {
ctx := storage.GetContext() ctx := storage.GetContext()
if !runtime.CheckWitness(key) { common.CheckWitness(key)
panic("this method must be invoked by candidate")
}
c := common.IRNode{PublicKey: key} c := common.IRNode{PublicKey: key}
candidates := getNodes(ctx, candidatesKey) candidates := getNodes(ctx, candidatesKey)
@ -342,9 +338,7 @@ func Cheque(id []byte, user interop.Hash160, amount int, lockAcc []byte) {
} }
} else { } else {
multiaddr := AlphabetAddress() multiaddr := AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("this method must be invoked by alphabet")
}
} }
from := runtime.GetExecutingScriptHash() from := runtime.GetExecutingScriptHash()
@ -435,9 +429,7 @@ func AlphabetUpdate(id []byte, args []interop.PublicKey) {
} }
} else { } else {
multiaddr := AlphabetAddress() multiaddr := AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("this method must be invoked by alphabet")
}
} }
newAlphabet := []common.IRNode{} newAlphabet := []common.IRNode{}
@ -496,9 +488,7 @@ func SetConfig(id, key, val []byte) {
} }
} else { } else {
multiaddr := AlphabetAddress() multiaddr := AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("this method must be invoked by alphabet")
}
} }
if notaryDisabled { if notaryDisabled {

View file

@ -113,9 +113,7 @@ func AddKey(owner []byte, keys []interop.PublicKey) {
) )
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("invocation from non inner ring node")
}
} }
for i := range keys { for i := range keys {
@ -172,9 +170,7 @@ func RemoveKey(owner []byte, keys []interop.PublicKey) {
} }
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("invocation from non inner ring node")
}
} }
for i := range keys { for i := range keys {

View file

@ -161,9 +161,7 @@ func UpdateInnerRing(keys []interop.PublicKey) {
} }
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("this method must be invoked by alphabet nodes")
}
} }
var irList []common.IRNode var irList []common.IRNode
@ -218,9 +216,8 @@ func AddPeer(nodeInfo []byte) {
if !alphabetCall { if !alphabetCall {
// V2 format // V2 format
publicKey := nodeInfo[2:35] // offset:2, len:33 publicKey := nodeInfo[2:35] // offset:2, len:33
if !runtime.CheckWitness(publicKey) { common.CheckWitness(publicKey)
panic("witness check failed")
}
runtime.Notify("AddPeer", nodeInfo) runtime.Notify("AddPeer", nodeInfo)
return return
} }
@ -270,9 +267,8 @@ func UpdateState(state int, publicKey interop.PublicKey) {
alphabet = common.AlphabetNodes() alphabet = common.AlphabetNodes()
nodeKey = common.InnerRingInvoker(alphabet) nodeKey = common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 { if len(nodeKey) == 0 {
if !runtime.CheckWitness(publicKey) { common.CheckWitness(publicKey)
panic("witness check failed")
}
runtime.Notify("UpdateState", state, publicKey) runtime.Notify("UpdateState", state, publicKey)
return return
} }
@ -288,12 +284,8 @@ func UpdateState(state int, publicKey interop.PublicKey) {
common.RemoveVotes(ctx, id) common.RemoveVotes(ctx, id)
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(publicKey) { common.CheckWitness(publicKey)
panic("witness check failed") common.CheckAlphabetWitness(multiaddr)
}
if !runtime.CheckWitness(multiaddr) {
panic("alphabet witness check failed")
}
} }
switch nodeState(state) { switch nodeState(state) {
@ -331,9 +323,7 @@ func NewEpoch(epochNum int) {
} }
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("this method must be invoked by inner ring nodes")
}
} }
if notaryDisabled { if notaryDisabled {
@ -463,9 +453,7 @@ func SetConfig(id, key, val []byte) {
} }
} else { } else {
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("invoked by non inner ring node")
}
} }
if notaryDisabled { if notaryDisabled {

View file

@ -303,9 +303,7 @@ func Register(name string, owner interop.Hash160, email string, refresh, retry,
if !isValid(owner) { if !isValid(owner) {
panic("invalid owner") panic("invalid owner")
} }
if !runtime.CheckWitness(owner) { common.CheckOwnerWitness(owner)
panic("not witnessed by owner")
}
runtime.BurnGas(GetPrice()) runtime.BurnGas(GetPrice())
var ( var (
tokenKey = getTokenKey([]byte(name)) tokenKey = getTokenKey([]byte(name))
@ -368,9 +366,7 @@ func SetAdmin(name string, admin interop.Hash160) {
} }
ctx := storage.GetContext() ctx := storage.GetContext()
ns := getNameState(ctx, []byte(name)) ns := getNameState(ctx, []byte(name))
if !runtime.CheckWitness(ns.Owner) { common.CheckOwnerWitness(ns.Owner)
panic("not witnessed by owner")
}
ns.Admin = admin ns.Admin = admin
putNameState(ctx, ns) putNameState(ctx, ns)
} }

View file

@ -37,8 +37,6 @@ const (
ErrUserNotExist = "user not found" ErrUserNotExist = "user not found"
// ErrAccessDenied is thrown when operation is denied for caller. // ErrAccessDenied is thrown when operation is denied for caller.
ErrAccessDenied = "access denied" ErrAccessDenied = "access denied"
errCheckWitnessFailed = "owner witness check failed"
) )
const ( const (
@ -103,9 +101,7 @@ func Put(id []byte, ownerKey interop.PublicKey, info []byte) {
alphabet := common.AlphabetNodes() alphabet := common.AlphabetNodes()
nodeKey := common.InnerRingInvoker(alphabet) nodeKey := common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 { if len(nodeKey) == 0 {
if !runtime.CheckWitness(ownerKey) { common.CheckWitness(ownerKey)
panic("witness check failed")
}
runtime.Notify("Put", id, ownerKey, info) runtime.Notify("Put", id, ownerKey, info)
return return
} }
@ -119,14 +115,10 @@ func Put(id []byte, ownerKey interop.PublicKey, info []byte) {
common.RemoveVotes(ctx, id) common.RemoveVotes(ctx, id)
} else { } else {
if !runtime.CheckWitness(ownerKey) { common.CheckOwnerWitness(ownerKey)
panic(errCheckWitnessFailed)
}
multiaddr := common.AlphabetAddress() multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) { common.CheckAlphabetWitness(multiaddr)
panic("alphabet witness check failed")
}
} }
storage.Put(ctx, stKey, ownerKey) storage.Put(ctx, stKey, ownerKey)
@ -165,9 +157,7 @@ func Delete(id []byte) {
} }
owner := raw.([]byte) owner := raw.([]byte)
if !runtime.CheckWitness(owner) { common.CheckOwnerWitness(owner)
panic(errCheckWitnessFailed)
}
storage.Delete(ctx, key) storage.Delete(ctx, key)
@ -210,9 +200,7 @@ func AddNodeAdmin(subnetID []byte, adminKey interop.PublicKey) {
} }
owner := rawOwner.([]byte) owner := rawOwner.([]byte)
if !runtime.CheckWitness(owner) { common.CheckOwnerWitness(owner)
panic(errCheckWitnessFailed)
}
stKey[0] = nodeAdminPrefix stKey[0] = nodeAdminPrefix
@ -245,9 +233,7 @@ func RemoveNodeAdmin(subnetID []byte, adminKey interop.PublicKey) {
} }
owner := rawOwner.([]byte) owner := rawOwner.([]byte)
if !runtime.CheckWitness(owner) { common.CheckOwnerWitness(owner)
panic(errCheckWitnessFailed)
}
stKey[0] = nodeAdminPrefix stKey[0] = nodeAdminPrefix
@ -391,9 +377,7 @@ func AddClientAdmin(subnetID []byte, groupID []byte, adminPublicKey interop.Publ
} }
owner := rawOwner.([]byte) owner := rawOwner.([]byte)
if !runtime.CheckWitness(owner) { common.CheckOwnerWitness(owner)
panic(errCheckWitnessFailed)
}
stKey[0] = clientAdminPrefix stKey[0] = clientAdminPrefix
stKey = append(stKey, groupID...) stKey = append(stKey, groupID...)
@ -433,9 +417,7 @@ func RemoveClientAdmin(subnetID []byte, groupID []byte, adminPublicKey interop.P
} }
owner := rawOwner.([]byte) owner := rawOwner.([]byte)
if !runtime.CheckWitness(owner) { common.CheckOwnerWitness(owner)
panic(errCheckWitnessFailed)
}
stKey[0] = clientAdminPrefix stKey[0] = clientAdminPrefix
stKey = append(stKey, groupID...) stKey = append(stKey, groupID...)

View file

@ -10,6 +10,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/neotest" "github.com/nspcc-dev/neo-go/pkg/neotest"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/nspcc-dev/neofs-contract/common"
"github.com/nspcc-dev/neofs-contract/container" "github.com/nspcc-dev/neofs-contract/container"
"github.com/nspcc-dev/neofs-contract/nns" "github.com/nspcc-dev/neofs-contract/nns"
) )
@ -88,7 +89,7 @@ func TestContainerPut(t *testing.T) {
balanceMint(t, cBal, acc, containerFee*1, []byte{}) balanceMint(t, cBal, acc, containerFee*1, []byte{})
cAcc := c.WithSigners(acc) cAcc := c.WithSigners(acc)
cAcc.InvokeFail(t, "alphabet witness check failed", "put", putArgs...) cAcc.InvokeFail(t, common.ErrAlphabetWitnessFailed, "put", putArgs...)
c.Invoke(t, stackitem.Null{}, "put", putArgs...) c.Invoke(t, stackitem.Null{}, "put", putArgs...)
@ -161,7 +162,7 @@ func TestContainerDelete(t *testing.T) {
c.Invoke(t, stackitem.Null{}, "put", cnt.value, cnt.sig, cnt.pub, cnt.token) c.Invoke(t, stackitem.Null{}, "put", cnt.value, cnt.sig, cnt.pub, cnt.token)
cAcc := c.WithSigners(acc) cAcc := c.WithSigners(acc)
cAcc.InvokeFail(t, "alphabet witness check failed", "delete", cAcc.InvokeFail(t, common.ErrAlphabetWitnessFailed, "delete",
cnt.id[:], cnt.sig, cnt.token) cnt.id[:], cnt.sig, cnt.token)
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.token) c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.token)
@ -256,7 +257,7 @@ func TestContainerSetEACL(t *testing.T) {
e := dummyEACL(cnt.id) e := dummyEACL(cnt.id)
setArgs := []interface{}{e.value, e.sig, e.pub, e.token} setArgs := []interface{}{e.value, e.sig, e.pub, e.token}
cAcc := c.WithSigners(acc) cAcc := c.WithSigners(acc)
cAcc.InvokeFail(t, "alphabet witness check failed", "setEACL", setArgs...) cAcc.InvokeFail(t, common.ErrAlphabetWitnessFailed, "setEACL", setArgs...)
c.Invoke(t, stackitem.Null{}, "setEACL", setArgs...) c.Invoke(t, stackitem.Null{}, "setEACL", setArgs...)

View file

@ -11,6 +11,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/vm"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/nspcc-dev/neofs-contract/common"
"github.com/nspcc-dev/neofs-contract/container" "github.com/nspcc-dev/neofs-contract/container"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -73,7 +74,7 @@ func TestAddPeer(t *testing.T) {
acc1 := c.NewAccount(t) acc1 := c.NewAccount(t)
cAcc1 := c.WithSigners(acc1) cAcc1 := c.WithSigners(acc1)
cAcc1.InvokeFail(t, "witness check failed", "addPeer", dummyInfo) cAcc1.InvokeFail(t, common.ErrWitnessFailed, "addPeer", dummyInfo)
h := cAcc.Invoke(t, stackitem.Null{}, "addPeer", dummyInfo) h := cAcc.Invoke(t, stackitem.Null{}, "addPeer", dummyInfo)
aer := cAcc.CheckHalt(t, h) aer := cAcc.CheckHalt(t, h)
@ -105,9 +106,9 @@ func TestUpdateState(t *testing.T) {
require.True(t, ok) require.True(t, ok)
t.Run("missing witness", func(t *testing.T) { t.Run("missing witness", func(t *testing.T) {
cAcc.InvokeFail(t, "alphabet witness check failed", cAcc.InvokeFail(t, common.ErrAlphabetWitnessFailed,
"updateState", int64(2), pub) "updateState", int64(2), pub)
e.InvokeFail(t, "witness check failed", e.InvokeFail(t, common.ErrWitnessFailed,
"updateState", int64(2), pub) "updateState", int64(2), pub)
}) })

View file

@ -45,10 +45,10 @@ func TestSubnet_Put(t *testing.T) {
binary.LittleEndian.PutUint32(id, 123) binary.LittleEndian.PutUint32(id, 123)
info := randomBytes(10) info := randomBytes(10)
e.InvokeFail(t, "witness check failed", "put", id, pub, info) e.InvokeFail(t, common.ErrWitnessFailed, "put", id, pub, info)
cAcc := e.WithSigners(acc) cAcc := e.WithSigners(acc)
cAcc.InvokeFail(t, "alphabet witness check failed", "put", id, pub, info) cAcc.InvokeFail(t, common.ErrAlphabetWitnessFailed, "put", id, pub, info)
cBoth := e.WithSigners(e.Committee, acc) cBoth := e.WithSigners(e.Committee, acc)
cBoth.InvokeFail(t, subnet.ErrInvalidSubnetID, "put", []byte{1, 2, 3}, pub, info) cBoth.InvokeFail(t, subnet.ErrInvalidSubnetID, "put", []byte{1, 2, 3}, pub, info)
@ -63,7 +63,7 @@ func TestSubnet_Delete(t *testing.T) {
id, owner := createSubnet(t, e) id, owner := createSubnet(t, e)
e.InvokeFail(t, "witness check failed", "delete", id) e.InvokeFail(t, common.ErrWitnessFailed, "delete", id)
cAcc := e.WithSigners(owner) cAcc := e.WithSigners(owner)
cAcc.InvokeFail(t, subnet.ErrInvalidSubnetID, "delete", []byte{1, 1, 1, 1}) cAcc.InvokeFail(t, subnet.ErrInvalidSubnetID, "delete", []byte{1, 1, 1, 1})
@ -88,7 +88,7 @@ func TestSubnet_AddNodeAdmin(t *testing.T) {
e.InvokeFail(t, subnet.ErrNotExist, method, []byte{0, 0, 0, 0, 0}, admPub) e.InvokeFail(t, subnet.ErrNotExist, method, []byte{0, 0, 0, 0, 0}, admPub)
cAdm := e.WithSigners(adm) cAdm := e.WithSigners(adm)
cAdm.InvokeFail(t, "owner witness check failed", method, id, admPub) cAdm.InvokeFail(t, common.ErrOwnerWitnessFailed, method, id, admPub)
cOwner := e.WithSigners(owner) cOwner := e.WithSigners(owner)
cOwner.Invoke(t, stackitem.Null{}, method, id, admPub) cOwner.Invoke(t, stackitem.Null{}, method, id, admPub)
@ -112,7 +112,7 @@ func TestSubnet_RemoveNodeAdmin(t *testing.T) {
e.InvokeFail(t, subnet.ErrNotExist, method, []byte{0, 0, 0, 0, 0}, admPub) e.InvokeFail(t, subnet.ErrNotExist, method, []byte{0, 0, 0, 0, 0}, admPub)
cAdm := e.WithSigners(adm) cAdm := e.WithSigners(adm)
cAdm.InvokeFail(t, "owner witness check failed", method, id, admPub) cAdm.InvokeFail(t, common.ErrOwnerWitnessFailed, method, id, admPub)
cOwner := e.WithSigners(owner) cOwner := e.WithSigners(owner)