-
Notifications
You must be signed in to change notification settings - Fork 206
/
test_friendbot.go
42 lines (34 loc) · 733 Bytes
/
test_friendbot.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"log"
"net/http"
"net/url"
"os"
"time"
)
const timeout = 10 * time.Minute
func main() {
startTime := time.Now()
for {
time.Sleep(10 * time.Second)
logLine("Waiting for Friendbot to be available")
if time.Since(startTime) > timeout {
logLine("Timeout")
os.Exit(-1)
}
params := url.Values{}
params.Set("addr", "GDDVAW5VBBMSKIGNHCZIRZ3BCDQXKO7TCPGEPJR4KL72RHAL2R2ETEST")
resp, err := http.Get("http://localhost:8000/friendbot?" + params.Encode())
if err != nil {
logLine(err)
continue
}
if resp.StatusCode == 200 {
logLine("Friendbot is available!")
os.Exit(0)
}
}
}
func logLine(text interface{}) {
log.Println("\033[32;1m[test_friendbot]\033[0m", text)
}