Files

106 lines
1.7 KiB
Go
Raw Permalink Normal View History

2024-11-28 14:16:37 +08:00
package client
import (
"testing"
)
func TestStruct(t *testing.T) {
type a struct {
name string
age int
}
b := &a{age: 1}
t.Log(b.age)
t.Log(b.name == "")
}
func genClient() (*Client, error) {
url := "http://021.node.internetapi.cn:21030/SCIDE"
2024-11-28 14:16:37 +08:00
pub := "042731bc66608ba21a4301cd6522e3d6a6c7964f8dc3618cfe5d0aae493229a98623de23dfb35a5f9b7b4ac53e1f82ea79325ddf96d88a6bbcaf075df7e98acc5a"
2024-11-28 14:16:37 +08:00
priv := "481343eac82e0d18f8ea3a9f82a8f065543d720209e9f0d8d508f7e343883c45"
2024-11-28 14:16:37 +08:00
client, err := NewClient(url, priv, pub, HttpCOptions{})
if err != nil {
return nil, err
}
return client, nil
}
func TestNewClient(t *testing.T) {
client, err := genClient()
if err != nil {
t.Error(err)
}
t.Log(client)
}
func TestClient_Ping(t *testing.T) {
client, err := genClient()
if err != nil {
t.Error(err)
}
resp, err := Ping(client)
2024-11-28 14:16:37 +08:00
if err != nil {
t.Log(resp.Status)
t.Error(err)
return
}
t.Log(resp.Data, resp.Status)
}
func TestClient_StartContract(t *testing.T) {
client, err := genClient()
if err != nil {
t.Error(err)
}
resp, err := StartContract(client, "contract TestContract")
2024-11-28 14:16:37 +08:00
if err != nil {
t.Log(resp)
return
}
t.Log(resp)
}
func TestClient_ExecuteContract(t *testing.T) {
client, err := genClient()
if err != nil {
t.Error(err)
}
resp, err := ExecuteContract[any](client, "GlobalRouter", "listLRS", map[string]any{"offset": 0, "count": 12, "queryByCreateTime": "true", "filter": "prefixId"}, false, true)
2024-11-28 14:16:37 +08:00
if err != nil {
t.Log(resp)
return
}
t.Log(resp)
}
func TestClient_LoadNodeConfig(t *testing.T) {
client, err := genClient()
if err != nil {
t.Error(err)
}
config, err := LoadNodeConfig(client)
2024-11-28 14:16:37 +08:00
if err != nil {
t.Log(config)
t.Error(err)
return
}
t.Log(config)
}