forked from TrueCloudLab/frostfs-node
[#280] ir: Add frostfs processor unit tests
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
5010b35466
commit
31b4da225a
16 changed files with 491 additions and 104 deletions
|
@ -11,31 +11,31 @@ import (
|
|||
)
|
||||
|
||||
type Bind struct {
|
||||
bindCommon
|
||||
BindCommon
|
||||
}
|
||||
|
||||
type bindCommon struct {
|
||||
user []byte
|
||||
keys [][]byte
|
||||
type BindCommon struct {
|
||||
UserValue []byte
|
||||
KeysValue [][]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 (b bindCommon) TxHash() util.Uint256 {
|
||||
return b.txHash
|
||||
func (b BindCommon) TxHash() util.Uint256 {
|
||||
return b.TxHashValue
|
||||
}
|
||||
|
||||
// MorphEvent implements Neo:Morph Event interface.
|
||||
func (bindCommon) MorphEvent() {}
|
||||
func (BindCommon) MorphEvent() {}
|
||||
|
||||
func (b bindCommon) Keys() [][]byte { return b.keys }
|
||||
func (b BindCommon) Keys() [][]byte { return b.KeysValue }
|
||||
|
||||
func (b bindCommon) User() []byte { return b.user }
|
||||
func (b BindCommon) User() []byte { return b.UserValue }
|
||||
|
||||
func ParseBind(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||
var (
|
||||
|
@ -48,17 +48,17 @@ func ParseBind(e *state.ContainedNotificationEvent) (event.Event, error) {
|
|||
return nil, fmt.Errorf("could not parse stack items from notify event: %w", err)
|
||||
}
|
||||
|
||||
err = parseBind(&ev.bindCommon, params)
|
||||
err = parseBind(&ev.BindCommon, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ev.txHash = e.Container
|
||||
ev.TxHashValue = e.Container
|
||||
|
||||
return ev, nil
|
||||
}
|
||||
|
||||
func parseBind(dst *bindCommon, params []stackitem.Item) error {
|
||||
func parseBind(dst *BindCommon, params []stackitem.Item) error {
|
||||
if ln := len(params); ln != 2 {
|
||||
return event.WrongNumberOfParameters(2, ln)
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ func parseBind(dst *bindCommon, params []stackitem.Item) error {
|
|||
var err error
|
||||
|
||||
// parse user
|
||||
dst.user, err = client.BytesFromStackItem(params[0])
|
||||
dst.UserValue, err = client.BytesFromStackItem(params[0])
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not get bind user: %w", err)
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ func parseBind(dst *bindCommon, params []stackitem.Item) error {
|
|||
return fmt.Errorf("could not get bind keys: %w", err)
|
||||
}
|
||||
|
||||
dst.keys = make([][]byte, 0, len(bindKeys))
|
||||
dst.KeysValue = make([][]byte, 0, len(bindKeys))
|
||||
|
||||
for i := range bindKeys {
|
||||
rawKey, err := client.BytesFromStackItem(bindKeys[i])
|
||||
|
@ -85,7 +85,7 @@ func parseBind(dst *bindCommon, params []stackitem.Item) error {
|
|||
return fmt.Errorf("could not get bind public key: %w", err)
|
||||
}
|
||||
|
||||
dst.keys = append(dst.keys, rawKey)
|
||||
dst.KeysValue = append(dst.KeysValue, rawKey)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue