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 }