forked from TrueCloudLab/frostfs-contract
[#152] netmap: allow only alphabet calls in updateState
If notary is enabled only alphabet calls are expected. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
c008910157
commit
e1ee1c203c
2 changed files with 49 additions and 18 deletions
|
@ -96,3 +96,36 @@ func TestAddPeer(t *testing.T) {
|
|||
require.Equal(t, 1, len(nodes))
|
||||
checkNode(t, dummyInfo, 1, nodes[0])
|
||||
}
|
||||
|
||||
func TestUpdateState(t *testing.T) {
|
||||
bc := NewChain(t)
|
||||
h := prepareNetmapContract(t, bc)
|
||||
|
||||
acc := NewAccount(t, bc)
|
||||
dummyInfo := dummyNodeInfo(acc)
|
||||
|
||||
tx := PrepareInvoke(t, bc, []*wallet.Account{CommitteeAcc, acc}, h, "addPeer", dummyInfo)
|
||||
AddBlockCheckHalt(t, bc, tx)
|
||||
|
||||
t.Run("missing witness", func(t *testing.T) {
|
||||
tx = PrepareInvoke(t, bc, acc, h, "updateState", int64(2), acc.PrivateKey().PublicKey().Bytes())
|
||||
AddBlock(t, bc, tx)
|
||||
CheckFault(t, bc, tx.Hash(), "updateState: alphabet witness check failed")
|
||||
|
||||
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,
|
||||
"updateState", int64(2), acc.PrivateKey().PublicKey().Bytes())
|
||||
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))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue