Merge branch 'test-channels' of dan/cwtch into master
This commit is contained in:
commit
319c724c05
|
@ -150,5 +150,7 @@ func (ppc *PeerPeerConnection) Run() error {
|
||||||
// Close closes the connection
|
// Close closes the connection
|
||||||
func (ppc *PeerPeerConnection) Close() {
|
func (ppc *PeerPeerConnection) Close() {
|
||||||
ppc.state = KILLED
|
ppc.state = KILLED
|
||||||
|
if ppc.connection != nil {
|
||||||
ppc.connection.Conn.Close()
|
ppc.connection.Conn.Close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,9 @@ func PeerAuthValid(hostname string, key ed25519.PublicKey) (allowed, known bool)
|
||||||
return true, true
|
return true, true
|
||||||
}
|
}
|
||||||
|
|
||||||
func runtestpeer(t *testing.T, tp *TestPeer, identity identity.Identity) {
|
func runtestpeer(t *testing.T, tp *TestPeer, identity identity.Identity, listenChan chan bool) {
|
||||||
ln, _ := net.Listen("tcp", "127.0.0.1:5452")
|
ln, _ := net.Listen("tcp", "127.0.0.1:5452")
|
||||||
|
listenChan <- true
|
||||||
conn, _ := ln.Accept()
|
conn, _ := ln.Accept()
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
|
@ -65,7 +66,9 @@ func TestPeerPeerConnection(t *testing.T) {
|
||||||
|
|
||||||
tp := new(TestPeer)
|
tp := new(TestPeer)
|
||||||
tp.Init()
|
tp.Init()
|
||||||
go runtestpeer(t, tp, identity)
|
listenChan := make(chan bool)
|
||||||
|
go runtestpeer(t, tp, identity, listenChan)
|
||||||
|
<-listenChan
|
||||||
state := ppc.GetState()
|
state := ppc.GetState()
|
||||||
if state != DISCONNECTED {
|
if state != DISCONNECTED {
|
||||||
fmt.Println("ERROR state should be disconnected")
|
fmt.Println("ERROR state should be disconnected")
|
||||||
|
|
|
@ -33,8 +33,9 @@ func (ts *TestServer) HandleFetchRequest() []*protocol.GroupMessage {
|
||||||
return []*protocol.GroupMessage{{Ciphertext: []byte("hello"), Signature: []byte{}, Spamguard: []byte{}}, {Ciphertext: []byte("hello"), Signature: []byte{}, Spamguard: []byte{}}}
|
return []*protocol.GroupMessage{{Ciphertext: []byte("hello"), Signature: []byte{}, Spamguard: []byte{}}, {Ciphertext: []byte("hello"), Signature: []byte{}, Spamguard: []byte{}}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func runtestserver(t *testing.T, ts *TestServer, identity identity.Identity) {
|
func runtestserver(t *testing.T, ts *TestServer, identity identity.Identity, listenChan chan bool) {
|
||||||
ln, _ := net.Listen("tcp", "127.0.0.1:5451")
|
ln, _ := net.Listen("tcp", "127.0.0.1:5451")
|
||||||
|
listenChan <- true
|
||||||
conn, _ := ln.Accept()
|
conn, _ := ln.Accept()
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
|
@ -70,7 +71,9 @@ func TestPeerServerConnection(t *testing.T) {
|
||||||
|
|
||||||
ts := new(TestServer)
|
ts := new(TestServer)
|
||||||
ts.Init()
|
ts.Init()
|
||||||
go runtestserver(t, ts, identity)
|
listenChan := make(chan bool)
|
||||||
|
go runtestserver(t, ts, identity, listenChan)
|
||||||
|
<-listenChan
|
||||||
onionAddr := identity.Hostname()
|
onionAddr := identity.Hostname()
|
||||||
|
|
||||||
psc := NewPeerServerConnection(connectivity.LocalProvider(), "127.0.0.1:5451|"+onionAddr)
|
psc := NewPeerServerConnection(connectivity.LocalProvider(), "127.0.0.1:5451|"+onionAddr)
|
||||||
|
|
|
@ -23,8 +23,10 @@ func TestTrustPeer(t *testing.T) {
|
||||||
groupName := "2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd"
|
groupName := "2c3kmoobnyghj2zw6pwv7d57yzld753auo3ugauezzpvfak3ahc4bdyd"
|
||||||
alice := NewCwtchPeer("alice")
|
alice := NewCwtchPeer("alice")
|
||||||
alice.Init(connectivity.LocalProvider())
|
alice.Init(connectivity.LocalProvider())
|
||||||
|
defer alice.Shutdown()
|
||||||
bob := NewCwtchPeer("bob")
|
bob := NewCwtchPeer("bob")
|
||||||
bob.Init(connectivity.LocalProvider())
|
bob.Init(connectivity.LocalProvider())
|
||||||
|
defer bob.Shutdown()
|
||||||
|
|
||||||
bobOnion := bob.GetProfile().Onion
|
bobOnion := bob.GetProfile().Onion
|
||||||
aliceOnion := alice.GetProfile().Onion
|
aliceOnion := alice.GetProfile().Onion
|
||||||
|
|
Loading…
Reference in New Issue