Skip to content

Commit 21cb047

Browse files
committed
First pass
1 parent 2fd9e2b commit 21cb047

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

internal/db/p2p.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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

internal/db/p2p_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
}

0 commit comments

Comments
 (0)