From 912eaab8d8fa767f2de499ddec3bce32d3190653 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Fri, 21 Jan 2022 10:57:27 +0300 Subject: [PATCH] [#198] test: Adopt `neotest` changes This reverts commit 84181834989ec29ff995effb3339530703c7ab0f. Signed-off-by: Pavel Karpy --- tests/alphabet_test.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/alphabet_test.go b/tests/alphabet_test.go index aef4dd2..090aecd 100644 --- a/tests/alphabet_test.go +++ b/tests/alphabet_test.go @@ -18,11 +18,6 @@ import ( const alphabetPath = "../alphabet" -// FIXME: delete after https://github.com/nspcc-dev/neo-go/issues/2297 -const singleValidatorWIF = "KxyjQ8eUa4FHt3Gvioyt1Wz29cTUrE4eTqX3yFSk1YFCsPL8uNsY" - -var committeeAcc, _ = wallet.NewAccountFromWIF(singleValidatorWIF) - func deployAlphabetContract(t *testing.T, e *neotest.Executor, addrNetmap, addrProxy util.Uint160, name string, index, total int64) util.Uint160 { c := neotest.CompileFile(t, e.CommitteeHash, alphabetPath, path.Join(alphabetPath, "config.yml")) @@ -56,7 +51,9 @@ func newAlphabetInvoker(t *testing.T) (*neotest.Executor, *neotest.ContractInvok deployProxyContract(t, e, ctrNetmap.Hash) hash := deployAlphabetContract(t, e, ctrNetmap.Hash, ctrProxy.Hash, "Az", 0, 1) - setAlphabetRole(t, e, committeeAcc.PrivateKey().PublicKey().Bytes()) + alphabet := getAlphabetAcc(t, e) + + setAlphabetRole(t, e, alphabet.PrivateKey().PublicKey().Bytes()) return e, e.CommitteeInvoker(hash) } @@ -66,7 +63,9 @@ func TestEmit(t *testing.T) { const method = "emit" - cCommittee := c.WithSigners(neotest.NewSingleSigner(committeeAcc)) + alphabet := getAlphabetAcc(t, c.Executor) + + cCommittee := c.WithSigners(neotest.NewSingleSigner(alphabet)) cCommittee.InvokeFail(t, "no gas to emit", method) transferNeoToContract(t, c) @@ -142,3 +141,10 @@ func setAlphabetRole(t *testing.T, e *neotest.Executor, new []byte) { // set committee as NeoFSAlphabet designInvoker.Invoke(t, stackitem.Null{}, "designateAsRole", int64(noderoles.NeoFSAlphabet), []interface{}{new}) } + +func getAlphabetAcc(t *testing.T, e *neotest.Executor) *wallet.Account { + multi, ok := e.Committee.(neotest.MultiSigner) + require.True(t, ok) + + return multi.Single(0).Account() +}