decred.org/dcrwallet/v3@v3.1.0/wallet/peer_test.go (about)

     1  // Copyright (c) 2020 The Decred developers
     2  // Use of this source code is governed by an ISC
     3  // license that can be found in the LICENSE file.
     4  
     5  package wallet
     6  
     7  import (
     8  	"context"
     9  
    10  	"github.com/decred/dcrd/chaincfg/chainhash"
    11  	"github.com/decred/dcrd/wire"
    12  )
    13  
    14  // peerFuncs implements Peer with custom implementations of each individual method.
    15  // Functions may be left nil (unimplemented) if they will not be called by the test code.
    16  type peerFuncs struct {
    17  	blocks              func(ctx context.Context, blockHashes []*chainhash.Hash) ([]*wire.MsgBlock, error)
    18  	cfiltersV2          func(ctx context.Context, blockHashes []*chainhash.Hash) ([]FilterProof, error)
    19  	headers             func(ctx context.Context, blockLocators []*chainhash.Hash, hashStop *chainhash.Hash) ([]*wire.BlockHeader, error)
    20  	publishTransactions func(ctx context.Context, txs ...*wire.MsgTx) error
    21  }
    22  
    23  func (p *peerFuncs) Blocks(ctx context.Context, blockHashes []*chainhash.Hash) ([]*wire.MsgBlock, error) {
    24  	return p.blocks(ctx, blockHashes)
    25  }
    26  func (p *peerFuncs) CFiltersV2(ctx context.Context, blockHashes []*chainhash.Hash) ([]FilterProof, error) {
    27  	return p.cfiltersV2(ctx, blockHashes)
    28  }
    29  func (p *peerFuncs) Headers(ctx context.Context, blockLocators []*chainhash.Hash, hashStop *chainhash.Hash) ([]*wire.BlockHeader, error) {
    30  	return p.headers(ctx, blockLocators, hashStop)
    31  }
    32  func (p *peerFuncs) PublishTransactions(ctx context.Context, txs ...*wire.MsgTx) error {
    33  	return p.publishTransactions(ctx, txs...)
    34  }