From bef2a6f7ae68f896929eed625bab4e1e90a53ee4 Mon Sep 17 00:00:00 2001 From: Evgeniy Stratonikov Date: Wed, 3 Nov 2021 15:22:08 +0300 Subject: [PATCH] neotest: provide both validator and committee It will become useful for multi-node committee. Signed-off-by: Evgeniy Stratonikov --- .../nft-nd-nns/tests/nonnative_name_service_test.go | 2 +- pkg/neotest/basic.go | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/nft-nd-nns/tests/nonnative_name_service_test.go b/examples/nft-nd-nns/tests/nonnative_name_service_test.go index c6176e8a2..40840981a 100644 --- a/examples/nft-nd-nns/tests/nonnative_name_service_test.go +++ b/examples/nft-nd-nns/tests/nonnative_name_service_test.go @@ -16,7 +16,7 @@ import ( func newNSClient(t *testing.T) *neotest.ContractInvoker { bc, acc := chain.NewSingle(t) - e := neotest.NewExecutor(t, bc, acc) + e := neotest.NewExecutor(t, bc, acc, acc) c := neotest.CompileFile(t, e.CommitteeHash, "..", "../nns.yml") e.DeployContract(t, c, nil) diff --git a/pkg/neotest/basic.go b/pkg/neotest/basic.go index bd33b33ed..25036d4cc 100644 --- a/pkg/neotest/basic.go +++ b/pkg/neotest/basic.go @@ -27,18 +27,20 @@ import ( // Executor is a wrapper over chain state. type Executor struct { Chain blockchainer.Blockchainer + Validator Signer Committee Signer CommitteeHash util.Uint160 Contracts map[string]*Contract } // NewExecutor creates new executor instance from provided blockchain and committee. -func NewExecutor(t *testing.T, bc blockchainer.Blockchainer, committee Signer) *Executor { +func NewExecutor(t *testing.T, bc blockchainer.Blockchainer, validator, committee Signer) *Executor { require.Equal(t, 1, len(bc.GetConfig().StandbyCommittee)) require.IsType(t, multiSigner{}, committee, "committee must be a multi-signer") return &Executor{ Chain: bc, + Validator: validator, Committee: committee, CommitteeHash: committee.ScriptHash(), Contracts: make(map[string]*Contract), @@ -191,9 +193,9 @@ func (e *Executor) NewUnsignedBlock(t *testing.T, txs ...*transaction.Transactio lastBlock := e.TopBlock(t) b := &block.Block{ Header: block.Header{ - NextConsensus: e.Committee.ScriptHash(), + NextConsensus: e.Validator.ScriptHash(), Script: transaction.Witness{ - VerificationScript: e.Committee.Script(), + VerificationScript: e.Validator.Script(), }, Timestamp: lastBlock.Timestamp + 1, }, @@ -219,7 +221,7 @@ func (e *Executor) AddNewBlock(t *testing.T, txs ...*transaction.Transaction) *b // SignBlock add validators signature to b. func (e *Executor) SignBlock(b *block.Block) *block.Block { - invoc := e.Committee.SignHashable(uint32(e.Chain.GetConfig().Magic), b) + invoc := e.Validator.SignHashable(uint32(e.Chain.GetConfig().Magic), b) b.Script.InvocationScript = invoc return b }