[#192] processing: Add processing contract test

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-12-06 17:35:58 +03:00 committed by Alex Vanin
parent c840498b6f
commit 9b50e1bb88
2 changed files with 44 additions and 4 deletions

View file

@ -38,7 +38,7 @@ func deployNeoFSContract(t *testing.T, e *neotest.Executor, addrProc util.Uint16
return c.Hash
}
func newNeoFSInvoker(t *testing.T, n int, config ...interface{}) (*neotest.ContractInvoker, keys.PublicKeys) {
func newNeoFSInvoker(t *testing.T, n int, config ...interface{}) (*neotest.ContractInvoker, neotest.Signer, keys.PublicKeys) {
e := newExecutor(t)
accounts := make([]*wallet.Account, n)
@ -76,13 +76,13 @@ func newNeoFSInvoker(t *testing.T, n int, config ...interface{}) (*neotest.Contr
e.Validator.ScriptHash(), alphabet.ScriptHash(),
int64(10_0000_0000), nil)
return e.CommitteeInvoker(h).WithSigners(alphabet), pubs
return e.CommitteeInvoker(h).WithSigners(alphabet), alphabet, pubs
}
func TestNeoFS_AlphabetList(t *testing.T) {
const alphabetSize = 4
e, pubs := newNeoFSInvoker(t, alphabetSize)
e, _, pubs := newNeoFSInvoker(t, alphabetSize)
arr := make([]stackitem.Item, len(pubs))
for i := range arr {
arr[i] = stackitem.NewStruct([]stackitem.Item{
@ -94,7 +94,7 @@ func TestNeoFS_AlphabetList(t *testing.T) {
}
func TestNeoFS_InnerRingCandidate(t *testing.T) {
e, _ := newNeoFSInvoker(t, 4, neofs.CandidateFeeConfigKey, int64(10))
e, _, _ := newNeoFSInvoker(t, 4, neofs.CandidateFeeConfigKey, int64(10))
const candidateCount = 3

40
tests/processing_test.go Normal file
View file

@ -0,0 +1,40 @@
package tests
import (
"path"
"testing"
"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"
)
const processingPath = "../processing"
func deployProcessingContract(t *testing.T, e *neotest.Executor, addrNeoFS util.Uint160) util.Uint160 {
c := neotest.CompileFile(t, e.CommitteeHash, processingPath, path.Join(processingPath, "config.yml"))
args := make([]interface{}, 1)
args[0] = addrNeoFS
e.DeployContract(t, c, args)
return c.Hash
}
func newProcessingInvoker(t *testing.T) (*neotest.ContractInvoker, neotest.Signer) {
neofsInvoker, irMultiAcc, _ := newNeoFSInvoker(t, 2)
hash := deployProcessingContract(t, neofsInvoker.Executor, neofsInvoker.Hash)
return neofsInvoker.CommitteeInvoker(hash), irMultiAcc
}
func TestVerify_Processing(t *testing.T) {
c, irMultiAcc := newProcessingInvoker(t)
const method = "verify"
cIR := c.WithSigners(irMultiAcc)
cIR.Invoke(t, stackitem.NewBool(true), method)
c.Invoke(t, stackitem.NewBool(false), method)
}