Skip to content

Commit

Permalink
fix: loading default port
Browse files Browse the repository at this point in the history
  • Loading branch information
PhearZero committed Nov 5, 2024
1 parent 8ceaebe commit a12872d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ func initConfig() {
}

}

if strings.Contains(algodConfig.EndpointAddress, ":0") {
algodConfig.EndpointAddress = strings.Replace(algodConfig.EndpointAddress, ":0", ":8080", 1)
}
if loadedToken == "" {
// Handle Token Path
tokenPath := algorandData + "/algod.admin.token"
Expand Down
14 changes: 14 additions & 0 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,17 @@ func Test_InitConfigWithAddress(t *testing.T) {
t.Fatal("Invalid Server")
}
}

func Test_InitConfigWithAddressAndDefaultPort(t *testing.T) {
cwd, _ := os.Getwd()
t.Setenv("ALGORAND_DATA", cwd+"/testdata/Test_InitConfigWithAddressAndDefaultPort")

initConfig()
server := viper.Get("server")
if server == "" {
t.Fatal("Invalid Server")
}
if server != "http://255.255.255.255:8080" {
t.Fatal("Invalid Server")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"EndpointAddress": "255.255.255.255:0",
"OtherKey": ""
}

0 comments on commit a12872d

Please sign in to comment.