jbenet/go-ipfs — pull request #461 by maybebtc (2014-12-17 14:51:42+00:00)
Title: add netmock2 to bitswap tests

@jbenet

This PR integrates mock2 into the bitswap tests.

A couple things:

* It looks like all mock2 constructors generate peers. Am I missing one that doesn't? Clients of this library already have ways of generating their own unique peers.
* Seeing a panic upon instantiation using `FullMeshLinked`:

```
BenchmarkInstantaneousAddCat1MB-4	panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x50 pc=0x131f4a]

goroutine 5 [running]:
github.com/jbenet/go-ipfs/net/mock2.(*mocknet).AddPeer(0xc20800a3c0, 0xc208721740, 0x22, 0x30, 0x0, 0x0, 0x0, 0x0)
/Users/btc/go/src/github.com/jbenet/go-ipfs/net/mock2/mock_net.go:62 +0x7a
github.com/jbenet/go-ipfs/net/mock2.(*mocknet).GenPeer(0xc20800a3c0, 0x0, 0x0, 0x0, 0x0)
/Users/btc/go/src/github.com/jbenet/go-ipfs/net/mock2/mock_net.go:48 +0x105
github.com/jbenet/go-ipfs/net/mock2.WithNPeers(0x79d658, 0xc20802ad30, 0x2, 0x0, 0x0, 0x0, 0x0)
/Users/btc/go/src/github.com/jbenet/go-ipfs/net/mock2/mock.go:15 +0x190
github.com/jbenet/go-ipfs/net/mock2.FullMeshLinked(0x79d658, 0xc20802ad30, 0x2, 0x0, 0x0, 0x0, 0x0)
/Users/btc/go/src/github.com/jbenet/go-ipfs/net/mock2/mock.go:26 +0x80
github.com/jbenet/go-ipfs/exchange/bitswap/testnet.LimitedStreamNetWithDelay(0x79d658, 0xc20802ad30, 0x2, 0x79d698, 0xc20801e000, 0x0, 0x0, 0x0, 0x0)
/Users/btc/go/src/github.com/jbenet/go-ipfs/exchange/bitswap/testnet/peernet.go:20 +0x72
github.com/jbenet/go-ipfs/epictest.AddCatBytes(0xc20849e000, 0x100000, 0x100000, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/btc/go/src/github.com/jbenet/go-ipfs/epictest/addcat_test.go:107 +0x19a
github.com/jbenet/go-ipfs/epictest.benchmarkAddCat(0x100000, 0x0, 0x0, 0x0, 0xc208062700)
/Users/btc/go/src/github.com/jbenet/go-ipfs/epictest/bench_test.go:13 +0xf3
github.com/jbenet/go-ipfs/epictest.BenchmarkInstantaneousAddCat1MB(0xc208062700)
/Users/btc/go/src/github.com/jbenet/go-ipfs/epictest/bench_test.go:21 +0x55
testing.(*B).runN(0xc208062700, 0x1)
/usr/local/Cellar/go/1.4/libexec/src/testing/benchmark.go:124 +0x95
testing.(*B).launch(0xc208062700)
/usr/local/Cellar/go/1.4/libexec/src/testing/benchmark.go:199 +0x78
created by testing.(*B).run
/usr/local/Cellar/go/1.4/libexec/src/testing/benchmark.go:179 +0x3e

goroutine 1 [runnable]:
testing.(*B).run(0xc208062700, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.4/libexec/src/testing/benchmark.go:180 +0x67
testing.RunBenchmarks(0x5393f8, 0x69be60, 0x2e, 0x2e)
/usr/local/Cellar/go/1.4/libexec/src/testing/benchmark.go:312 +0x649
testing.(*M).Run(0xc20800a370, 0x6a6b60)
/usr/local/Cellar/go/1.4/libexec/src/testing/testing.go:494 +0x1a5
main.main()
github.com/jbenet/go-ipfs/epictest/_test/_testmain.go:154 +0x1d5
exit status 2
FAIL	github.com/jbenet/go-ipfs/epictest	0.038s
```