ax(node): enforce TestFilename_Function_{Good,Bad,Ugly} naming in peer_test.go
All peer registry test functions lacked the mandatory category suffix required by AX-10 (CLI tests as artifact validation / test naming convention). Renamed every test to carry _Good, _Bad, or _Ugly and split the former monolithic AddPeer test into three focused cases. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
7b50431043
commit
5b6a607018
1 changed files with 46 additions and 20 deletions
|
|
@ -61,7 +61,7 @@ func TestPeer_NewPeerRegistry_Ugly(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_AddPeer(t *testing.T) {
|
||||
func TestPeerRegistry_AddPeer_Good(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
|
|
@ -82,15 +82,41 @@ func TestPeerRegistry_AddPeer(t *testing.T) {
|
|||
if pr.Count() != 1 {
|
||||
t.Errorf("expected 1 peer, got %d", pr.Count())
|
||||
}
|
||||
}
|
||||
|
||||
// Try to add duplicate
|
||||
err = pr.AddPeer(peer)
|
||||
func TestPeerRegistry_AddPeer_Bad(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
// Peer with no ID must be rejected
|
||||
err := pr.AddPeer(&Peer{Name: "No ID Peer"})
|
||||
if err == nil {
|
||||
t.Error("expected error when adding peer with empty ID")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_AddPeer_Ugly(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
peer := &Peer{
|
||||
ID: "dup-peer",
|
||||
Name: "Duplicate Peer",
|
||||
PublicKey: "dupkey123",
|
||||
Address: "192.168.1.101:9091",
|
||||
Role: RoleWorker,
|
||||
}
|
||||
|
||||
pr.AddPeer(peer)
|
||||
|
||||
// Adding the same peer twice must fail
|
||||
err := pr.AddPeer(peer)
|
||||
if err == nil {
|
||||
t.Error("expected error when adding duplicate peer")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_GetPeer(t *testing.T) {
|
||||
func TestPeerRegistry_GetPeer_Good(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
|
|
@ -120,7 +146,7 @@ func TestPeerRegistry_GetPeer(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_ListPeers(t *testing.T) {
|
||||
func TestPeerRegistry_ListPeers_Good(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
|
|
@ -140,7 +166,7 @@ func TestPeerRegistry_ListPeers(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_RemovePeer(t *testing.T) {
|
||||
func TestPeerRegistry_RemovePeer_Good(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
|
|
@ -173,7 +199,7 @@ func TestPeerRegistry_RemovePeer(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_UpdateMetrics(t *testing.T) {
|
||||
func TestPeerRegistry_UpdateMetrics_Good(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
|
|
@ -206,7 +232,7 @@ func TestPeerRegistry_UpdateMetrics(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_UpdateScore(t *testing.T) {
|
||||
func TestPeerRegistry_UpdateScore_Good(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
|
|
@ -260,7 +286,7 @@ func TestPeerRegistry_UpdateScore(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_SetConnected(t *testing.T) {
|
||||
func TestPeerRegistry_SetConnected_Good(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
|
|
@ -295,7 +321,7 @@ func TestPeerRegistry_SetConnected(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_GetConnectedPeers(t *testing.T) {
|
||||
func TestPeerRegistry_GetConnectedPeers_Good(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
|
|
@ -318,7 +344,7 @@ func TestPeerRegistry_GetConnectedPeers(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_SelectOptimalPeer(t *testing.T) {
|
||||
func TestPeerRegistry_SelectOptimalPeer_Good(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
|
|
@ -344,7 +370,7 @@ func TestPeerRegistry_SelectOptimalPeer(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_SelectNearestPeers(t *testing.T) {
|
||||
func TestPeerRegistry_SelectNearestPeers_Good(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
|
|
@ -365,7 +391,7 @@ func TestPeerRegistry_SelectNearestPeers(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_Persistence(t *testing.T) {
|
||||
func TestPeerRegistry_Persistence_Good(t *testing.T) {
|
||||
tmpDir, _ := os.MkdirTemp("", "persist-test")
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
|
|
@ -414,7 +440,7 @@ func TestPeerRegistry_Persistence(t *testing.T) {
|
|||
|
||||
// --- Security Feature Tests ---
|
||||
|
||||
func TestPeerRegistry_AuthMode(t *testing.T) {
|
||||
func TestPeerRegistry_AuthMode_Good(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
|
|
@ -436,7 +462,7 @@ func TestPeerRegistry_AuthMode(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_PublicKeyAllowlist(t *testing.T) {
|
||||
func TestPeerRegistry_PublicKeyAllowlist_Good(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
|
|
@ -479,7 +505,7 @@ func TestPeerRegistry_PublicKeyAllowlist(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_IsPeerAllowed_OpenMode(t *testing.T) {
|
||||
func TestPeerRegistry_IsPeerAllowed_Good(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
|
|
@ -495,7 +521,7 @@ func TestPeerRegistry_IsPeerAllowed_OpenMode(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_IsPeerAllowed_AllowlistMode(t *testing.T) {
|
||||
func TestPeerRegistry_IsPeerAllowed_Bad(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
|
|
@ -530,7 +556,7 @@ func TestPeerRegistry_IsPeerAllowed_AllowlistMode(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_PeerNameValidation(t *testing.T) {
|
||||
func TestPeerRegistry_PeerNameValidation_Ugly(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
|
|
@ -574,7 +600,7 @@ func TestPeerRegistry_PeerNameValidation(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_ScoreRecording(t *testing.T) {
|
||||
func TestPeerRegistry_ScoreRecording_Good(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
|
|
@ -630,7 +656,7 @@ func TestPeerRegistry_ScoreRecording(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPeerRegistry_GetPeersByScore(t *testing.T) {
|
||||
func TestPeerRegistry_GetPeersByScore_Good(t *testing.T) {
|
||||
pr, cleanup := setupTestPeerRegistry(t)
|
||||
defer cleanup()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue