[#280] ir: Add netmap processor unit tests

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-04-27 17:57:27 +03:00 committed by Evgenii Stratonikov
parent fb5dcc15d2
commit d00b1c0d29
15 changed files with 690 additions and 41 deletions

View file

@ -13,13 +13,13 @@ import (
)
type UpdatePeer struct {
publicKey *keys.PublicKey
PubKey *keys.PublicKey
state netmap.NodeState
State netmap.NodeState
// For notary notifications only.
// Contains raw transactions of notary request.
notaryRequest *payload.P2PNotaryRequest
Request *payload.P2PNotaryRequest
}
// MorphEvent implements Neo:Morph Event interface.
@ -28,27 +28,27 @@ func (UpdatePeer) MorphEvent() {}
// Online returns true if node's state is requested to be switched
// to "online".
func (s UpdatePeer) Online() bool {
return s.state == netmap.NodeStateOnline
return s.State == netmap.NodeStateOnline
}
// Maintenance returns true if node's state is requested to be switched
// to "maintenance".
func (s UpdatePeer) Maintenance() bool {
return s.state == netmap.NodeStateMaintenance
return s.State == netmap.NodeStateMaintenance
}
func (s UpdatePeer) PublicKey() *keys.PublicKey {
return s.publicKey
return s.PubKey
}
// NotaryRequest returns raw notary request if notification
// was received via notary service. Otherwise, returns nil.
func (s UpdatePeer) NotaryRequest() *payload.P2PNotaryRequest {
return s.notaryRequest
return s.Request
}
func (s *UpdatePeer) decodeState(state int64) error {
switch s.state = netmap.NodeState(state); s.state {
switch s.State = netmap.NodeState(state); s.State {
default:
return fmt.Errorf("unsupported node state %d", state)
case
@ -82,7 +82,7 @@ func ParseUpdatePeer(e *state.ContainedNotificationEvent) (event.Event, error) {
return nil, fmt.Errorf("could not get public key: %w", err)
}
ev.publicKey, err = keys.NewPublicKeyFromBytes(key, elliptic.P256())
ev.PubKey, err = keys.NewPublicKeyFromBytes(key, elliptic.P256())
if err != nil {
return nil, fmt.Errorf("could not parse public key: %w", err)
}