Closed kcalvinalvin closed 6 months ago
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
connmgr/connmanager.go | 2 | 86.27% | ||
<!-- | Total: | 2 | --> |
Totals | |
---|---|
Change from base Build 8117173129: | 0.0% |
Covered Lines: | 29296 |
Relevant Lines: | 51599 |
To reproduce the bug, you can spam go test
in the addrmgr package.
[I] calvin@nixos ~/b/b/addrmgr (master)> go test
--- FAIL: TestAddrManagerV1ToV2 (0.00s)
addrmanager_internal_test.go:171: expected to find 5 adddresses, found 4
FAIL
exit status 1
FAIL github.com/btcsuite/btcd/addrmgr 0.039s
This doesn't happen with this PR applied.
Sometimes the tests in the addrmanager_internal_test will fail with: "addrmanager_internal_test.go: expected to find 5 addresses, found 4"
This is because the generated address with randAddr() may not always generate an address that's routable. If the address is not routable, that address will not be added to the manager when calling AddAddress().
This bug is fixed by creating a new function routableRandAddr() that always creates a routable random address.