package lmaxapi import ( "log" "testing" "time" ) func TestEchoMtf(t *testing.T) { mtf := NewMtf() go mtf.Start() client := NewMtfClient(mtf, time.Second, false, 1024) go client.Recv(nil) client.ConnectPrivate() msg := client.SendMessage(MsgEcho, "echo") if msg.Err != nil { panic(msg.Err) return } if msg.Data.(string) != "echo" { t.Errorf("mtf echo error") return } err := client.Close() if err != nil { t.Error(err) return } mtf.Close() } func BenchmarkEchoMtf(b *testing.B) { mtf := NewMtf() go mtf.Start() client := NewMtfClient(mtf, time.Millisecond*100, false, 1024) go client.Recv(nil) err := client.ConnectPrivate() if err != nil { panic(err) } log.Println("ready") for i := 0; i < b.N; i++ { msg := client.SendMessage(MsgEcho, "echo") if msg.Err != nil { panic(msg.Err) return } } err = client.Close() if err != nil { b.Error(err) return } mtf.Close() }