@cryptotaxi247 / kubo / commits / 19de3041f

fix(bitswap) build-breaking compilation errors

License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>

Brian Tiger Chow committed Nov 23, 2014 at 22:52 UTC 19de3041fb0c03e597acc1afea8382064358e044
1 file changed +30 -30
exchange/bitswap/bitswap_test.go
+30 -30
@@ -25,8 +25,8 @@ func TestClose(t *testing.T) {
25 block := bgen.Next()
26 bitswap := sesgen.Next()
27
28 - bitswap.exchange.Close()
29 - bitswap.exchange.GetBlock(context.Background(), block.Key())
28 + bitswap.Exchange.Close()
29 + bitswap.Exchange.GetBlock(context.Background(), block.Key())
30 }
31
32 func TestGetBlockTimeout(t *testing.T) {
@@ -39,7 +39,7 @@ func TestGetBlockTimeout(t *testing.T) {
39
40 ctx, _ := context.WithTimeout(context.Background(), time.Nanosecond)
41 block := blocks.NewBlock([]byte("block"))
42 - _, err := self.exchange.GetBlock(ctx, block.Key())
42 + _, err := self.Exchange.GetBlock(ctx, block.Key())
43
44 if err != context.DeadlineExceeded {
45 t.Fatal("Expected DeadlineExceeded error")
@@ -58,7 +58,7 @@ func TestProviderForKeyButNetworkCannotFind(t *testing.T) {
58 solo := g.Next()
59
60 ctx, _ := context.WithTimeout(context.Background(), time.Nanosecond)
61 - _, err := solo.exchange.GetBlock(ctx, block.Key())
61 + _, err := solo.Exchange.GetBlock(ctx, block.Key())
62
63 if err != context.DeadlineExceeded {
64 t.Fatal("Expected DeadlineExceeded error")
@@ -76,17 +76,17 @@ func TestGetBlockFromPeerAfterPeerAnnounces(t *testing.T) {
76
77 hasBlock := g.Next()
78
79 - if err := hasBlock.blockstore.Put(block); err != nil {
79 + if err := hasBlock.Blockstore.Put(block); err != nil {
80 t.Fatal(err)
81 }
82 - if err := hasBlock.exchange.HasBlock(context.Background(), block); err != nil {
82 + if err := hasBlock.Exchange.HasBlock(context.Background(), block); err != nil {
83 t.Fatal(err)
84 }
85
86 wantsBlock := g.Next()
87
88 ctx, _ := context.WithTimeout(context.Background(), time.Second)
89 - received, err := wantsBlock.exchange.GetBlock(ctx, block.Key())
89 + received, err := wantsBlock.Exchange.GetBlock(ctx, block.Key())
90 if err != nil {
91 t.Log(err)
92 t.Fatal("Expected to succeed")
@@ -135,9 +135,9 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
135
136 first := instances[0]
137 for _, b := range blocks {
138 - first.blockstore.Put(b)
139 - first.exchange.HasBlock(context.Background(), b)
140 - rs.Announce(first.peer, b.Key())
138 + first.Blockstore.Put(b)
139 + first.Exchange.HasBlock(context.Background(), b)
140 + rs.Announce(first.Peer, b.Key())
141 }
142
143 t.Log("Distribute!")
@@ -158,7 +158,7 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
158
159 for _, inst := range instances {
160 for _, b := range blocks {
161 - if _, err := inst.blockstore.Get(b.Key()); err != nil {
161 + if _, err := inst.Blockstore.Get(b.Key()); err != nil {
162 t.Fatal(err)
163 }
164 }
@@ -166,8 +166,8 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
166 }
167
168 func getOrFail(bitswap Instance, b *blocks.Block, t *testing.T, wg *sync.WaitGroup) {
169 - if _, err := bitswap.blockstore.Get(b.Key()); err != nil {
170 - _, err := bitswap.exchange.GetBlock(context.Background(), b.Key())
169 + if _, err := bitswap.Blockstore.Get(b.Key()); err != nil {
170 + _, err := bitswap.Exchange.GetBlock(context.Background(), b.Key())
171 if err != nil {
172 t.Fatal(err)
173 }
@@ -190,50 +190,50 @@ func TestSendToWantingPeer(t *testing.T) {
190 w := sg.Next()
191 o := sg.Next()
192
193 - t.Logf("Session %v\n", me.peer)
194 - t.Logf("Session %v\n", w.peer)
195 - t.Logf("Session %v\n", o.peer)
193 + t.Logf("Session %v\n", me.Peer)
194 + t.Logf("Session %v\n", w.Peer)
195 + t.Logf("Session %v\n", o.Peer)
196
197 alpha := bg.Next()
198
199 const timeout = 100 * time.Millisecond // FIXME don't depend on time
200
201 - t.Logf("Peer %v attempts to get %v. NB: not available\n", w.peer, alpha.Key())
201 + t.Logf("Peer %v attempts to get %v. NB: not available\n", w.Peer, alpha.Key())
202 ctx, _ := context.WithTimeout(context.Background(), timeout)
203 - _, err := w.exchange.GetBlock(ctx, alpha.Key())
203 + _, err := w.Exchange.GetBlock(ctx, alpha.Key())
204 if err == nil {
205 t.Fatalf("Expected %v to NOT be available", alpha.Key())
206 }
207
208 beta := bg.Next()
209 - t.Logf("Peer %v announes availability of %v\n", w.peer, beta.Key())
209 + t.Logf("Peer %v announes availability of %v\n", w.Peer, beta.Key())
210 ctx, _ = context.WithTimeout(context.Background(), timeout)
211 - if err := w.blockstore.Put(beta); err != nil {
211 + if err := w.Blockstore.Put(beta); err != nil {
212 t.Fatal(err)
213 }
214 - w.exchange.HasBlock(ctx, beta)
214 + w.Exchange.HasBlock(ctx, beta)
215
216 - t.Logf("%v gets %v from %v and discovers it wants %v\n", me.peer, beta.Key(), w.peer, alpha.Key())
216 + t.Logf("%v gets %v from %v and discovers it wants %v\n", me.Peer, beta.Key(), w.Peer, alpha.Key())
217 ctx, _ = context.WithTimeout(context.Background(), timeout)
218 - if _, err := me.exchange.GetBlock(ctx, beta.Key()); err != nil {
218 + if _, err := me.Exchange.GetBlock(ctx, beta.Key()); err != nil {
219 t.Fatal(err)
220 }
221
222 - t.Logf("%v announces availability of %v\n", o.peer, alpha.Key())
222 + t.Logf("%v announces availability of %v\n", o.Peer, alpha.Key())
223 ctx, _ = context.WithTimeout(context.Background(), timeout)
224 - if err := o.blockstore.Put(alpha); err != nil {
224 + if err := o.Blockstore.Put(alpha); err != nil {
225 t.Fatal(err)
226 }
227 - o.exchange.HasBlock(ctx, alpha)
227 + o.Exchange.HasBlock(ctx, alpha)
228
229 - t.Logf("%v requests %v\n", me.peer, alpha.Key())
229 + t.Logf("%v requests %v\n", me.Peer, alpha.Key())
230 ctx, _ = context.WithTimeout(context.Background(), timeout)
231 - if _, err := me.exchange.GetBlock(ctx, alpha.Key()); err != nil {
231 + if _, err := me.Exchange.GetBlock(ctx, alpha.Key()); err != nil {
232 t.Fatal(err)
233 }
234
235 - t.Logf("%v should now have %v\n", w.peer, alpha.Key())
236 - block, err := w.blockstore.Get(alpha.Key())
235 + t.Logf("%v should now have %v\n", w.Peer, alpha.Key())
236 + block, err := w.Blockstore.Get(alpha.Key())
237 if err != nil {
238 t.Fatal("Should not have received an error")
239 }