mirror of
https://github.com/LBRYFoundation/lbcd.git
synced 2025-08-23 17:47:24 +00:00
addrmgr/btcd: Updates for staticcheck results.
This makes two modifications based on the results of staticcheck. The first is to use a simplified zero value for the time in the addrmgr package tests. The second is check any errors when opening a directory while attempting to perform old version upgrades.
This commit is contained in:
parent
82cba61bad
commit
aa53c14a19
2 changed files with 4 additions and 1 deletions
|
@ -61,7 +61,7 @@ func TestIsBad(t *testing.T) {
|
||||||
secondsOld := time.Now().Add(-2 * time.Second)
|
secondsOld := time.Now().Add(-2 * time.Second)
|
||||||
minutesOld := time.Now().Add(-27 * time.Minute)
|
minutesOld := time.Now().Add(-27 * time.Minute)
|
||||||
hoursOld := time.Now().Add(-5 * time.Hour)
|
hoursOld := time.Now().Add(-5 * time.Hour)
|
||||||
zeroTime, _ := time.Parse("Jan 1, 1970 at 0:00am (GMT)", "Jan 1, 1970 at 0:00am (GMT)")
|
zeroTime := time.Time{}
|
||||||
|
|
||||||
futureNa := &wire.NetAddress{Timestamp: future}
|
futureNa := &wire.NetAddress{Timestamp: future}
|
||||||
minutesOldNa := &wire.NetAddress{Timestamp: minutesOld}
|
minutesOldNa := &wire.NetAddress{Timestamp: minutesOld}
|
||||||
|
|
|
@ -13,6 +13,9 @@ import (
|
||||||
// dirEmpty returns whether or not the specified directory path is empty.
|
// dirEmpty returns whether or not the specified directory path is empty.
|
||||||
func dirEmpty(dirPath string) (bool, error) {
|
func dirEmpty(dirPath string) (bool, error) {
|
||||||
f, err := os.Open(dirPath)
|
f, err := os.Open(dirPath)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
// Read the names of a max of one entry from the directory. When the
|
// Read the names of a max of one entry from the directory. When the
|
||||||
|
|
Loading…
Add table
Reference in a new issue