Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion peer/brontide.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ func NewBrontide(cfg Config) *Brontide {
// used to cross-check our own view of the network to mitigate
// various types of eclipse attacks.
header, err := p.cfg.BestBlockView.BestBlockHeader()
if err != nil && header == lastBlockHeader {
if err != nil || header == lastBlockHeader {
return lastSerializedBlockHeader[:]
}

Expand Down
17 changes: 16 additions & 1 deletion peer/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,20 @@ func (m *mockMessageConn) Close() error {
return nil
}

// mockBestBlockView is a mock implementation of chainntnfs.BestBlockView for
// testing.
type mockBestBlockView struct{}

// BestHeight returns a dummy block height.
func (m *mockBestBlockView) BestHeight() (uint32, error) {
return 0, nil
}

// BestBlockHeader returns a dummy block header.
func (m *mockBestBlockView) BestBlockHeader() (*wire.BlockHeader, error) {
return &wire.BlockHeader{}, nil
}

// createTestPeer creates a new peer for testing and returns a context struct
// containing necessary handles and mock objects for conducting tests on peer
// functionalities.
Expand Down Expand Up @@ -739,7 +753,8 @@ func createTestPeer(t *testing.T) *peerTestCtx {

return nil
},
PongBuf: make([]byte, lnwire.MaxPongBytes),
PongBuf: make([]byte, lnwire.MaxPongBytes),
BestBlockView: &mockBestBlockView{},
FetchLastChanUpdate: func(chanID lnwire.ShortChannelID,
) (*lnwire.ChannelUpdate1, error) {

Expand Down
Loading