Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(309)

Delta Between Two Patch Sets: otr/otr_test.go

Issue 6446054: code review 6446054: otr: fix compilation (Closed)
Left Patch Set: Created 12 years, 8 months ago
Right Patch Set: diff -r cff3f3cc78cd https://code.google.com/p/go.crypto Created 12 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2012 The Go Authors. All rights reserved. 1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package otr 5 package otr
6 6
7 import ( 7 import (
8 "bufio" 8 "bufio"
9 "bytes" 9 "bytes"
10 "crypto/rand" 10 "crypto/rand"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 bob.PrivateKey = new(PrivateKey) 130 bob.PrivateKey = new(PrivateKey)
131 alice.PrivateKey.Parse(alicePrivateKey) 131 alice.PrivateKey.Parse(alicePrivateKey)
132 bob.PrivateKey.Parse(bobPrivateKey) 132 bob.PrivateKey.Parse(bobPrivateKey)
133 alice.FragmentSize = 100 133 alice.FragmentSize = 100
134 bob.FragmentSize = 100 134 bob.FragmentSize = 100
135 135
136 var alicesMessage, bobsMessage [][]byte 136 var alicesMessage, bobsMessage [][]byte
137 var out []byte 137 var out []byte
138 var aliceChange, bobChange SecurityChange 138 var aliceChange, bobChange SecurityChange
139 var err error 139 var err error
140 » alicesMessage = append(alicesMessage, QueryMessage) 140 » alicesMessage = append(alicesMessage, []byte(QueryMessage))
141 141
142 for round := 0; len(alicesMessage) > 0 || len(bobsMessage) > 0; round++ { 142 for round := 0; len(alicesMessage) > 0 || len(bobsMessage) > 0; round++ {
143 bobsMessage = nil 143 bobsMessage = nil
144 for i, msg := range alicesMessage { 144 for i, msg := range alicesMessage {
145 out, _, bobChange, bobsMessage, err = bob.Receive(msg) 145 out, _, bobChange, bobsMessage, err = bob.Receive(msg)
146 if len(out) > 0 { 146 if len(out) > 0 {
147 t.Errorf("Bob generated output during key exchan ge, round %d, message %d", round, i) 147 t.Errorf("Bob generated output during key exchan ge, round %d, message %d", round, i)
148 } 148 }
149 if err != nil { 149 if err != nil {
150 t.Fatalf("Bob returned an error, round %d, messa ge %d (%x): %s", round, i, msg, err) 150 t.Fatalf("Bob returned an error, round %d, messa ge %d (%x): %s", round, i, msg, err)
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 stdout, err := cmd.StdoutPipe() 304 stdout, err := cmd.StdoutPipe()
305 if err != nil { 305 if err != nil {
306 t.Fatal(err) 306 t.Fatal(err)
307 } 307 }
308 in := bufio.NewReader(stdout) 308 in := bufio.NewReader(stdout)
309 309
310 if err := cmd.Start(); err != nil { 310 if err := cmd.Start(); err != nil {
311 t.Fatal(err) 311 t.Fatal(err)
312 } 312 }
313 313
314 » out.Write(QueryMessage) 314 » out.Write([]byte(QueryMessage))
315 out.Write([]byte("\n")) 315 out.Write([]byte("\n"))
316 var expectedText = []byte("test message") 316 var expectedText = []byte("test message")
317 317
318 for { 318 for {
319 line, isPrefix, err := in.ReadLine() 319 line, isPrefix, err := in.ReadLine()
320 if isPrefix { 320 if isPrefix {
321 t.Fatal("line from subprocess too long") 321 t.Fatal("line from subprocess too long")
322 } 322 }
323 if err != nil { 323 if err != nil {
324 t.Fatal(err) 324 t.Fatal(err)
(...skipping 20 matching lines...) Expand all
345 if len(text) > 0 { 345 if len(text) > 0 {
346 if !bytes.Equal(text, expectedText) { 346 if !bytes.Equal(text, expectedText) {
347 t.Errorf("expected %x, but got %x", expectedText , text) 347 t.Errorf("expected %x, but got %x", expectedText , text)
348 } 348 }
349 if !encrypted { 349 if !encrypted {
350 t.Error("message wasn't encrypted") 350 t.Error("message wasn't encrypted")
351 } 351 }
352 } 352 }
353 } 353 }
354 } 354 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b