[#280] ir: Add alphabet processor unit tests

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-04-26 10:51:30 +03:00 committed by Evgenii Stratonikov
parent 53693071de
commit e89fa7f69f
4 changed files with 316 additions and 15 deletions

View file

@ -3,12 +3,13 @@ package alphabet
import (
"errors"
"fmt"
"time"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
nmClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/panjf2000/ants/v2"
"go.uber.org/zap"
@ -32,14 +33,24 @@ type (
GetByIndex(int) (util.Uint160, bool)
}
netmapClient interface {
NetMap() (*netmap.NetMap, error)
}
morphClient interface {
Invoke(contract util.Uint160, fee fixedn.Fixed8, method string, args ...any) error
TransferGas(receiver util.Uint160, amount fixedn.Fixed8) error
BatchTransferGas(receivers []util.Uint160, amount fixedn.Fixed8) error
}
// Processor of events produced for alphabet contracts in the sidechain.
Processor struct {
parsedWallets []util.Uint160
log *logger.Logger
pool *ants.Pool
alphabetContracts Contracts
netmapClient *nmClient.Client
morphClient *client.Client
netmapClient netmapClient
morphClient morphClient
irList Indexer
storageEmission uint64
}
@ -50,8 +61,8 @@ type (
Log *logger.Logger
PoolSize int
AlphabetContracts Contracts
NetmapClient *nmClient.Client
MorphClient *client.Client
NetmapClient netmapClient
MorphClient morphClient
IRList Indexer
StorageEmission uint64
}
@ -106,3 +117,11 @@ func (ap *Processor) ListenerNotaryParsers() []event.NotaryParserInfo {
func (ap *Processor) ListenerNotaryHandlers() []event.NotaryHandlerInfo {
return nil
}
// WaitPoolRunning waits while pool has running tasks
// For use in test only.
func (ap *Processor) WaitPoolRunning() {
for ap.pool.Running() > 0 {
time.Sleep(10 * time.Millisecond)
}
}