All checks were successful
Vulncheck / Vulncheck (push) Successful in 1m9s
Build / Build Components (push) Successful in 1m59s
Pre-commit hooks / Pre-commit (push) Successful in 2m2s
Tests and linters / Run gofumpt (push) Successful in 3m4s
Tests and linters / Lint (push) Successful in 3m26s
Tests and linters / Staticcheck (push) Successful in 3m39s
Tests and linters / Tests (push) Successful in 3m44s
Tests and linters / gopls check (push) Successful in 4m2s
Tests and linters / Tests with -race (push) Successful in 4m23s
OCI image / Build container images (push) Successful in 4m15s
If request has no tag, but request's public key is netmap node's key or one of allowed internal tag keys from config, then request must use internal IO tag. Change-Id: Iff93b626941a81b088d8999b3f2947f9501dcdf8 Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
36 lines
822 B
Go
36 lines
822 B
Go
package testing
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
|
|
)
|
|
|
|
var (
|
|
errInvalidDiff = errors.New("invalid diff")
|
|
errNetmapNotFound = errors.New("netmap not found")
|
|
)
|
|
|
|
type TestNetmapSource struct {
|
|
Netmaps map[uint64]*netmap.NetMap
|
|
CurrentEpoch uint64
|
|
}
|
|
|
|
func (s *TestNetmapSource) GetNetMap(ctx context.Context, diff uint64) (*netmap.NetMap, error) {
|
|
if diff >= s.CurrentEpoch {
|
|
return nil, errInvalidDiff
|
|
}
|
|
return s.GetNetMapByEpoch(ctx, s.CurrentEpoch-diff)
|
|
}
|
|
|
|
func (s *TestNetmapSource) GetNetMapByEpoch(_ context.Context, epoch uint64) (*netmap.NetMap, error) {
|
|
if nm, found := s.Netmaps[epoch]; found {
|
|
return nm, nil
|
|
}
|
|
return nil, errNetmapNotFound
|
|
}
|
|
|
|
func (s *TestNetmapSource) Epoch(context.Context) (uint64, error) {
|
|
return s.CurrentEpoch, nil
|
|
}
|