[#280] ir: Add frostfs processor unit tests

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-04-26 16:25:50 +03:00 committed by Evgenii Stratonikov
parent 5010b35466
commit 31b4da225a
16 changed files with 491 additions and 104 deletions

View file

@ -10,30 +10,30 @@ import (
)
type Config struct {
key []byte
value []byte
id []byte
KeyValue []byte
ValueValue []byte
IDValue []byte
// txHash is used in notary environmental
// TxHashValue is used in notary environmental
// for calculating unique but same for
// all notification receivers values.
txHash util.Uint256
TxHashValue util.Uint256
}
// TxHash returns hash of the TX with new epoch
// notification.
func (u Config) TxHash() util.Uint256 {
return u.txHash
return u.TxHashValue
}
// MorphEvent implements Neo:Morph Event interface.
func (Config) MorphEvent() {}
func (u Config) ID() []byte { return u.id }
func (u Config) ID() []byte { return u.IDValue }
func (u Config) Key() []byte { return u.key }
func (u Config) Key() []byte { return u.KeyValue }
func (u Config) Value() []byte { return u.value }
func (u Config) Value() []byte { return u.ValueValue }
func ParseConfig(e *state.ContainedNotificationEvent) (event.Event, error) {
var (
@ -51,24 +51,24 @@ func ParseConfig(e *state.ContainedNotificationEvent) (event.Event, error) {
}
// parse id
ev.id, err = client.BytesFromStackItem(params[0])
ev.IDValue, err = client.BytesFromStackItem(params[0])
if err != nil {
return nil, fmt.Errorf("could not get config update id: %w", err)
}
// parse key
ev.key, err = client.BytesFromStackItem(params[1])
ev.KeyValue, err = client.BytesFromStackItem(params[1])
if err != nil {
return nil, fmt.Errorf("could not get config key: %w", err)
}
// parse value
ev.value, err = client.BytesFromStackItem(params[2])
ev.ValueValue, err = client.BytesFromStackItem(params[2])
if err != nil {
return nil, fmt.Errorf("could not get config value: %w", err)
}
ev.txHash = e.Container
ev.TxHashValue = e.Container
return ev, nil
}