// Copyright 2013-2014 Fuzamei tech Ltd. All rights reserved. package market // 本文件测试server的rpc接口 import ( "github.com/wangch/rpc" "log" "testing" "time" ) var ( server *Server subCode = time.Now().UnixNano() ) func newServer(t *testing.T) { // newDB() if server != nil { return } conf := DefaultServerConf conf.DsMap[Lmax].Run = false s := NewServer(nil, conf.DataDir, "") server = s go s.ListenAndServe(":19526", ":19527") } func TestSubMarket(t *testing.T) { newServer(t) client, err := rpc.Dial("tcp", "localhost:19526") if err != nil { t.Fatal(err) } log.Println("@@@@@@@: connected server OK!") f := func(v interface{}, err error) error { if err != nil { t.Error(err) return err } mk, ok := v.(*Market) if !ok { t.Error("market.Client.subMarket error: v.(*Market) is NOT ok") return err } log.Println("@@@@@@@:", mk) return nil } args := SubArgs{"4001", subCode, false} var reply Market err = client.Sub("Server.SubMarket", args, &reply, f) if err != nil { t.Error(err) } time.Sleep(time.Minute) } func TestUnsubMarket(t *testing.T) { } func TestGetHistory(t *testing.T) { } func TestGetLastTicks(t *testing.T) { } func TestGetLastCandles(t *testing.T) { }