github.com/ethersphere/bee/v2@v2.2.0/pkg/pingpong/mock/mock.go (about) 1 // Copyright 2020 The Swarm Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package mock 6 7 import ( 8 "context" 9 "time" 10 11 "github.com/ethersphere/bee/v2/pkg/swarm" 12 ) 13 14 type Service struct { 15 pingFunc func(ctx context.Context, address swarm.Address, msgs ...string) (rtt time.Duration, err error) 16 } 17 18 func New(pingFunc func(ctx context.Context, address swarm.Address, msgs ...string) (rtt time.Duration, err error)) *Service { 19 return &Service{pingFunc: pingFunc} 20 } 21 22 func (s *Service) Ping(ctx context.Context, address swarm.Address, msgs ...string) (rtt time.Duration, err error) { 23 return s.pingFunc(ctx, address, msgs...) 24 }