Also changed GetNumber() to check on nil interface Signed-off-by: Lebedeva Ekaterina <ekaterina.lebedeva@yadro.com>
35 lines
982 B
Go
35 lines
982 B
Go
package tests
|
|
|
|
import (
|
|
"path"
|
|
"testing"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
|
"github.com/nspcc-dev/neo-go/pkg/neotest/chain"
|
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
|
)
|
|
|
|
const ctrPath = "../contract"
|
|
|
|
func TestContract_GetNumber(t *testing.T) {
|
|
e := newExecutor(t)
|
|
ctrGetNum := neotest.CompileFile(t, e.CommitteeHash, ctrPath, path.Join(ctrPath, "neo-go.yml"))
|
|
e.DeployContract(t, ctrGetNum, nil)
|
|
inv := e.CommitteeInvoker(ctrGetNum.Hash)
|
|
inv.InvokeFail(t, "Cannot get number", "getNumber")
|
|
}
|
|
|
|
func newExecutor(t *testing.T) *neotest.Executor {
|
|
bc, acc := chain.NewSingle(t)
|
|
return neotest.NewExecutor(t, bc, acc, acc)
|
|
}
|
|
|
|
func TestContract_PutNumber(t *testing.T) {
|
|
e := newExecutor(t)
|
|
ctrPutGetNum := neotest.CompileFile(t, e.CommitteeHash, ctrPath, path.Join(ctrPath, "neo-go.yml"))
|
|
e.DeployContract(t, ctrPutGetNum, nil)
|
|
inv := e.CommitteeInvoker(ctrPutGetNum.Hash)
|
|
inv.Invoke(t, stackitem.Null{}, "putNumber", 42)
|
|
|
|
inv.Invoke(t, 42, "getNumber")
|
|
}
|