forked from TrueCloudLab/frostfs-node
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
|
|
}
|