Skip to content

Conversation

ffranr
Copy link
Contributor

@ffranr ffranr commented Sep 16, 2025

This PR improves the FederationEnvoy.AddServer method by:

  • Moving the server connection check into AddServer, simplifying logic at two call sites.
  • Introducing a ServerAddReport struct that provides detailed feedback on each server addition attempt (e.g., whether it was already known and the result of the connection check).
  • Adding initial unit tests and mocks to provide unit test coverage for AddServer, which previously had none.

Also includes:

  • A supporting change to use UpsertUniverseServer in place of InsertUniverseServer, avoiding unique constraint errors when adding known servers.

Replace the InsertUniverseServer SQL query with UpsertUniverseServer.

Since adding a server that already exists is harmless, we use an upsert
to avoid handling unique constraint errors at call sites.
Move the server connection check into `FederationEnvoy.AddServer`,
simplifying the logic at two call sites.

The method now returns a `ServerAddReport` for each candidate server.
This report includes whether the server was already known, and whether
the connection check was attempted and succeeded/failed.
Add unit tests and supporting mock functionality to provide test
coverage for the `FederationEnvoy.AddServer` method, which previously
had none.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 17771102876

Details

  • 112 of 167 (67.07%) changed or added relevant lines in 5 files are covered.
  • 25468 unchanged lines in 182 files lost coverage.
  • Overall coverage decreased (-11.4%) to 38.196%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rpcserver.go 0 2 0.0%
tapdb/universe_federation.go 2 4 50.0%
universe/federation.go 85 100 85.0%
universe/mock.go 21 57 36.84%
Files with Coverage Reduction New Missed Lines %
proof/util.go 2 81.63%
tapdb/migrations.go 2 76.06%
tapdb/mssmt.go 2 88.64%
tapdb/sqlc/mssmt.sql.go 2 52.98%
address/log.go 3 0.0%
commitment/log.go 3 0.0%
internal/pedersen/commitment.go 3 95.31%
lndservices/log.go 3 0.0%
rfq/log.go 3 0.0%
tapchannel/log.go 3 0.0%
Totals Coverage Status
Change from base Build 17762935341: -11.4%
Covered Lines: 33517
Relevant Lines: 87749

💛 - Coveralls

@ffranr ffranr marked this pull request as draft September 17, 2025 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

2 participants