-
Notifications
You must be signed in to change notification settings - Fork 8
/
v1history_test.go
78 lines (73 loc) · 1.57 KB
/
v1history_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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package fio
import (
"fmt"
"testing"
)
func TestAPI_HistGetBlockTxids(t *testing.T) {
// fio.devtools: start.sh - option 1, 6 ... not normally started so if connect fails abort the test without failure.
api, _, err := NewConnection(nil, "http://dev:8080")
if err != nil {
return
}
blocks, err := api.HistGetBlockTxids(123)
if err != nil {
t.Error(err)
return
}
if len(blocks.Ids) == 0 {
t.Error("did not get tx list")
fmt.Println(blocks)
}
trace, err := api.GetTransaction(blocks.Ids[0])
if err != nil {
t.Error(err)
return
}
if trace == nil || trace.Receipt.Status != 0 {
t.Error("got empty tx")
}
fmt.Printf("%+v\n", trace)
}
func TestApi_getMaxActions(t *testing.T) {
_, api, _, err := newApi()
if err != nil {
t.Error(err)
return
}
if !api.HasHistory() {
fmt.Println("history api not available, skipping GetMaxActions test")
return
}
h, err := api.GetMaxActions("eosio")
if err != nil {
t.Error(err)
return
}
if h < 1000 {
t.Errorf("eosio did not have enough action traces expected > 1000, got %d", h)
}
}
func TestAPI_GetActionsUniq(t *testing.T) {
_, api, _, err := newApi()
if err != nil {
t.Error(err)
return
}
if !api.HasHistory() {
fmt.Println("history api not available, skipping GetActionsUniq test")
return
}
traces, err := api.GetActionsUniq("o2ouxipw2rt4", 1000, 0)
if err != nil {
t.Error(err)
return
}
seen := make(map[string]bool)
for _, trace := range traces {
if seen[trace.Receipt.ActionDigest] {
t.Error("duplicate trace located")
return
}
seen[trace.Receipt.ActionDigest] = true
}
}