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://021.node.internetapi.cn:43030/SCIDE" pub, err := sm2util.ParsePublicKey("04153ad2d70e67741e0fc33e0c92c702e2afba2480dbea73d23fd02a3ce3a1b69979a7006a8e045f8836ae4797a8fe426823d7ad3450817e794948c8e47b60b711") if err != nil { return nil, err } priv, err := sm2util.ParsePrivateKey("31672b434458fdb6b854e64ededeb51305bc4d0bd258a5276ccb9bc86f7c03f6", 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", "resolveDoIdTest", "{\"doId\":\"bdtest021/ControlProxy\"}", 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) }