File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,6 +59,9 @@ func (db *DB) Connect(
5959 return err
6060 }
6161
62+ if db .p2p == nil {
63+ return ErrNoP2P
64+ }
6265 return db .p2p .Connect (ctx , addresses )
6366}
6467
Original file line number Diff line number Diff line change 1+ // Copyright 2026 Democratized Data Foundation
2+ //
3+ // Use of this software is governed by the Business Source License
4+ // included in the file licenses/BSL.txt.
5+ //
6+ // As of the Change Date specified in that file, in accordance with
7+ // the Business Source License, use of this software will be governed
8+ // by the Apache License, Version 2.0, included in the file
9+ // licenses/APL.txt.
10+
11+ package db
12+
13+ import (
14+ "context"
15+ "testing"
16+
17+ "github.com/stretchr/testify/require"
18+ )
19+
20+ // TestDB_Connect_WithoutP2P_ReturnsError tests that an error will be returned if
21+ // Conneect is called with P2P disabled.
22+ func TestDB_Connect_WithoutP2P_ReturnsError (t * testing.T ) {
23+ db := & DB {} // P2P is nil
24+
25+ err := db .Connect (context .Background (), []string {"/ip4/0.0.0.0/tcp/9171/p2p/12D3KooWBogusPeerID" })
26+ require .ErrorIs (t , err , ErrNoP2P )
27+ }
You can’t perform that action at this time.
0 commit comments