sproto_test.go 954 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package sproto_Protocol
  2. import (
  3. "fmt"
  4. cherryHttp "github.com/cherry-game/cherry/extend/http"
  5. sproto "github.com/xjdrew/gosproto"
  6. "testing"
  7. )
  8. func TestSProto(t *testing.T) {
  9. languageID := int64(1)
  10. systemMsg := &SystemMsg{
  11. LanguageId: &languageID,
  12. Args: []string{"aaa", "bbb", "ccc"},
  13. }
  14. bytes, err := sproto.Encode(systemMsg)
  15. fmt.Println(err)
  16. fmt.Println(bytes)
  17. systemMsg1 := &SystemMsg{}
  18. sproto.Decode(bytes, systemMsg1)
  19. fmt.Println(systemMsg1)
  20. }
  21. func TestROK(t *testing.T) {
  22. url := "http://192.168.200.129:58005/recharge"
  23. str := &struct {
  24. RID int64 `json:"rid"`
  25. SN int64 `json:"sn"`
  26. IGGID string `json:"iggid"`
  27. PCID int64 `json:"pc_id"`
  28. index int64 `json:"index"`
  29. }{
  30. RID: 10000003,
  31. SN: 1,
  32. IGGID: "ID1976875",
  33. PCID: 24613, //24599, //
  34. index: 1,
  35. }
  36. for i := 0; i < 1000; i++ {
  37. bytes, rsp, err := cherryHttp.PostJSON(url, str)
  38. fmt.Println(string(bytes), rsp.StatusCode, err)
  39. }
  40. }