cli: add scope check tests for invocations

It doesn't trigger the problem fixed in the previous commit because here
CreateTxFromScript is used with pre-calculated GAS value from InvokeFunction
and thus it's not performing invocation. Still, it's a nice test extension.
This commit is contained in:
Roman Khimov 2021-11-22 12:46:42 +03:00
parent f58d424c6d
commit e5b5a3b118
2 changed files with 18 additions and 2 deletions

View file

@ -466,9 +466,17 @@ func TestComlileAndInvokeFunction(t *testing.T) {
}) })
t.Run("with cosigner", func(t *testing.T) { t.Run("with cosigner", func(t *testing.T) {
t.Run("cosigner is sender", func(t *testing.T) { t.Run("cosigner is sender (none)", func(t *testing.T) {
e.In.WriteString("one\r") e.In.WriteString("one\r")
e.Run(t, append(cmd, hVerify.StringLE(), "verify", "--", validatorAddr+":Global")...) e.RunWithError(t, append(cmd, h.StringLE(), "checkSenderWitness", "--", validatorAddr+":None")...)
})
t.Run("cosigner is sender (customcontract)", func(t *testing.T) {
e.In.WriteString("one\r")
e.Run(t, append(cmd, h.StringLE(), "checkSenderWitness", "--", validatorAddr+":CustomContracts:"+h.StringLE())...)
})
t.Run("cosigner is sender (global)", func(t *testing.T) {
e.In.WriteString("one\r")
e.Run(t, append(cmd, h.StringLE(), "checkSenderWitness", "--", validatorAddr+":Global")...)
}) })
acc, err := wallet.NewAccount() acc, err := wallet.NewAccount()

View file

@ -40,6 +40,14 @@ func Fail() {
panic("as expected") panic("as expected")
} }
// CheckSenderWitness checks sender's witness.
func CheckSenderWitness() {
tx := runtime.GetScriptContainer()
if !runtime.CheckWitness(tx.Sender) {
panic("not witnessed")
}
}
// Update updates contract with the new one. // Update updates contract with the new one.
func Update(script, manifest []byte) { func Update(script, manifest []byte) {
ctx := storage.GetReadOnlyContext() ctx := storage.GetReadOnlyContext()