@@ -104,7 +104,7 @@ func TestPubsubPublishResolve(t *testing.T) {
104
104
105
105
name := "/ipns/" + pubhost .ID ().Pretty ()
106
106
107
- reshosts := newNetHosts (ctx , t , 20 )
107
+ reshosts := newNetHosts (ctx , t , 5 )
108
108
resmrs := newMockRoutingForHosts (ms , ks , reshosts )
109
109
res := make ([]Resolver , len (reshosts ))
110
110
for i := 0 ; i < len (res ); i ++ {
@@ -113,22 +113,24 @@ func TestPubsubPublishResolve(t *testing.T) {
113
113
114
114
time .Sleep (time .Millisecond * 100 )
115
115
for i := 0 ; i < len (res ); i ++ {
116
- checkResolveNotFound (ctx , t , res [i ], name )
116
+ checkResolveNotFound (ctx , t , i , res [i ], name )
117
+ // delay to avoid connection storms
117
118
time .Sleep (time .Millisecond * 100 )
118
119
}
119
120
120
121
// let the bootstrap finish
121
- time .Sleep (time .Second * 3 )
122
+ time .Sleep (time .Second * 1 )
122
123
123
124
val := path .Path ("/ipfs/QmP1DfoUjiWH2ZBo1PBH6FupdBucbDepx3HpWmEY6JMUpY" )
124
125
err := pub .Publish (ctx , privk , val )
125
126
if err != nil {
126
127
t .Fatal (err )
127
128
}
128
129
130
+ // let the flood propagate
129
131
time .Sleep (time .Second * 3 )
130
132
for i := 0 ; i < len (res ); i ++ {
131
- checkResolve (ctx , t , res [i ], name , val )
133
+ checkResolve (ctx , t , i , res [i ], name , val )
132
134
}
133
135
134
136
val = path .Path ("/ipfs/QmP1wMAqk6aZYRZirbaAwmrNeqFRgQrwBt3orUtvSa1UYD" )
@@ -137,25 +139,26 @@ func TestPubsubPublishResolve(t *testing.T) {
137
139
t .Fatal (err )
138
140
}
139
141
142
+ // let the flood propagate
140
143
time .Sleep (time .Second * 3 )
141
144
for i := 0 ; i < len (res ); i ++ {
142
- checkResolve (ctx , t , res [i ], name , val )
145
+ checkResolve (ctx , t , i , res [i ], name , val )
143
146
}
144
147
}
145
148
146
- func checkResolveNotFound (ctx context.Context , t * testing.T , resolver Resolver , name string ) {
149
+ func checkResolveNotFound (ctx context.Context , t * testing.T , i int , resolver Resolver , name string ) {
147
150
_ , err := resolver .Resolve (ctx , name )
148
151
if err != ds .ErrNotFound {
149
- t .Fatalf ("unexpected value : %#v " , err )
152
+ t .Fatalf ("[resolver %d] unexpected error : %s " , i , err . Error () )
150
153
}
151
154
}
152
155
153
- func checkResolve (ctx context.Context , t * testing.T , resolver Resolver , name string , val path.Path ) {
156
+ func checkResolve (ctx context.Context , t * testing.T , i int , resolver Resolver , name string , val path.Path ) {
154
157
xval , err := resolver .Resolve (ctx , name )
155
158
if err != nil {
156
- t .Fatal ( err )
159
+ t .Fatalf ( "[resolver %d] resolve failed: %s" , i , err . Error () )
157
160
}
158
161
if xval != val {
159
- t .Fatalf ("resolver resolves to unexpected value %s %s" , val , xval )
162
+ t .Fatalf ("[ resolver %d] unexpected value: %s %s" , i , val , xval )
160
163
}
161
164
}
0 commit comments