@@ -19,6 +19,7 @@ package ethtest
19
19
import (
20
20
"fmt"
21
21
"net"
22
+ "strings"
22
23
"time"
23
24
24
25
"github.com/davecgh/go-spew/spew"
@@ -84,6 +85,8 @@ func (s *Suite) AllEthTests() []utesting.Test {
84
85
{Name : "Broadcast_66" , Fn : s .TestBroadcast_66 },
85
86
{Name : "TestLargeAnnounce" , Fn : s .TestLargeAnnounce },
86
87
{Name : "TestLargeAnnounce_66" , Fn : s .TestLargeAnnounce_66 },
88
+ {Name : "TestOldAnnounce" , Fn : s .TestOldAnnounce },
89
+ {Name : "TestOldAnnounce_66" , Fn : s .TestOldAnnounce_66 },
87
90
// malicious handshakes + status
88
91
{Name : "TestMaliciousHandshake" , Fn : s .TestMaliciousHandshake },
89
92
{Name : "TestMaliciousStatus" , Fn : s .TestMaliciousStatus },
@@ -389,6 +392,36 @@ func (s *Suite) TestLargeAnnounce(t *utesting.T) {
389
392
}
390
393
}
391
394
395
+ func (s * Suite ) TestOldAnnounce (t * utesting.T ) {
396
+ s .oldAnnounce (t , s .setupConnection (t ), s .setupConnection (t ))
397
+ }
398
+
399
+ func (s * Suite ) oldAnnounce (t * utesting.T , sendConn , receiveConn * Conn ) {
400
+ oldBlockAnnounce := & NewBlock {
401
+ Block : s .chain .blocks [len (s .chain .blocks )/ 2 ],
402
+ TD : s .chain .blocks [len (s .chain .blocks )/ 2 ].Difficulty (),
403
+ }
404
+
405
+ if err := sendConn .Write (oldBlockAnnounce ); err != nil {
406
+ t .Fatalf ("could not write to connection: %v" , err )
407
+ }
408
+
409
+ switch msg := receiveConn .ReadAndServe (s .chain , timeout * 2 ).(type ) {
410
+ case * NewBlock :
411
+ t .Fatalf ("unexpected: block propagated: %s" , pretty .Sdump (msg ))
412
+ case * NewBlockHashes :
413
+ t .Fatalf ("unexpected: block announced: %s" , pretty .Sdump (msg ))
414
+ case * Error :
415
+ errMsg := * msg
416
+ // check to make sure error is timeout (propagation didn't come through == test successful)
417
+ if ! strings .Contains (errMsg .String (), "timeout" ) {
418
+ t .Fatalf ("unexpected error: %v" , pretty .Sdump (msg ))
419
+ }
420
+ default :
421
+ t .Fatalf ("unexpected: %s" , pretty .Sdump (msg ))
422
+ }
423
+ }
424
+
392
425
func (s * Suite ) testAnnounce (t * utesting.T , sendConn , receiveConn * Conn , blockAnnouncement * NewBlock ) {
393
426
// Announce the block.
394
427
if err := sendConn .Write (blockAnnouncement ); err != nil {
0 commit comments