frostfs-contract/tests/processing_test.go

54 lines
1.4 KiB
Go
Raw Permalink Normal View History

package tests
import (
"path"
"testing"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
"github.com/nspcc-dev/neo-go/pkg/neotest"
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/nspcc-dev/neo-go/pkg/wallet"
"github.com/stretchr/testify/require"
)
const processingPath = "../processing"
func deployProcessingContract(t *testing.T, e *neotest.Executor) util.Uint160 {
c := neotest.CompileFile(t, e.CommitteeHash, processingPath, path.Join(processingPath, "config.yml"))
e.DeployContract(t, c, nil)
return c.Hash
}
func newProcessingInvoker(t *testing.T) (*neotest.ContractInvoker, neotest.SingleSigner) {
e := newExecutor(t)
acc, err := wallet.NewAccount()
require.NoError(t, err)
sig := neotest.NewSingleSigner(acc)
gasHash, err := e.Chain.GetNativeContractScriptHash(nativenames.Gas)
require.NoError(t, err)
vc := e.CommitteeInvoker(gasHash).WithSigners(e.Validator)
vc.Invoke(t, true, "transfer",
e.Validator.ScriptHash(), sig.ScriptHash(),
int64(10_0000_0000), nil)
hash := deployProcessingContract(t, e)
return e.CommitteeInvoker(hash), sig
}
func TestVerify_Processing(t *testing.T) {
c, irMultiAcc := newProcessingInvoker(t)
const method = "verify"
cIR := c.WithSigners(irMultiAcc)
cIR.Invoke(t, stackitem.NewBool(false), method)
c.Invoke(t, stackitem.NewBool(true), method)
}