[#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,26 +11,26 @@ import (
// Cheque structure of frostfs.Cheque notification from mainnet chain.
type Cheque struct {
id []byte
amount int64 // Fixed8
user util.Uint160
lock util.Uint160
IDValue []byte
AmountValue int64 // Fixed8
UserValue util.Uint160
LockValue util.Uint160
}
// MorphEvent implements Neo:Morph Event interface.
func (Cheque) MorphEvent() {}
// ID is a withdraw transaction hash.
func (c Cheque) ID() []byte { return c.id }
func (c Cheque) ID() []byte { return c.IDValue }
// User returns withdraw receiver script hash from main net.
func (c Cheque) User() util.Uint160 { return c.user }
func (c Cheque) User() util.Uint160 { return c.UserValue }
// Amount of the sent assets.
func (c Cheque) Amount() int64 { return c.amount }
func (c Cheque) Amount() int64 { return c.AmountValue }
// LockAccount return script hash for balance contract wallet.
func (c Cheque) LockAccount() util.Uint160 { return c.lock }
func (c Cheque) LockAccount() util.Uint160 { return c.LockValue }
// ParseCheque from notification into cheque structure.
func ParseCheque(e *state.ContainedNotificationEvent) (event.Event, error) {
@ -49,7 +49,7 @@ func ParseCheque(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 cheque id: %w", err)
}
@ -60,13 +60,13 @@ func ParseCheque(e *state.ContainedNotificationEvent) (event.Event, error) {
return nil, fmt.Errorf("could not get cheque 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 cheque user to uint160: %w", err)
}
// parse amount
ev.amount, err = client.IntFromStackItem(params[2])
ev.AmountValue, err = client.IntFromStackItem(params[2])
if err != nil {
return nil, fmt.Errorf("could not get cheque amount: %w", err)
}
@ -77,7 +77,7 @@ func ParseCheque(e *state.ContainedNotificationEvent) (event.Event, error) {
return nil, fmt.Errorf("could not get cheque lock account: %w", err)
}
ev.lock, err = util.Uint160DecodeBytesBE(lock)
ev.LockValue, err = util.Uint160DecodeBytesBE(lock)
if err != nil {
return nil, fmt.Errorf("could not convert cheque lock account to uint160: %w", err)
}