@@ -470,9 +470,10 @@ func TestScoreBounds(t *testing.T) {
470470 }
471471}
472472
473- // TestGetAllUsers tests retrieving all registered users
474- func TestGetAllUsers (t *testing.T) {
473+ // TestGetTotalUsers tests retrieving total user count
474+ func TestGetTotalUsers (t *testing.T) {
475475 trustScores = avl.NewTree()
476+ totalUsers = 0
476477
477478 addr1 := address("g1user1234567890123456789012345678")
478479 addr2 := address("g1user2345678901234567890123456789")
@@ -481,23 +482,25 @@ func TestGetAllUsers(t *testing.T) {
481482 trustScores.Set(string(addr1), &TrustScore{Score: 5.0, LastUpdate: time.Now().Unix()})
482483 trustScores.Set(string(addr2), &TrustScore{Score: 6.0, LastUpdate: time.Now().Unix()})
483484 trustScores.Set(string(addr3), &TrustScore{Score: 7.0, LastUpdate: time.Now().Unix()})
485+ totalUsers = 3
484486
485- allUsers := GetAllUsers ()
487+ count := GetTotalUsers ()
486488
487- if len(allUsers) != 3 {
488- t.Errorf("Expected 3 users, got %d", len(allUsers) )
489+ if count != 3 {
490+ t.Errorf("Expected 3 users, got %d", count )
489491 }
490492
491- if _, exists := allUsers[addr1]; !exists {
492- t.Error("addr1 should exist in all users")
493+ // Verify users exist using GetTrustDetails
494+ if trust := GetTrustDetails(addr1); trust.Score == 0 {
495+ t.Error("addr1 should exist")
493496 }
494497
495- if _, exists := allUsers[ addr2]; !exists {
496- t.Error("addr2 should exist in all users ")
498+ if trust := GetTrustDetails( addr2); trust.Score == 0 {
499+ t.Error("addr2 should exist")
497500 }
498501
499- if _, exists := allUsers[ addr3]; !exists {
500- t.Error("addr3 should exist in all users ")
502+ if trust := GetTrustDetails( addr3); trust.Score == 0 {
503+ t.Error("addr3 should exist")
501504 }
502505}
503506
0 commit comments