working towards lightwalletd deb package

This commit is contained in:
jahway603
2021-09-29 02:04:48 -04:00
parent 4dd26ec92b
commit b33b4b476f
4 changed files with 54 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ package main
import (
"context"
"flag"
"fmt"
"net"
"os"
"os/signal"
@@ -97,6 +98,14 @@ func main() {
flag.StringVar(&opts.hush3ConfPath, "conf-file", "", "conf file to pull RPC creds from")
flag.IntVar(&opts.cacheSize, "cache-size", 40000, "number of blocks to hold in the cache")
// creating --version so help2man will work
if len(os.Args) > 1 && (os.Args[1] == "--version" || os.Args[1] == "-v") {
// TODO find a better method than hardcode the version number here
fmt.Printf("hush lightwalletd version 0.1.1\n")
os.Exit(0)
}
// TODO determine why help2man is now complaining about --help even after I tried creating one...
// TODO prod metrics
// TODO support config from file and env vars
flag.Parse()

32
cmd/server/main_test.go Normal file
View File

@@ -0,0 +1,32 @@
// Copyright 2021 The Hush developers
// Released under the GPLv3
package main
import (
"os"
"testing"
)
// TestFileExists checks whether or not the file exists
func TestFileExists(t *testing.T) {
if fileExists("nonexistent-file") {
t.Fatal("fileExists unexpected success")
}
// If the path exists but is a directory, should return false
if fileExists(".") {
t.Fatal("fileExists unexpected success")
}
// The following file should exist, it's what's being tested
if !fileExists("main.go") {
t.Fatal("fileExists failed")
}
}
// fileExists checks if file exists and is not directory to prevent further errors
func fileExists(filename string) bool {
info, err := os.Stat(filename)
if os.IsNotExist(err) {
return false
}
return !info.IsDir()
}