github.com/ethersphere/bee/v2@v2.2.0/pkg/steward/mock/steward.go (about) 1 // Copyright 2021 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 10 "github.com/ethersphere/bee/v2/pkg/postage" 11 "github.com/ethersphere/bee/v2/pkg/swarm" 12 ) 13 14 // Steward represents steward.Interface mock. 15 type Steward struct { 16 addr swarm.Address 17 } 18 19 // Reupload implements steward.Interface Reupload method. 20 // The given address is recorded. 21 func (s *Steward) Reupload(_ context.Context, addr swarm.Address, _ postage.Stamper) error { 22 s.addr = addr 23 return nil 24 } 25 26 // IsRetrievable implements steward.Interface IsRetrievable method. 27 // The method always returns true. 28 func (s *Steward) IsRetrievable(_ context.Context, addr swarm.Address) (bool, error) { 29 return addr.Equal(s.addr), nil 30 } 31 32 // LastAddress returns the last address given to the Reupload method call. 33 func (s *Steward) LastAddress() swarm.Address { 34 return s.addr 35 }