-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_test.go
34 lines (28 loc) · 839 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
package filecoin
import (
"context"
"testing"
)
// The Lotus Node
// The default token is in ~/.lotus/token
func testClient() *Client {
return New("https://1lB5G4SmGdSTikOo7l6vYlsktdd:b58884915362a99b4fc18c2bf8af8358@filecoin.infura.io")
}
// 测试RpcClient
func TestClient_Request(t *testing.T) {
c := NewClient("https://eth-mainnet.token.im", "")
var blockNumber string
if err := c.Request(context.Background(), "eth_blockNumber", &blockNumber); err != nil {
t.Error(err)
}
t.Log(blockNumber)
var tr struct {
BlockHash string `json:"blockHash"`
BlockNumber string `json:"blockNumber"`
}
if err := c.Request(context.Background(), "eth_getTransactionReceipt", &tr, "0xbb3a336e3f823ec18197f1e13ee875700f08f03e2cab75f0d0b118dabb44cba0"); err != nil {
t.Error(err)
}
t.Log(tr.BlockHash)
t.Log(tr.BlockNumber)
}