contactRetry test needs to use a valid onion
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
This commit is contained in:
parent
ca63205934
commit
048effc91a
|
@ -259,6 +259,7 @@ func (cr *contactRetry) run() {
|
||||||
cr.addConnection(server, connections.DISCONNECTED, serverConn, lastSeen)
|
cr.addConnection(server, connections.DISCONNECTED, serverConn, lastSeen)
|
||||||
}
|
}
|
||||||
// this was an authorized event, and so we store this peer.
|
// this was an authorized event, and so we store this peer.
|
||||||
|
log.Debugf("authorizing id: %v", id);
|
||||||
cr.authorizedPeers.Store(id, true)
|
cr.authorizedPeers.Store(id, true)
|
||||||
if c, ok := cr.connections.Load(id); ok {
|
if c, ok := cr.connections.Load(id); ok {
|
||||||
contact := c.(*contact)
|
contact := c.(*contact)
|
||||||
|
|
|
@ -23,32 +23,37 @@ func TestContactRetryQueue(t *testing.T) {
|
||||||
cr.protocolEngine = true // fake protocol engine
|
cr.protocolEngine = true // fake protocol engine
|
||||||
go cr.run()
|
go cr.run()
|
||||||
|
|
||||||
|
testOnion := "2wgvbza2mbuc72a4u6r6k4hc2blcvrmk4q26bfvlwbqxv2yq5k52fcqd"
|
||||||
|
|
||||||
t.Logf("contact plugin up and running..sending peer connection...")
|
t.Logf("contact plugin up and running..sending peer connection...")
|
||||||
// Assert that there is a peer connection identified as "test"
|
// Assert that there is a peer connection identified as "test"
|
||||||
bus.Publish(event.NewEvent(event.QueuePeerRequest, map[event.Field]string{event.RemotePeer: "test", event.LastSeen: "test"}))
|
bus.Publish(event.NewEvent(event.QueuePeerRequest, map[event.Field]string{event.RemotePeer: testOnion, event.LastSeen: "test"}))
|
||||||
|
|
||||||
// Wait until the test actually exists, and is queued
|
// Wait until the test actually exists, and is queued
|
||||||
// This is the worst part of this test setup. Ideally we would sleep, or some other yielding, but
|
// This is the worst part of this test setup. Ideally we would sleep, or some other yielding, but
|
||||||
// go test scheduling doesn't like that and even sleeping long periods won't cause the event thread to make
|
// go test scheduling doesn't like that and even sleeping long periods won't cause the event thread to make
|
||||||
// progress...
|
// progress...
|
||||||
for {
|
for {
|
||||||
if pinf, exists := cr.connections.Load("test"); exists {
|
if pinf, exists := cr.connections.Load(testOnion); exists {
|
||||||
if pinf.(*contact).queued {
|
if pinf.(*contact).queued {
|
||||||
break
|
if _,exists := cr.authorizedPeers.Load(testOnion); exists {
|
||||||
|
t.Logf("authorized");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pinf, _ := cr.connections.Load("test")
|
pinf, _ := cr.connections.Load(testOnion)
|
||||||
if pinf.(*contact).queued == false {
|
if pinf.(*contact).queued == false {
|
||||||
t.Fatalf("test connection should be queued, actually: %v", pinf.(*contact).queued)
|
t.Fatalf("test connection should be queued, actually: %v", pinf.(*contact).queued)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asset that "test" is authenticated
|
// Asset that "test" is authenticated
|
||||||
cr.handleEvent("test", connections.AUTHENTICATED, peerConn)
|
cr.handleEvent(testOnion, connections.AUTHENTICATED, peerConn)
|
||||||
|
|
||||||
// Assert that "test has a valid state"
|
// Assert that "test has a valid state"
|
||||||
pinf, _ = cr.connections.Load("test")
|
pinf, _ = cr.connections.Load(testOnion)
|
||||||
if pinf.(*contact).state != 3 {
|
if pinf.(*contact).state != 3 {
|
||||||
t.Fatalf("test connection should be in authenticated after update, actually: %v", pinf.(*contact).state)
|
t.Fatalf("test connection should be in authenticated after update, actually: %v", pinf.(*contact).state)
|
||||||
}
|
}
|
||||||
|
@ -62,11 +67,11 @@ func TestContactRetryQueue(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Publish a new peer request...
|
// Publish a new peer request...
|
||||||
bus.Publish(event.NewEvent(event.QueuePeerRequest, map[event.Field]string{event.RemotePeer: "test"}))
|
bus.Publish(event.NewEvent(event.QueuePeerRequest, map[event.Field]string{event.RemotePeer: testOnion}))
|
||||||
time.Sleep(time.Second) // yield for a second so the event can catch up...
|
time.Sleep(time.Second) // yield for a second so the event can catch up...
|
||||||
|
|
||||||
// Peer test should be forced to queue....
|
// Peer test should be forced to queue....
|
||||||
pinf, _ = cr.connections.Load("test")
|
pinf, _ = cr.connections.Load(testOnion)
|
||||||
if pinf.(*contact).queued != true {
|
if pinf.(*contact).queued != true {
|
||||||
t.Fatalf("test connection should be forced to queue after new queue peer request")
|
t.Fatalf("test connection should be forced to queue after new queue peer request")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue