[#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

@ -11,22 +11,22 @@ import (
// Withdraw structure of frostfs.Withdraw notification from mainnet chain.
type Withdraw struct {
id []byte
amount int64 // Fixed8
user util.Uint160
IDValue []byte
AmountValue int64 // Fixed8
UserValue util.Uint160
}
// MorphEvent implements Neo:Morph Event interface.
func (Withdraw) MorphEvent() {}
// ID is a withdraw transaction hash.
func (w Withdraw) ID() []byte { return w.id }
func (w Withdraw) ID() []byte { return w.IDValue }
// User returns withdraw receiver script hash from main net.
func (w Withdraw) User() util.Uint160 { return w.user }
func (w Withdraw) User() util.Uint160 { return w.UserValue }
// Amount of the withdraw assets.
func (w Withdraw) Amount() int64 { return w.amount }
func (w Withdraw) Amount() int64 { return w.AmountValue }
// ParseWithdraw notification into withdraw structure.
func ParseWithdraw(e *state.ContainedNotificationEvent) (event.Event, error) {
@ -47,19 +47,19 @@ func ParseWithdraw(e *state.ContainedNotificationEvent) (event.Event, error) {
return nil, fmt.Errorf("could not get withdraw user: %w", err)
}
ev.user, err = util.Uint160DecodeBytesBE(user)
ev.UserValue, err = util.Uint160DecodeBytesBE(user)
if err != nil {
return nil, fmt.Errorf("could not convert withdraw user to uint160: %w", err)
}
// parse amount
ev.amount, err = client.IntFromStackItem(params[1])
ev.AmountValue, err = client.IntFromStackItem(params[1])
if err != nil {
return nil, fmt.Errorf("could not get withdraw amount: %w", err)
}
// parse id
ev.id, err = client.BytesFromStackItem(params[2])
ev.IDValue, err = client.BytesFromStackItem(params[2])
if err != nil {
return nil, fmt.Errorf("could not get withdraw id: %w", err)
}