From df1976d5a445d2d578fabb7266b68bfb5386e893 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Thu, 3 May 2018 13:03:37 -0700 Subject: [PATCH] test verify --- .../cwtch_peer_server_intergration_test.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/testing/cwtch_peer_server_intergration_test.go b/testing/cwtch_peer_server_intergration_test.go index 61380d8..e2e4193 100644 --- a/testing/cwtch_peer_server_intergration_test.go +++ b/testing/cwtch_peer_server_intergration_test.go @@ -15,7 +15,7 @@ import ( ) const ( - server = "kwke2hntvyfqm7dr"//"ylhbhtypevo4ympq" + //server = "kwke2hntvyfqm7dr"//"ylhbhtypevo4ympq" keyfile = "./private_key" ) @@ -25,16 +25,21 @@ var ( ) -func printTimeline(timeline model.Timeline) { +func printAndVerifyTimeline(t *testing.T, timeline model.Timeline) error { for _, message := range timeline.Messages { fmt.Printf("%v %v> %s [%t]\n", message.Timestamp, message.PeerID, message.Message, message.Verified) + if !message.Verified { + t.Errorf("Message '%s' from '%s' not verified!", message.Message, message.PeerID) + } } + return nil } func TestCwtchPeerIntegration(t *testing.T) { // Hide logging "noise" log.SetOutput(ioutil.Discard) + // TODO: only launch server if not running // launch app server := new(cwtchserver.Server) fmt.Println("starting cwtch server...") @@ -42,7 +47,7 @@ func TestCwtchPeerIntegration(t *testing.T) { server_key, err := utils.LoadPrivateKeyFromFile(keyfile) if err != nil { - log.Fatal("Could not load server's key from %v", keyfile) + t.Error("Could not load server's key from %v", keyfile) } server_addr, _ := utils.GetOnionAddress(server_key) @@ -66,9 +71,9 @@ func TestCwtchPeerIntegration(t *testing.T) { fmt.Println("Bob joining group...") bob.JoinServer(server_addr) - // Associate and peer alice & bob + // Associate peer alice & bob as peers alice.Profile.AddContact(bob.Profile.Onion, bob.Profile.PublicProfile) - bob.Profile.AddContact(alice.Profile.Onion, alice.Profile.PublicProfile) + //bob.Profile.AddContact(alice.Profile.Onion, alice.Profile.PublicProfile) fmt.Println("Alice> ", aliceLines[0]) alice.SendMessageToGroup(groupId, aliceLines[0]) @@ -98,11 +103,11 @@ func TestCwtchPeerIntegration(t *testing.T) { alicesGroup := alice.Profile.Groups[groupId] fmt.Printf("Alice TimeLine:\n") - printTimeline(alicesGroup.Timeline) + printAndVerifyTimeline(t, alicesGroup.Timeline) bobsGroup := bob.Profile.Groups[groupId] fmt.Printf("Bob TimeLine:\n") - printTimeline(bobsGroup.Timeline) + printAndVerifyTimeline(t, bobsGroup.Timeline) // Todo: shutdown users and server }