// basic send/receive testing
basic send/receive testing
// basic send / receive testing
func TestCall(t *testing.T) {
	serverName := "cleartext server name"
	server := bilateralrpc.NewPlaintext(networkName, serverName)
	defer server.Close()
	serverAddress := "tcp://127.0.0.1:9979"
	if err := server.ListenOn(serverAddress); nil != err {
		t.Fatalf("ConnectTo: err = %v", err)
	}
	arith := new(Arith)
	server.Register(arith)
	clientName := "a unique client name"
	client := bilateralrpc.NewPlaintext(networkName, clientName)
	defer client.Close()
	client.Register(arith)
	if err := client.ConnectTo(serverName, serverAddress); nil != err {
		t.Fatalf("ConnectTo: err = %v", err)
	}
	waitConnect(t, client, 1)
	args := Args{
		A: 186,
		B: 253,
	}
	var results []Result
	if err := client.Call(nil, "Arith.SumDiffV", &args, &results, 5*time.Second); nil != err {
		t.Fatalf("Call: err = %v", err)
	}
	checkResults(t, args, results, []string{serverName})
	if err := server.Call(nil, "Arith.SumDiffV", args, &results, 5*time.Second); nil != err {
		t.Fatalf("reverse Call: err = %v", err)
	}
	checkResults(t, args, results, []string{clientName})
	if err := client.Call(nil, "Arith.SumDiffP", &args, &results, 5*time.Second); nil != err {
		t.Fatalf("Call: err = %v", err)
	}
	checkResults(t, args, results, []string{serverName})
	if err := server.Call(nil, "Arith.SumDiffP", args, &results, 5*time.Second); nil != err {
		t.Fatalf("reverse Call: err = %v", err)
	}
	checkResults(t, args, results, []string{clientName})
}
func TestCall ( t * testing . T ) { serverName := " " server := bilateralrpc . NewPlaintext ( networkName , serverName ) defer server . Close ( ) serverAddress := " " if err := server . ListenOn ( serverAddress ) ; nil != err { t . Fatalf ( " " , err ) } arith := new ( Arith ) server . Register ( arith ) clientName := " " client := bilateralrpc . NewPlaintext ( networkName , clientName ) defer client . Close ( ) client . Register ( arith ) if err := client . ConnectTo ( serverName , serverAddress ) ; nil != err { t . Fatalf ( " " , err ) } waitConnect ( t , client , 1 ) args := Args { A : 186 , B : 253 , } var results [ ] Result if err := client . Call ( nil , " " , & args , & results , 5 * time . Second ) ; nil != err { t . Fatalf ( " " , err ) } checkResults ( t , args , results , [ ] string { serverName } ) if err := server . Call ( nil , " " , args , & results , 5 * time . Second ) ; nil != err { t . Fatalf ( " " , err ) } checkResults ( t , args , results , [ ] string { clientName } ) if err := client . Call ( nil , " " , & args , & results , 5 * time . Second ) ; nil != err { t . Fatalf ( " " , err ) } checkResults ( t , args , results , [ ] string { serverName } ) if err := server . Call ( nil , " " , args , & results , 5 * time . Second ) ; nil != err { t . Fatalf ( " " , err ) } checkResults ( t , args , results , [ ] string { clientName } ) }
basic send/receive testing
basic send / receive testing
// create a server // use a specific IP:Port so client can use this - (for testing with tcp) //serverAddress := "inproc://test_bilateral_calling" // listen on a port // register server objects // create a client // allow time to connect - since handshake must occur in the background // some data to send // this will receive slice of results // SumDiffV // -------- // nil string slice will result in calls to all active connections // NOTE: args is pointer, receiver is value // nil string slice will result in calls to all active connections // NOTE: args is value, receiver is value // SumDiffP // -------- // nil string slice will result in calls to all active connections // NOTE: args is pointer, receiver is pointer // nil string slice will result in calls to all active connections // NOTE: args is value, receiver is pointer