|
|
|
@ -110,8 +110,9 @@ func TestCwtchPeerIntegration(t *testing.T) {
|
|
|
|
|
numGoRoutinesStart := runtime.NumGoroutine()
|
|
|
|
|
|
|
|
|
|
// ***** Cwtch Server managment *****
|
|
|
|
|
var server *cwtchserver.Server = nil
|
|
|
|
|
var server *cwtchserver.Server
|
|
|
|
|
serverKey := loadPrivateKey(t)
|
|
|
|
|
|
|
|
|
|
serverOnline := false
|
|
|
|
|
var serverAddr string
|
|
|
|
|
|
|
|
|
@ -162,8 +163,8 @@ func TestCwtchPeerIntegration(t *testing.T) {
|
|
|
|
|
// ***** Peering, server joining, group creation / invite *****
|
|
|
|
|
|
|
|
|
|
fmt.Println("Creating group on ", serverAddr, "...")
|
|
|
|
|
groupId, _, err := alice.Profile.StartGroup(serverAddr)
|
|
|
|
|
fmt.Printf("Created group: %v!\n", groupId)
|
|
|
|
|
groupID, _, err := alice.Profile.StartGroup(serverAddr)
|
|
|
|
|
fmt.Printf("Created group: %v!\n", groupID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Errorf("Failed to init group: %v", err)
|
|
|
|
|
return
|
|
|
|
@ -183,7 +184,7 @@ func TestCwtchPeerIntegration(t *testing.T) {
|
|
|
|
|
time.Sleep(time.Second * 60)
|
|
|
|
|
|
|
|
|
|
fmt.Println("Alice inviting Bob to group...")
|
|
|
|
|
err = alice.InviteOnionToGroup(bob.Profile.Onion, groupId)
|
|
|
|
|
err = alice.InviteOnionToGroup(bob.Profile.Onion, groupID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("Error for Alice inviting Bob to group: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -238,29 +239,29 @@ func TestCwtchPeerIntegration(t *testing.T) {
|
|
|
|
|
fmt.Println("Starting conversation in group...")
|
|
|
|
|
// Conversation
|
|
|
|
|
fmt.Println("Alice> ", aliceLines[0])
|
|
|
|
|
err = alice.SendMessageToGroup(groupId, aliceLines[0])
|
|
|
|
|
err = alice.SendMessageToGroup(groupID, aliceLines[0])
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("Alice failed to send a message to the group: %v", err)
|
|
|
|
|
}
|
|
|
|
|
time.Sleep(time.Second * 10)
|
|
|
|
|
|
|
|
|
|
fmt.Println("Bob> ", bobLines[0])
|
|
|
|
|
err = bob.SendMessageToGroup(groupId, bobLines[0])
|
|
|
|
|
err = bob.SendMessageToGroup(groupID, bobLines[0])
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("Bob failed to send a message to the group: %v", err)
|
|
|
|
|
}
|
|
|
|
|
time.Sleep(time.Second * 10)
|
|
|
|
|
|
|
|
|
|
fmt.Println("Alice> ", aliceLines[1])
|
|
|
|
|
alice.SendMessageToGroup(groupId, aliceLines[1])
|
|
|
|
|
alice.SendMessageToGroup(groupID, aliceLines[1])
|
|
|
|
|
time.Sleep(time.Second * 10)
|
|
|
|
|
|
|
|
|
|
fmt.Println("Bob> ", bobLines[1])
|
|
|
|
|
bob.SendMessageToGroup(groupId, bobLines[1])
|
|
|
|
|
bob.SendMessageToGroup(groupID, bobLines[1])
|
|
|
|
|
time.Sleep(time.Second * 10)
|
|
|
|
|
|
|
|
|
|
fmt.Println("Alice inviting Carol to group...")
|
|
|
|
|
err = alice.InviteOnionToGroup(carol.Profile.Onion, groupId)
|
|
|
|
|
err = alice.InviteOnionToGroup(carol.Profile.Onion, groupID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("Error for Alice inviting Carol to group: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -285,11 +286,11 @@ func TestCwtchPeerIntegration(t *testing.T) {
|
|
|
|
|
numGoRotinesPostCarolConnect := runtime.NumGoroutine()
|
|
|
|
|
|
|
|
|
|
fmt.Println("Bob> ", bobLines[2])
|
|
|
|
|
bob.SendMessageToGroup(groupId, bobLines[2])
|
|
|
|
|
bob.SendMessageToGroup(groupID, bobLines[2])
|
|
|
|
|
time.Sleep(time.Second * 10)
|
|
|
|
|
|
|
|
|
|
fmt.Println("Carol> ", carolLines[0])
|
|
|
|
|
carol.SendMessageToGroup(groupId, carolLines[0])
|
|
|
|
|
carol.SendMessageToGroup(groupID, carolLines[0])
|
|
|
|
|
time.Sleep(time.Second * 10)
|
|
|
|
|
|
|
|
|
|
// ***** Verify Test *****
|
|
|
|
@ -297,7 +298,7 @@ func TestCwtchPeerIntegration(t *testing.T) {
|
|
|
|
|
// final syncing time...
|
|
|
|
|
time.Sleep(time.Second * 15)
|
|
|
|
|
|
|
|
|
|
alicesGroup := alice.Profile.GetGroupByGroupID(groupId)
|
|
|
|
|
alicesGroup := alice.Profile.GetGroupByGroupID(groupID)
|
|
|
|
|
if alicesGroup == nil {
|
|
|
|
|
t.Error("aliceGroup == nil")
|
|
|
|
|
return
|
|
|
|
@ -309,7 +310,7 @@ func TestCwtchPeerIntegration(t *testing.T) {
|
|
|
|
|
t.Errorf("Alice did not have 4 verified messages")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bobsGroup := bob.Profile.GetGroupByGroupID(groupId)
|
|
|
|
|
bobsGroup := bob.Profile.GetGroupByGroupID(groupID)
|
|
|
|
|
if bobsGroup == nil {
|
|
|
|
|
t.Error("bobGroup == nil")
|
|
|
|
|
return
|
|
|
|
@ -320,7 +321,7 @@ func TestCwtchPeerIntegration(t *testing.T) {
|
|
|
|
|
t.Errorf("Bob did not have 5 verified messages")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
carolsGroup := carol.Profile.GetGroupByGroupID(groupId)
|
|
|
|
|
carolsGroup := carol.Profile.GetGroupByGroupID(groupID)
|
|
|
|
|
fmt.Printf("Carol's TimeLine:\n")
|
|
|
|
|
carolVerified := printAndCountVerifedTimeline(t, carolsGroup.GetTimeline())
|
|
|
|
|
if carolVerified != 3 {
|
|
|
|
|