forked from alphaticks/go-farcaster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_test.go
54 lines (47 loc) · 913 Bytes
/
client_test.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
43
44
45
46
47
48
49
50
51
52
53
54
package farcaster
import (
"crypto/ecdsa"
"encoding/hex"
"fmt"
"github.com/ethereum/go-ethereum/crypto"
"github.com/joho/godotenv"
"os"
"testing"
)
var privateKey *ecdsa.PrivateKey
func TestMain(m *testing.M) {
err := godotenv.Load("test.env")
if err != nil {
panic(err)
}
if os.Getenv("FARCASTER_PRIVATE_KEY") != "" {
b, err := hex.DecodeString(os.Getenv("FARCASTER_PRIVATE_KEY")[2:])
if err != nil {
panic(err)
}
privateKey, err = crypto.ToECDSA(b)
if err != nil {
panic(err)
}
}
if privateKey == nil {
panic("no token or private key provided")
}
m.Run()
}
func TestClient(t *testing.T) {
c, err := NewClient(privateKey, "")
if err != nil {
t.Fatal(err)
}
casts, err := c.GetCasts(2)
if err != nil {
t.Fatal(err)
}
fmt.Println(casts)
/*
if err := c.Cast("Casting from https://github.com/alphaticks/go-farcaster"); err != nil {
t.Fatal(err)
}
*/
}