generated from KyberNetwork/go-project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from KyberNetwork/update_ws
update disconnect flow
- Loading branch information
Showing
5 changed files
with
57 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package server | ||
|
||
import ( | ||
"encoding/json" | ||
"log" | ||
"testing" | ||
"time" | ||
|
||
"github.com/KyberNetwork/tradelogs/pkg/storage" | ||
"github.com/gorilla/websocket" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
const ( | ||
url1 = "wss://tradelogs.kyberengineering.io/eventlogws?maker=0x807cF9A772d5a3f9CeFBc1192e939D62f0D9bD38&event_hash=0xac75f773e3a92f1a02b12134d65e1f47f8a14eabe4eaf1e24624918e6a8b269f" | ||
url2 = "ws://localhost:8080/eventlogws?maker=0x807cF9A772d5a3f9CeFBc1192e939D62f0D9bD38&event_hash=0xac75f773e3a92f1a02b12134d65e1f47f8a14eabe4eaf1e24624918e6a8b269f" | ||
) | ||
|
||
func TestWSClient(t *testing.T) { | ||
t.Skip() | ||
for { | ||
conn, _, err := websocket.DefaultDialer.Dial(url2, nil) | ||
if err != nil { | ||
log.Fatal("dial:", err) | ||
} | ||
for range time.NewTicker(time.Second).C { | ||
if _, data, err := conn.ReadMessage(); err == nil { | ||
var l storage.TradeLog | ||
err := json.Unmarshal(data, &l) | ||
require.NoError(t, err) | ||
log.Println("receive:", l) | ||
} else { | ||
conn.Close() | ||
break | ||
} | ||
} | ||
} | ||
} |