Review1
This commit is contained in:
@ -12,7 +12,7 @@ func TestEndToEnd(t *testing.T) {
|
||||
// Create my own identity
|
||||
//
|
||||
fmt.Println("Trying to load identity from file.")
|
||||
me, err := LoadIdentity("test.id")
|
||||
me, err := LoadIdentity("id.enc")
|
||||
if err != nil {
|
||||
fmt.Println("Failed : creating New identity...")
|
||||
me = CreateIdentity("myname")
|
||||
@ -36,6 +36,8 @@ func TestEndToEnd(t *testing.T) {
|
||||
// Simulate peer invitation response : generate the friend's keypair
|
||||
fmt.Println("Simulating first friend answer...")
|
||||
var receivedContact ContactCard
|
||||
|
||||
// Friend simulated invitation
|
||||
firstFriendContactKp := NewKeyPair()
|
||||
firstFriendEncryptionKp := NewKeyPair()
|
||||
firstFriendLookupKp := NewKeyPair()
|
||||
@ -45,9 +47,12 @@ func TestEndToEnd(t *testing.T) {
|
||||
receivedContact.LookupPublicKey = firstFriendLookupKp.Public
|
||||
var friendsMessageServers ServerList
|
||||
friendsMessageServers.AddUrls([]string{"http://myfriend.org/meow/"})
|
||||
// end Friend simulated invitation
|
||||
|
||||
for _, srv := range friendsMessageServers.Servers {
|
||||
receivedContact.PullServers = append(receivedContact.PullServers, srv.ServerData)
|
||||
}
|
||||
|
||||
// End simulating contact invitation response
|
||||
//
|
||||
|
||||
@ -55,7 +60,7 @@ func TestEndToEnd(t *testing.T) {
|
||||
// Finalize the contact with the invitation response
|
||||
//
|
||||
me.FinalizeInvitation(myFirstFriend, &receivedContact)
|
||||
err = me.Save("test.id")
|
||||
err = me.Save("id.enc")
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
@ -63,10 +68,27 @@ func TestEndToEnd(t *testing.T) {
|
||||
a, _ = json.Marshal(me)
|
||||
ioutil.WriteFile("id.json", a, 0644)
|
||||
fmt.Println(string(a))
|
||||
}
|
||||
// go me.CheckMessages()
|
||||
|
||||
//myFirstFriend.SetComMethod()
|
||||
//msg := myFirstFriend.SendText()
|
||||
// create message to simulated friend
|
||||
sentmessage := "Hello friend!"
|
||||
lookupK, EncMsg, MsgSignature, Servers, err := myFirstFriend.CreateMessage([]byte(sentmessage))
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
fmt.Println(lookupK)
|
||||
fmt.Println(len(Servers))
|
||||
// simulated friend decoding the message
|
||||
//ReadMessage
|
||||
|
||||
// simulates if peer can decrypt my message
|
||||
//Message := "toto"
|
||||
//Signature := "test"
|
||||
decMess, err2 := DecryptAndCheck(myFirstFriend.EncryptionKp.Private, myFirstFriend.Contact.EncryptionPublicKey, []byte(EncMsg), MsgSignature)
|
||||
if err2 != nil {
|
||||
fmt.Println(err2.Error())
|
||||
}
|
||||
fmt.Println(decMess)
|
||||
//
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user