forked from cwtch.im/cwtch
1
0
Fork 0

Fixing up ContactRetry and Integ Tests

This commit is contained in:
Sarah Jamie Lewis 2020-09-28 10:40:41 -07:00
parent 2d9050346b
commit 1e34eb67a7
2 changed files with 5 additions and 8 deletions

View File

@ -3,7 +3,6 @@ package plugins
import ( import (
"cwtch.im/cwtch/event" "cwtch.im/cwtch/event"
"cwtch.im/cwtch/protocol/connections" "cwtch.im/cwtch/protocol/connections"
"git.openprivacy.ca/openprivacy/log"
"sync" "sync"
"time" "time"
) )
@ -57,13 +56,11 @@ func (cr *contactRetry) run() {
case e := <-cr.queue.OutChan(): case e := <-cr.queue.OutChan():
switch e.EventType { switch e.EventType {
case event.PeerStateChange: case event.PeerStateChange:
log.Errorf("PEER STATE CHANGE: %v", e)
state := connections.ConnectionStateToType[e.Data[event.ConnectionState]] state := connections.ConnectionStateToType[e.Data[event.ConnectionState]]
peer := e.Data[event.RemotePeer] peer := e.Data[event.RemotePeer]
cr.handleEvent(peer, state, peerConn) cr.handleEvent(peer, state, peerConn)
case event.ServerStateChange: case event.ServerStateChange:
log.Errorf("SERVER STATE CHANGE: %v", e)
state := connections.ConnectionStateToType[e.Data[event.ConnectionState]] state := connections.ConnectionStateToType[e.Data[event.ConnectionState]]
server := e.Data[event.GroupServer] server := e.Data[event.GroupServer]
cr.handleEvent(server, state, serverConn) cr.handleEvent(server, state, serverConn)
@ -97,8 +94,6 @@ func (cr *contactRetry) run() {
if cr.networkUp { if cr.networkUp {
if p.ctype == peerConn { if p.ctype == peerConn {
cr.bus.Publish(event.NewEvent(event.RetryPeerRequest, map[event.Field]string{event.RemotePeer: p.id})) cr.bus.Publish(event.NewEvent(event.RetryPeerRequest, map[event.Field]string{event.RemotePeer: p.id}))
} else {
//cr.bus.Publish(event.NewEventList(event.JoinServer, event.GroupServer, p.id))
} }
} }
} }

View File

@ -348,16 +348,18 @@ func TestCwtchPeerIntegration(t *testing.T) {
fmt.Printf("%v> %v", bobName, bobLines[2]) fmt.Printf("%v> %v", bobName, bobLines[2])
bob.SendMessageToGroup(groupID, bobLines[2]) bob.SendMessageToGroup(groupID, bobLines[2])
time.Sleep(time.Second * 60) // we need to account for spam-based token acquisition // Bob should have enough tokens so we don't need to account for
// token acquisition here...
fmt.Printf("%v> %v", carolName, carolLines[0]) fmt.Printf("%v> %v", carolName, carolLines[0])
carol.SendMessageToGroup(groupID, carolLines[0]) carol.SendMessageToGroup(groupID, carolLines[0])
time.Sleep(time.Second * 60) // we need to account for spam-based token acquisition time.Sleep(time.Second * 30) // we need to account for spam-based token acquisition, but everything should
// be warmed-up and delays should be pretty small.
// ***** Verify Test ***** // ***** Verify Test *****
fmt.Println("Final syncing time...") fmt.Println("Final syncing time...")
time.Sleep(time.Second * 60) time.Sleep(time.Second * 30)
alicesGroup := alice.GetGroup(groupID) alicesGroup := alice.GetGroup(groupID)
if alicesGroup == nil { if alicesGroup == nil {