package tests import ( "encoding/xml" "lux/rpc" "testing" ) func TestRequestDecoding(t *testing.T) { var request rpc.LuxRpcRequest err := xml.Unmarshal([]byte(``), &request) if err != nil { t.Fatal(err) } t.Log(request) err = xml.Unmarshal([]byte(``), &request) if err != nil { t.Fatal(err) } t.Log(request) err = xml.Unmarshal([]byte(` `), &request) if err != nil { t.Fatal(err) } t.Log(request) err = xml.Unmarshal([]byte(` `), &request) if err != nil { t.Fatal(err) } t.Log(request) } func TestResponseEncoding(t *testing.T) { xmlBytes, err := xml.Marshal(rpc.LuxRpcResponse{ RequestID: 1, KeyStoreBlob: "*base64 keystore*", }) if err != nil { t.Fatal(err) } t.Log(string(xmlBytes)) xmlBytes, err = xml.Marshal(rpc.LuxRpcResponse{ RequestID: 2, Routes: []rpc.LuxRpcRoute{ {Type: 1, Target: "1111", Source: "0001", Destination: "127.0.0.1:1234"}, {Type: 2, Target: "1112", Source: "0001", Destination: "127.0.0.1:4321"}, }, }) if err != nil { t.Fatal(err) } t.Log(string(xmlBytes)) xmlBytes, err = xml.Marshal(rpc.LuxRpcResponse{ RequestID: 3, Hosts: []rpc.LuxRpcHost{ {HostID: "0001", Hostname: "test-host1"}, {HostID: "0002", Hostname: "test-host2"}, }, }) if err != nil { t.Fatal(err) } t.Log(string(xmlBytes)) }