-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtest.go
55 lines (47 loc) · 1.38 KB
/
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
55
package tests
import (
"fmt"
"time"
"github.com/OdyseeTeam/commentron/commentapi"
"github.com/lbryio/lbry.go/v2/extras/errors"
"github.com/lbryio/lbry.go/v2/extras/util"
"github.com/sirupsen/logrus"
)
var address = fmt.Sprintf("http://%s:%d/api", "localhost", 5900)
// Launch launches the e2e tests for commentron
func Launch() {
err := createComment("testing 1")
if err != nil {
logrus.Fatal(err)
}
err = createComment("testing 2")
if err != nil {
logrus.Fatal(err)
}
list, err := listComments()
if err != nil {
logrus.Fatal(err)
}
if len(list.Items) < 2 {
logrus.Fatal("should have at least 2 comments")
}
}
func listComments() (*commentapi.ListResponse, error) {
c := commentapi.NewClient(address)
r, err := c.CommentList(commentapi.ListArgs{
ClaimID: util.PtrToString("abe3c90453fd481383acb4e3d243e2f4efd43e02"),
})
return r, errors.Err(err)
}
func createComment(comment string) error {
c := commentapi.NewClient(address)
_, err := c.CommentCreate(commentapi.CreateArgs{
CommentText: comment,
ClaimID: "abe3c90453fd481383acb4e3d243e2f4efd43e02",
ChannelID: "599617e276c2704a3bff888991bd8a018df672a9",
ChannelName: "@LBRYBeamer",
Signature: "f2e71944954c7e1b5b3a2d01d82c8830e3b9e3ec4d9bb152369dca0707a58e8b390fbdc301539383c398287c08e1c4054198a7730f1fa945c272085b47ec7928",
SigningTS: fmt.Sprintf("%d", time.Now().Unix()),
})
return errors.Err(err)
}