-
Notifications
You must be signed in to change notification settings - Fork 1
/
transactions_test.go
91 lines (74 loc) · 1.92 KB
/
transactions_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
79
80
81
82
83
84
85
86
87
88
89
90
91
package ethcli_test
import (
"encoding/json"
"testing"
"github.com/ethereum/go-ethereum/ethclient"
ethcli "github.com/medeirosfalante/ethcli"
)
func TestGetByBlock(t *testing.T) {
client, err := ethclient.Dial("https://data-seed-prebsc-2-s2.binance.org:8545")
if err != nil {
t.Errorf("err : %s", err)
return
}
txs := ethcli.NewTransactions(client, "BNB")
tx, err := txs.GetBlock(9197771, 9197775, []string{"0xf35d75E2Ce765fD4aB1Da7b331eB03C56D4859c4"})
if err != nil {
t.Errorf("err : %s", err)
return
}
if len(tx) <= 0 {
t.Errorf("invalid counter need more than 0")
return
}
}
func TestGetByBlockNative(t *testing.T) {
client, err := ethclient.Dial("https://data-seed-prebsc-2-s2.binance.org:8545")
if err != nil {
t.Errorf("err : %s", err)
return
}
txs := ethcli.NewTransactions(client, "BNB")
tx, err := txs.GetBlockNative(9337807, 9337809)
if err != nil {
t.Errorf("err : %s", err)
return
}
if len(tx) <= 0 {
t.Errorf("invalid counter need more than 0")
return
}
}
func TestGetByBlockNativeByBlock(t *testing.T) {
client, err := ethclient.Dial("https://data-seed-prebsc-2-s2.binance.org:8545")
if err != nil {
t.Errorf("err : %s", err)
return
}
txs := ethcli.NewTransactions(client, "BNB")
tx, err := txs.GetBlockNativeByBlock(9337809)
if err != nil {
t.Errorf("err : %s", err)
return
}
if len(tx) <= 0 {
t.Errorf("invalid counter need more than 0")
return
}
}
func TestGetTransactionByHash(t *testing.T) {
client, err := ethclient.Dial("https://data-seed-prebsc-2-s2.binance.org:8545")
if err != nil {
t.Errorf("err : %s", err)
return
}
txs := ethcli.NewTransactions(client, "BNB")
tx, err := txs.GetTrasactionByHex("0x955a08ca3e25d5a28b40e286417df9bd18e7f59e7ef30f4bc2c24f49c05f5c3f")
t.Errorf("invalid counter need more than 0")
data, _ := json.MarshalIndent(tx, "", "\t")
t.Errorf("err : \n%s\n", data)
if err != nil {
t.Errorf("err : %s", err)
return
}
}