forked from TrueCloudLab/frostfs-node
[#1680] morph/netmap: Adopt to recent contract changes
After recent Netmap contract changes all read methods which return network map (either candidates or snapshots) encode node descriptors into same structure. Decode `netmap.Node` contract-side structure from the call results. Replace node state with the value from the `netmap.Node.State` field. Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
This commit is contained in:
parent
d6c01199c8
commit
eb1fba5182
14 changed files with 135 additions and 221 deletions
|
@ -19,10 +19,12 @@ func Test_stackItemsToNodeInfos(t *testing.T) {
|
|||
rand.Read(pub)
|
||||
|
||||
switch i % 3 {
|
||||
case int(netmapcontract.OfflineState):
|
||||
default:
|
||||
expected[i].SetOffline()
|
||||
case int(netmapcontract.OnlineState):
|
||||
case int(netmapcontract.NodeStateOnline):
|
||||
expected[i].SetOnline()
|
||||
case int(netmapcontract.NodeStateMaintenance):
|
||||
expected[i].SetMaintenance()
|
||||
}
|
||||
|
||||
expected[i].SetPublicKey(pub)
|
||||
|
@ -38,20 +40,20 @@ func Test_stackItemsToNodeInfos(t *testing.T) {
|
|||
|
||||
switch {
|
||||
case expected[i].IsOnline():
|
||||
state = int64(netmapcontract.OnlineState)
|
||||
state = int64(netmapcontract.NodeStateOnline)
|
||||
case expected[i].IsOffline():
|
||||
state = int64(netmapcontract.OfflineState)
|
||||
state = int64(netmapcontract.NodeStateOffline)
|
||||
case expected[i].IsMaintenance():
|
||||
state = int64(netmapcontract.NodeStateMaintenance)
|
||||
}
|
||||
|
||||
items[i] = stackitem.NewStruct([]stackitem.Item{
|
||||
stackitem.NewStruct([]stackitem.Item{
|
||||
stackitem.NewByteArray(data),
|
||||
}),
|
||||
stackitem.NewByteArray(data),
|
||||
stackitem.NewBigInteger(big.NewInt(state)),
|
||||
})
|
||||
}
|
||||
|
||||
actual, err := nodeInfosFromStackItems([]stackitem.Item{stackitem.NewArray(items)}, "")
|
||||
actual, err := decodeNodeList(stackitem.NewArray(items))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, expected, actual)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue