github.com/ethersphere/bee/v2@v2.2.0/pkg/settlement/swap/chequebook/common_test.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 chequebook_test
     6  
     7  import (
     8  	"context"
     9  	"math/big"
    10  
    11  	"github.com/ethereum/go-ethereum/common"
    12  	"github.com/ethersphere/bee/v2/pkg/settlement/swap/chequebook"
    13  )
    14  
    15  type chequeSignerMock struct {
    16  	sign func(cheque *chequebook.Cheque) ([]byte, error)
    17  }
    18  
    19  func (m *chequeSignerMock) Sign(cheque *chequebook.Cheque) ([]byte, error) {
    20  	return m.sign(cheque)
    21  }
    22  
    23  type factoryMock struct {
    24  	erc20Address     func(ctx context.Context) (common.Address, error)
    25  	deploy           func(ctx context.Context, issuer common.Address, defaultHardDepositTimeoutDuration *big.Int, nonce common.Hash) (common.Hash, error)
    26  	waitDeployed     func(ctx context.Context, txHash common.Hash) (common.Address, error)
    27  	verifyChequebook func(ctx context.Context, chequebook common.Address) error
    28  }
    29  
    30  // ERC20Address returns the token for which this factory deploys chequebooks.
    31  func (m *factoryMock) ERC20Address(ctx context.Context) (common.Address, error) {
    32  	return m.erc20Address(ctx)
    33  }
    34  
    35  func (m *factoryMock) Deploy(ctx context.Context, issuer common.Address, defaultHardDepositTimeoutDuration *big.Int, nonce common.Hash) (common.Hash, error) {
    36  	return m.deploy(ctx, issuer, defaultHardDepositTimeoutDuration, nonce)
    37  }
    38  
    39  func (m *factoryMock) WaitDeployed(ctx context.Context, txHash common.Hash) (common.Address, error) {
    40  	return m.waitDeployed(ctx, txHash)
    41  }
    42  
    43  // VerifyChequebook checks that the supplied chequebook has been deployed by this factory.
    44  func (m *factoryMock) VerifyChequebook(ctx context.Context, chequebook common.Address) error {
    45  	return m.verifyChequebook(ctx, chequebook)
    46  }