package client import ( "testing" "go.fusiongalaxy.cn/bdware/bdcontract-client/sm2util" ) 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://127.0.0.1:21030/SCIDE" pub, err := sm2util.ParsePublicKey("04180354fdb6507f8ab98ccfbe165ce11da74ba733f81af86ad6d32216b32cf4f797c559d50ceeefbf4c760c3483840471c67471b90acdffb388cd7d496d9a1610") if err != nil { return nil, err } priv, err := sm2util.ParsePrivateKey("1d4196947f59532db6f8f4055e58474a48db8f30b476ae3edc66406464521b3b", pub) if err != nil { return nil, err } 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 := client.Ping() 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 := client.StartContract("contract TestContract") 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 := client.ExecuteContract("GlobalRouter", "listID", map[string]any{"offset": 0, "count": 12, "queryByCreateTime": "true", "filter": "prefixId"}, false, true) 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 := client.LoadNodeConfig() if err != nil { t.Log(config) t.Error(err) return } t.Log(config) }