-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsdk_test.go
54 lines (44 loc) · 1.01 KB
/
sdk_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 iost
import (
"testing"
"encoding/json"
"github.com/iost-official/go-iost/common"
)
var addr = "localhost:30002"
func TestGet(t *testing.T) {
client := NewClient()
err := client.Dial(addr)
if err != nil {
t.Fatal(err)
}
t.Log(client.ChainInfo())
t.Log(client.NodeInfo())
// ...
t.Log(client.TxByHash("abc"))
client.Close()
}
func TestSendTx(t *testing.T) {
client := NewClient()
err := client.Dial(addr)
if err != nil {
t.Fatal("error in dial", err)
}
defer client.Close()
tx := NewTx(Config{
GasRatio: 1,
GasLimit: 100000,
Delay: 0,
Expiration: 90,
})
args, err := json.Marshal([]string{"iost", "admin", "admin", "10.000", ""})
if err != nil {
t.Fatal(err)
}
AddAction(tx, "token.iost", "transfer", string(args))
kc := NewKeychain("admin")
kc.AddKey(common.Base58Decode("2yquS3ySrGWPEKywCPzX4RTJugqRh7kJSo5aehsLYPEWkUxBWA39oMrZ7ZxuM4fgyXYs2cPwh5n8aNNpH5x2VyK1"), "active")
kc.SignTx(tx)
handler := NewHandler(tx, client)
hash, err := handler.Send()
t.Log(hash, err)
}