[#161] netmap: fix tests

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2021-11-17 11:20:13 +03:00 committed by Alex Vanin
parent 68eac87e64
commit 370720c83b
3 changed files with 17 additions and 28 deletions

2
go.mod
View file

@ -4,6 +4,6 @@ go 1.14
require ( require (
github.com/mr-tron/base58 v1.2.0 github.com/mr-tron/base58 v1.2.0
github.com/nspcc-dev/neo-go v0.97.4-pre.0.20211115125313-0e1fe2f58b1a github.com/nspcc-dev/neo-go v0.97.4-pre.0.20211116130941-ecfe3e724732
github.com/stretchr/testify v1.7.0 github.com/stretchr/testify v1.7.0
) )

6
go.sum
View file

@ -177,10 +177,8 @@ github.com/nspcc-dev/hrw v1.0.9/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkP
github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg= github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg=
github.com/nspcc-dev/neo-go v0.91.0/go.mod h1:G6HdOWvzQ6tlvFdvFSN/PgCzLPN/X/X4d5hTjFRUDcc= github.com/nspcc-dev/neo-go v0.91.0/go.mod h1:G6HdOWvzQ6tlvFdvFSN/PgCzLPN/X/X4d5hTjFRUDcc=
github.com/nspcc-dev/neo-go v0.95.1/go.mod h1:bW07ge1WFXsBgqrcPpLUr6OcyQxHqM26MZNesWMdH0c= github.com/nspcc-dev/neo-go v0.95.1/go.mod h1:bW07ge1WFXsBgqrcPpLUr6OcyQxHqM26MZNesWMdH0c=
github.com/nspcc-dev/neo-go v0.97.4-pre.0.20211111084655-0a7f8afcea5d h1:h3duQCMpHn0Vq1qeKYVdK5RQyNPu8JfpUrC9S9EsLZU= github.com/nspcc-dev/neo-go v0.97.4-pre.0.20211116130941-ecfe3e724732 h1:iSk3NRGcHHgrYHpd2vqpMykm1hKiWCwhd03rCgDl4/c=
github.com/nspcc-dev/neo-go v0.97.4-pre.0.20211111084655-0a7f8afcea5d/go.mod h1:i6TJVL2vwddNlP1CftD0b8qZ2mcTi9DzYxOlxkXxgg0= github.com/nspcc-dev/neo-go v0.97.4-pre.0.20211116130941-ecfe3e724732/go.mod h1:i6TJVL2vwddNlP1CftD0b8qZ2mcTi9DzYxOlxkXxgg0=
github.com/nspcc-dev/neo-go v0.97.4-pre.0.20211115125313-0e1fe2f58b1a h1:H8BHO5syx7qT6LrRwLPbWunQCeaaveAnjunBiK1XGzg=
github.com/nspcc-dev/neo-go v0.97.4-pre.0.20211115125313-0e1fe2f58b1a/go.mod h1:i6TJVL2vwddNlP1CftD0b8qZ2mcTi9DzYxOlxkXxgg0=
github.com/nspcc-dev/neofs-api-go v1.24.0/go.mod h1:G7dqincfdjBrAbL5nxVp82emF05fSVEqe59ICsoRDI8= github.com/nspcc-dev/neofs-api-go v1.24.0/go.mod h1:G7dqincfdjBrAbL5nxVp82emF05fSVEqe59ICsoRDI8=
github.com/nspcc-dev/neofs-api-go v1.27.1 h1:ONdKOnm0/hK6m38VTUliCHY6RTxg+IpAzY4G+BeOZG4= github.com/nspcc-dev/neofs-api-go v1.27.1 h1:ONdKOnm0/hK6m38VTUliCHY6RTxg+IpAzY4G+BeOZG4=
github.com/nspcc-dev/neofs-api-go v1.27.1/go.mod h1:i0Cwgvcu9A4M4e58pydbXFisUhSxpfljmuWFPIp2btE= github.com/nspcc-dev/neofs-api-go v1.27.1/go.mod h1:i0Cwgvcu9A4M4e58pydbXFisUhSxpfljmuWFPIp2btE=

View file

@ -92,34 +92,25 @@ func TestAddPeer(t *testing.T) {
} }
func TestUpdateState(t *testing.T) { func TestUpdateState(t *testing.T) {
bc := NewChain(t) e := newNetmapInvoker(t)
h := prepareNetmapContract(t, bc)
acc := NewAccount(t, bc) acc := e.NewAccount(t)
cAcc := e.WithSigners(acc)
cBoth := e.WithSigners(e.Committee, acc)
dummyInfo := dummyNodeInfo(acc) dummyInfo := dummyNodeInfo(acc)
tx := PrepareInvoke(t, bc, []*wallet.Account{CommitteeAcc, acc}, h, "addPeer", dummyInfo) cBoth.Invoke(t, stackitem.Null{}, "addPeer", dummyInfo)
AddBlockCheckHalt(t, bc, tx)
pub, ok := vm.ParseSignatureContract(acc.Script())
require.True(t, ok)
t.Run("missing witness", func(t *testing.T) { t.Run("missing witness", func(t *testing.T) {
tx = PrepareInvoke(t, bc, acc, h, "updateState", int64(2), acc.PrivateKey().PublicKey().Bytes()) cAcc.InvokeFail(t, "updateState: alphabet witness check failed",
AddBlock(t, bc, tx) "updateState", int64(2), pub)
CheckFault(t, bc, tx.Hash(), "updateState: alphabet witness check failed") e.InvokeFail(t, "updateState: witness check failed",
"updateState", int64(2), pub)
tx = PrepareInvoke(t, bc, CommitteeAcc, h, "updateState", int64(2), acc.PrivateKey().PublicKey().Bytes())
AddBlock(t, bc, tx)
CheckFault(t, bc, tx.Hash(), "updateState: witness check failed")
}) })
tx = PrepareInvoke(t, bc, []*wallet.Account{CommitteeAcc, acc}, h, cBoth.Invoke(t, stackitem.Null{}, "updateState", int64(2), pub)
"updateState", int64(2), acc.PrivateKey().PublicKey().Bytes()) cAcc.Invoke(t, stackitem.NewArray([]stackitem.Item{}), "netmapCandidates")
AddBlockCheckHalt(t, bc, tx)
tx = PrepareInvoke(t, bc, acc, h, "netmapCandidates")
AddBlock(t, bc, tx)
aer := CheckHalt(t, bc, tx.Hash())
nodes, ok := aer.Stack[0].Value().([]stackitem.Item)
require.True(t, ok)
require.Equal(t, 0, len(nodes))
} }