You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

458 lines
12 KiB

7 years ago
8 years ago
8 years ago
7 years ago
Replaced NodeInfo's pubkey to ID (#1443) * Replaced NodeInfo PubKey to NodeID * Fixed tests and replaced NodeID with ID * Removed unnecessary method ID() * Fixed codec_test.go * Fixed codec_test.go * Removed unnecessary bracket * Fixed all tests * Fixed peer_set_test.go * Fixed peer_test.go * Fixed common_test.go * Fixed common_test.go * Renamed node_id to id * Removed peer.ID() from RPC net.go * Replaced NodeInfo pubKey to ID * Fixed codec_test.go * Fixed peer_set_test.go * Fix pex_reactor_test.go * Refactored code for privateKey initiali * Fixed peer_set_test.go * Fixed test.proto and removed orphan string in codec_test.go * Fixed pointer to a string * generate node_key when running tendermint init * [docs] prefix IPs with node IDs Refs #1429 * gen_node_key cmd * [docs/specification/secure-p2p] add a note about config * fix data race Closes #1442 ``` WARNING: DATA RACE Write at 0x00c4209de7c8 by goroutine 23: github.com/tendermint/tendermint/types.(*Block).fillHeader() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:88 +0x157 github.com/tendermint/tendermint/types.(*Block).Hash() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:104 +0x121 github.com/tendermint/tendermint/types.(*Block).HashesTo() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:135 +0x4f github.com/tendermint/tendermint/consensus.(*ConsensusState).enterPrecommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1037 +0x182d github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1425 +0x1a6c github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1318 +0x77 github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:581 +0x7a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:539 +0x6c3 Previous read at 0x00c4209de7c8 by goroutine 47: github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*HexBytes).MarshalJSON() <autogenerated>:1 +0x52 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.invokeMarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:433 +0x88 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:82 +0x8d2 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).MarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/amino.go:296 +0x182 github.com/tendermint/tendermint/rpc/lib/types.NewRPCSuccessResponse() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/types/types.go:100 +0x12c github.com/tendermint/tendermint/rpc/lib/server.makeJSONRPCHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/handlers.go:152 +0xab7 net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.(*ServeMux).ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2254 +0xa2 github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:138 +0x4fa net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.serverHandler.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2619 +0xbc net/http.(*conn).serve() /usr/lib/go-1.9/src/net/http/server.go:1801 +0x83b Goroutine 23 (running) created at: github.com/tendermint/tendermint/consensus.(*ConsensusState).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:250 +0x35b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/reactor.go:69 +0x1b4 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).Start() <autogenerated>:1 +0x43 github.com/tendermint/tendermint/p2p.(*Switch).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/p2p/switch.go:177 +0x124 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/node.(*Node).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/node/node.go:416 +0xa1b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/rpc/test.StartTendermint() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/test/helpers.go:100 +0x5b github.com/tendermint/tendermint/rpc/client_test.TestMain() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/client/main_test.go:17 +0x4c main.main() github.com/tendermint/tendermint/rpc/client/_test/_testmain.go:76 +0x1cd Goroutine 47 (running) created at: net/http.(*Server).Serve() /usr/lib/go-1.9/src/net/http/server.go:2720 +0x37c net/http.Serve() /usr/lib/go-1.9/src/net/http/server.go:2323 +0xe2 github.com/tendermint/tendermint/rpc/lib/server.StartHTTPServer.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:35 +0xb3 ``` * removed excessive comment Refs https://github.com/tendermint/tendermint/pull/1446#discussion_r180353446 * use the tag interface for pubsub. (#1438) * use the tag interface for pubsub. * update tmlibs. * Fix unresolved conflict. * improve `show_node_id` (#1433) * fix show_node_id * make LoadNodeKey public * make LoadNodeKey public * remove if * remove if
7 years ago
7 years ago
Replaced NodeInfo's pubkey to ID (#1443) * Replaced NodeInfo PubKey to NodeID * Fixed tests and replaced NodeID with ID * Removed unnecessary method ID() * Fixed codec_test.go * Fixed codec_test.go * Removed unnecessary bracket * Fixed all tests * Fixed peer_set_test.go * Fixed peer_test.go * Fixed common_test.go * Fixed common_test.go * Renamed node_id to id * Removed peer.ID() from RPC net.go * Replaced NodeInfo pubKey to ID * Fixed codec_test.go * Fixed peer_set_test.go * Fix pex_reactor_test.go * Refactored code for privateKey initiali * Fixed peer_set_test.go * Fixed test.proto and removed orphan string in codec_test.go * Fixed pointer to a string * generate node_key when running tendermint init * [docs] prefix IPs with node IDs Refs #1429 * gen_node_key cmd * [docs/specification/secure-p2p] add a note about config * fix data race Closes #1442 ``` WARNING: DATA RACE Write at 0x00c4209de7c8 by goroutine 23: github.com/tendermint/tendermint/types.(*Block).fillHeader() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:88 +0x157 github.com/tendermint/tendermint/types.(*Block).Hash() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:104 +0x121 github.com/tendermint/tendermint/types.(*Block).HashesTo() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:135 +0x4f github.com/tendermint/tendermint/consensus.(*ConsensusState).enterPrecommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1037 +0x182d github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1425 +0x1a6c github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1318 +0x77 github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:581 +0x7a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:539 +0x6c3 Previous read at 0x00c4209de7c8 by goroutine 47: github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*HexBytes).MarshalJSON() <autogenerated>:1 +0x52 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.invokeMarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:433 +0x88 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:82 +0x8d2 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).MarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/amino.go:296 +0x182 github.com/tendermint/tendermint/rpc/lib/types.NewRPCSuccessResponse() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/types/types.go:100 +0x12c github.com/tendermint/tendermint/rpc/lib/server.makeJSONRPCHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/handlers.go:152 +0xab7 net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.(*ServeMux).ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2254 +0xa2 github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:138 +0x4fa net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.serverHandler.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2619 +0xbc net/http.(*conn).serve() /usr/lib/go-1.9/src/net/http/server.go:1801 +0x83b Goroutine 23 (running) created at: github.com/tendermint/tendermint/consensus.(*ConsensusState).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:250 +0x35b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/reactor.go:69 +0x1b4 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).Start() <autogenerated>:1 +0x43 github.com/tendermint/tendermint/p2p.(*Switch).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/p2p/switch.go:177 +0x124 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/node.(*Node).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/node/node.go:416 +0xa1b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/rpc/test.StartTendermint() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/test/helpers.go:100 +0x5b github.com/tendermint/tendermint/rpc/client_test.TestMain() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/client/main_test.go:17 +0x4c main.main() github.com/tendermint/tendermint/rpc/client/_test/_testmain.go:76 +0x1cd Goroutine 47 (running) created at: net/http.(*Server).Serve() /usr/lib/go-1.9/src/net/http/server.go:2720 +0x37c net/http.Serve() /usr/lib/go-1.9/src/net/http/server.go:2323 +0xe2 github.com/tendermint/tendermint/rpc/lib/server.StartHTTPServer.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:35 +0xb3 ``` * removed excessive comment Refs https://github.com/tendermint/tendermint/pull/1446#discussion_r180353446 * use the tag interface for pubsub. (#1438) * use the tag interface for pubsub. * update tmlibs. * Fix unresolved conflict. * improve `show_node_id` (#1433) * fix show_node_id * make LoadNodeKey public * make LoadNodeKey public * remove if * remove if
7 years ago
Replaced NodeInfo's pubkey to ID (#1443) * Replaced NodeInfo PubKey to NodeID * Fixed tests and replaced NodeID with ID * Removed unnecessary method ID() * Fixed codec_test.go * Fixed codec_test.go * Removed unnecessary bracket * Fixed all tests * Fixed peer_set_test.go * Fixed peer_test.go * Fixed common_test.go * Fixed common_test.go * Renamed node_id to id * Removed peer.ID() from RPC net.go * Replaced NodeInfo pubKey to ID * Fixed codec_test.go * Fixed peer_set_test.go * Fix pex_reactor_test.go * Refactored code for privateKey initiali * Fixed peer_set_test.go * Fixed test.proto and removed orphan string in codec_test.go * Fixed pointer to a string * generate node_key when running tendermint init * [docs] prefix IPs with node IDs Refs #1429 * gen_node_key cmd * [docs/specification/secure-p2p] add a note about config * fix data race Closes #1442 ``` WARNING: DATA RACE Write at 0x00c4209de7c8 by goroutine 23: github.com/tendermint/tendermint/types.(*Block).fillHeader() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:88 +0x157 github.com/tendermint/tendermint/types.(*Block).Hash() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:104 +0x121 github.com/tendermint/tendermint/types.(*Block).HashesTo() /home/vagrant/go/src/github.com/tendermint/tendermint/types/block.go:135 +0x4f github.com/tendermint/tendermint/consensus.(*ConsensusState).enterPrecommit() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1037 +0x182d github.com/tendermint/tendermint/consensus.(*ConsensusState).addVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1425 +0x1a6c github.com/tendermint/tendermint/consensus.(*ConsensusState).tryAddVote() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:1318 +0x77 github.com/tendermint/tendermint/consensus.(*ConsensusState).handleMsg() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:581 +0x7a9 github.com/tendermint/tendermint/consensus.(*ConsensusState).receiveRoutine() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:539 +0x6c3 Previous read at 0x00c4209de7c8 by goroutine 47: github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*HexBytes).MarshalJSON() <autogenerated>:1 +0x52 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.invokeMarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:433 +0x88 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:82 +0x8d2 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSONStruct() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:348 +0x539 github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec)._encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:119 +0x83f github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).encodeReflectJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/json-encode.go:50 +0x10e github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino.(*Codec).MarshalJSON() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/go-amino/amino.go:296 +0x182 github.com/tendermint/tendermint/rpc/lib/types.NewRPCSuccessResponse() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/types/types.go:100 +0x12c github.com/tendermint/tendermint/rpc/lib/server.makeJSONRPCHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/handlers.go:152 +0xab7 net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.(*ServeMux).ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2254 +0xa2 github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:138 +0x4fa net/http.HandlerFunc.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:1918 +0x51 net/http.serverHandler.ServeHTTP() /usr/lib/go-1.9/src/net/http/server.go:2619 +0xbc net/http.(*conn).serve() /usr/lib/go-1.9/src/net/http/server.go:1801 +0x83b Goroutine 23 (running) created at: github.com/tendermint/tendermint/consensus.(*ConsensusState).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/state.go:250 +0x35b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/consensus/reactor.go:69 +0x1b4 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/consensus.(*ConsensusReactor).Start() <autogenerated>:1 +0x43 github.com/tendermint/tendermint/p2p.(*Switch).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/p2p/switch.go:177 +0x124 github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/node.(*Node).OnStart() /home/vagrant/go/src/github.com/tendermint/tendermint/node/node.go:416 +0xa1b github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common.(*BaseService).Start() /home/vagrant/go/src/github.com/tendermint/tendermint/vendor/github.com/tendermint/tmlibs/common/service.go:130 +0x5fc github.com/tendermint/tendermint/rpc/test.StartTendermint() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/test/helpers.go:100 +0x5b github.com/tendermint/tendermint/rpc/client_test.TestMain() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/client/main_test.go:17 +0x4c main.main() github.com/tendermint/tendermint/rpc/client/_test/_testmain.go:76 +0x1cd Goroutine 47 (running) created at: net/http.(*Server).Serve() /usr/lib/go-1.9/src/net/http/server.go:2720 +0x37c net/http.Serve() /usr/lib/go-1.9/src/net/http/server.go:2323 +0xe2 github.com/tendermint/tendermint/rpc/lib/server.StartHTTPServer.func1() /home/vagrant/go/src/github.com/tendermint/tendermint/rpc/lib/server/http_server.go:35 +0xb3 ``` * removed excessive comment Refs https://github.com/tendermint/tendermint/pull/1446#discussion_r180353446 * use the tag interface for pubsub. (#1438) * use the tag interface for pubsub. * update tmlibs. * Fix unresolved conflict. * improve `show_node_id` (#1433) * fix show_node_id * make LoadNodeKey public * make LoadNodeKey public * remove if * remove if
7 years ago
7 years ago
  1. package pex
  2. import (
  3. "fmt"
  4. "io/ioutil"
  5. "net"
  6. "os"
  7. "path/filepath"
  8. "testing"
  9. "time"
  10. "github.com/stretchr/testify/assert"
  11. "github.com/stretchr/testify/require"
  12. crypto "github.com/tendermint/go-crypto"
  13. cmn "github.com/tendermint/tmlibs/common"
  14. "github.com/tendermint/tmlibs/log"
  15. "github.com/tendermint/tendermint/config"
  16. "github.com/tendermint/tendermint/p2p"
  17. "github.com/tendermint/tendermint/p2p/conn"
  18. )
  19. var (
  20. cfg *config.P2PConfig
  21. )
  22. func init() {
  23. cfg = config.DefaultP2PConfig()
  24. cfg.PexReactor = true
  25. cfg.AllowDuplicateIP = true
  26. }
  27. func TestPEXReactorBasic(t *testing.T) {
  28. r, book := createReactor(&PEXReactorConfig{})
  29. defer teardownReactor(book)
  30. assert.NotNil(t, r)
  31. assert.NotEmpty(t, r.GetChannels())
  32. }
  33. func TestPEXReactorAddRemovePeer(t *testing.T) {
  34. r, book := createReactor(&PEXReactorConfig{})
  35. defer teardownReactor(book)
  36. size := book.Size()
  37. peer := p2p.CreateRandomPeer(false)
  38. r.AddPeer(peer)
  39. assert.Equal(t, size+1, book.Size())
  40. r.RemovePeer(peer, "peer not available")
  41. outboundPeer := p2p.CreateRandomPeer(true)
  42. r.AddPeer(outboundPeer)
  43. r.RemovePeer(outboundPeer, "peer not available")
  44. }
  45. // --- FAIL: TestPEXReactorRunning (11.10s)
  46. // pex_reactor_test.go:411: expected all switches to be connected to at
  47. // least one peer (switches: 0 => {outbound: 1, inbound: 0}, 1 =>
  48. // {outbound: 0, inbound: 1}, 2 => {outbound: 0, inbound: 0}, )
  49. //
  50. // EXPLANATION: peers are getting rejected because in switch#addPeer we check
  51. // if any peer (who we already connected to) has the same IP. Even though local
  52. // peers have different IP addresses, they all have the same underlying remote
  53. // IP: 127.0.0.1.
  54. //
  55. func TestPEXReactorRunning(t *testing.T) {
  56. N := 3
  57. switches := make([]*p2p.Switch, N)
  58. // directory to store address books
  59. dir, err := ioutil.TempDir("", "pex_reactor")
  60. require.Nil(t, err)
  61. defer os.RemoveAll(dir) // nolint: errcheck
  62. books := make([]*addrBook, N)
  63. logger := log.TestingLogger()
  64. // create switches
  65. for i := 0; i < N; i++ {
  66. switches[i] = p2p.MakeSwitch(cfg, i, "testing", "123.123.123", func(i int, sw *p2p.Switch) *p2p.Switch {
  67. books[i] = NewAddrBook(filepath.Join(dir, fmt.Sprintf("addrbook%d.json", i)), false)
  68. books[i].SetLogger(logger.With("pex", i))
  69. sw.SetAddrBook(books[i])
  70. sw.SetLogger(logger.With("pex", i))
  71. r := NewPEXReactor(books[i], &PEXReactorConfig{})
  72. r.SetLogger(logger.With("pex", i))
  73. r.SetEnsurePeersPeriod(250 * time.Millisecond)
  74. sw.AddReactor("pex", r)
  75. return sw
  76. })
  77. }
  78. addOtherNodeAddrToAddrBook := func(switchIndex, otherSwitchIndex int) {
  79. addr := switches[otherSwitchIndex].NodeInfo().NetAddress()
  80. books[switchIndex].AddAddress(addr, addr)
  81. }
  82. addOtherNodeAddrToAddrBook(0, 1)
  83. addOtherNodeAddrToAddrBook(1, 0)
  84. addOtherNodeAddrToAddrBook(2, 1)
  85. for i, sw := range switches {
  86. sw.AddListener(p2p.NewDefaultListener("tcp", sw.NodeInfo().ListenAddr, true, logger.With("pex", i)))
  87. err := sw.Start() // start switch and reactors
  88. require.Nil(t, err)
  89. }
  90. assertPeersWithTimeout(t, switches, 10*time.Millisecond, 10*time.Second, N-1)
  91. // stop them
  92. for _, s := range switches {
  93. s.Stop()
  94. }
  95. }
  96. func TestPEXReactorReceive(t *testing.T) {
  97. r, book := createReactor(&PEXReactorConfig{})
  98. defer teardownReactor(book)
  99. peer := p2p.CreateRandomPeer(false)
  100. // we have to send a request to receive responses
  101. r.RequestAddrs(peer)
  102. size := book.Size()
  103. addrs := []*p2p.NetAddress{peer.NodeInfo().NetAddress()}
  104. msg := cdc.MustMarshalBinary(&pexAddrsMessage{Addrs: addrs})
  105. r.Receive(PexChannel, peer, msg)
  106. assert.Equal(t, size+1, book.Size())
  107. msg = cdc.MustMarshalBinary(&pexRequestMessage{})
  108. r.Receive(PexChannel, peer, msg) // should not panic.
  109. }
  110. func TestPEXReactorRequestMessageAbuse(t *testing.T) {
  111. r, book := createReactor(&PEXReactorConfig{})
  112. defer teardownReactor(book)
  113. sw := createSwitchAndAddReactors(r)
  114. sw.SetAddrBook(book)
  115. peer := newMockPeer()
  116. p2p.AddPeerToSwitch(sw, peer)
  117. assert.True(t, sw.Peers().Has(peer.ID()))
  118. id := string(peer.ID())
  119. msg := cdc.MustMarshalBinary(&pexRequestMessage{})
  120. // first time creates the entry
  121. r.Receive(PexChannel, peer, msg)
  122. assert.True(t, r.lastReceivedRequests.Has(id))
  123. assert.True(t, sw.Peers().Has(peer.ID()))
  124. // next time sets the last time value
  125. r.Receive(PexChannel, peer, msg)
  126. assert.True(t, r.lastReceivedRequests.Has(id))
  127. assert.True(t, sw.Peers().Has(peer.ID()))
  128. // third time is too many too soon - peer is removed
  129. r.Receive(PexChannel, peer, msg)
  130. assert.False(t, r.lastReceivedRequests.Has(id))
  131. assert.False(t, sw.Peers().Has(peer.ID()))
  132. }
  133. func TestPEXReactorAddrsMessageAbuse(t *testing.T) {
  134. r, book := createReactor(&PEXReactorConfig{})
  135. defer teardownReactor(book)
  136. sw := createSwitchAndAddReactors(r)
  137. sw.SetAddrBook(book)
  138. peer := newMockPeer()
  139. p2p.AddPeerToSwitch(sw, peer)
  140. assert.True(t, sw.Peers().Has(peer.ID()))
  141. id := string(peer.ID())
  142. // request addrs from the peer
  143. r.RequestAddrs(peer)
  144. assert.True(t, r.requestsSent.Has(id))
  145. assert.True(t, sw.Peers().Has(peer.ID()))
  146. addrs := []*p2p.NetAddress{peer.NodeInfo().NetAddress()}
  147. msg := cdc.MustMarshalBinary(&pexAddrsMessage{Addrs: addrs})
  148. // receive some addrs. should clear the request
  149. r.Receive(PexChannel, peer, msg)
  150. assert.False(t, r.requestsSent.Has(id))
  151. assert.True(t, sw.Peers().Has(peer.ID()))
  152. // receiving more addrs causes a disconnect
  153. r.Receive(PexChannel, peer, msg)
  154. assert.False(t, sw.Peers().Has(peer.ID()))
  155. }
  156. func TestPEXReactorUsesSeedsIfNeeded(t *testing.T) {
  157. // directory to store address books
  158. dir, err := ioutil.TempDir("", "pex_reactor")
  159. require.Nil(t, err)
  160. defer os.RemoveAll(dir) // nolint: errcheck
  161. // 1. create seed
  162. seed := p2p.MakeSwitch(
  163. cfg,
  164. 0,
  165. "127.0.0.1",
  166. "123.123.123",
  167. func(i int, sw *p2p.Switch) *p2p.Switch {
  168. book := NewAddrBook(filepath.Join(dir, "addrbook0.json"), false)
  169. book.SetLogger(log.TestingLogger())
  170. sw.SetAddrBook(book)
  171. sw.SetLogger(log.TestingLogger())
  172. r := NewPEXReactor(book, &PEXReactorConfig{})
  173. r.SetLogger(log.TestingLogger())
  174. sw.AddReactor("pex", r)
  175. return sw
  176. },
  177. )
  178. seed.AddListener(
  179. p2p.NewDefaultListener(
  180. "tcp",
  181. seed.NodeInfo().ListenAddr,
  182. true,
  183. log.TestingLogger(),
  184. ),
  185. )
  186. require.Nil(t, seed.Start())
  187. defer seed.Stop()
  188. // 2. create usual peer with only seed configured.
  189. peer := p2p.MakeSwitch(
  190. cfg,
  191. 1,
  192. "127.0.0.1",
  193. "123.123.123",
  194. func(i int, sw *p2p.Switch) *p2p.Switch {
  195. book := NewAddrBook(filepath.Join(dir, "addrbook1.json"), false)
  196. book.SetLogger(log.TestingLogger())
  197. sw.SetAddrBook(book)
  198. sw.SetLogger(log.TestingLogger())
  199. r := NewPEXReactor(
  200. book,
  201. &PEXReactorConfig{
  202. Seeds: []string{seed.NodeInfo().NetAddress().String()},
  203. },
  204. )
  205. r.SetLogger(log.TestingLogger())
  206. sw.AddReactor("pex", r)
  207. return sw
  208. },
  209. )
  210. require.Nil(t, peer.Start())
  211. defer peer.Stop()
  212. // 3. check that the peer connects to seed immediately
  213. assertPeersWithTimeout(t, []*p2p.Switch{peer}, 10*time.Millisecond, 3*time.Second, 1)
  214. }
  215. func TestPEXReactorCrawlStatus(t *testing.T) {
  216. pexR, book := createReactor(&PEXReactorConfig{SeedMode: true})
  217. defer teardownReactor(book)
  218. // Seed/Crawler mode uses data from the Switch
  219. sw := createSwitchAndAddReactors(pexR)
  220. sw.SetAddrBook(book)
  221. // Create a peer, add it to the peer set and the addrbook.
  222. peer := p2p.CreateRandomPeer(false)
  223. p2p.AddPeerToSwitch(pexR.Switch, peer)
  224. addr1 := peer.NodeInfo().NetAddress()
  225. pexR.book.AddAddress(addr1, addr1)
  226. // Add a non-connected address to the book.
  227. _, addr2 := p2p.CreateRoutableAddr()
  228. pexR.book.AddAddress(addr2, addr1)
  229. // Get some peerInfos to crawl
  230. peerInfos := pexR.getPeersToCrawl()
  231. // Make sure it has the proper number of elements
  232. assert.Equal(t, 2, len(peerInfos))
  233. // TODO: test
  234. }
  235. func TestPEXReactorDoesNotAddPrivatePeersToAddrBook(t *testing.T) {
  236. peer := p2p.CreateRandomPeer(false)
  237. pexR, book := createReactor(&PEXReactorConfig{PrivatePeerIDs: []string{string(peer.NodeInfo().ID)}})
  238. defer teardownReactor(book)
  239. // we have to send a request to receive responses
  240. pexR.RequestAddrs(peer)
  241. size := book.Size()
  242. addrs := []*p2p.NetAddress{peer.NodeInfo().NetAddress()}
  243. msg := cdc.MustMarshalBinary(&pexAddrsMessage{Addrs: addrs})
  244. pexR.Receive(PexChannel, peer, msg)
  245. assert.Equal(t, size, book.Size())
  246. pexR.AddPeer(peer)
  247. assert.Equal(t, size, book.Size())
  248. }
  249. func TestPEXReactorDialPeer(t *testing.T) {
  250. pexR, book := createReactor(&PEXReactorConfig{})
  251. defer teardownReactor(book)
  252. sw := createSwitchAndAddReactors(pexR)
  253. sw.SetAddrBook(book)
  254. peer := newMockPeer()
  255. addr := peer.NodeInfo().NetAddress()
  256. assert.Equal(t, 0, pexR.AttemptsToDial(addr))
  257. // 1st unsuccessful attempt
  258. pexR.dialPeer(addr)
  259. assert.Equal(t, 1, pexR.AttemptsToDial(addr))
  260. // 2nd unsuccessful attempt
  261. pexR.dialPeer(addr)
  262. // must be skipped because it is too early
  263. assert.Equal(t, 1, pexR.AttemptsToDial(addr))
  264. if !testing.Short() {
  265. time.Sleep(3 * time.Second)
  266. // 3rd attempt
  267. pexR.dialPeer(addr)
  268. assert.Equal(t, 2, pexR.AttemptsToDial(addr))
  269. }
  270. }
  271. type mockPeer struct {
  272. *cmn.BaseService
  273. pubKey crypto.PubKey
  274. addr *p2p.NetAddress
  275. outbound, persistent bool
  276. }
  277. func newMockPeer() mockPeer {
  278. _, netAddr := p2p.CreateRoutableAddr()
  279. mp := mockPeer{
  280. addr: netAddr,
  281. pubKey: crypto.GenPrivKeyEd25519().PubKey(),
  282. }
  283. mp.BaseService = cmn.NewBaseService(nil, "MockPeer", mp)
  284. mp.Start()
  285. return mp
  286. }
  287. func (mp mockPeer) ID() p2p.ID { return mp.addr.ID }
  288. func (mp mockPeer) IsOutbound() bool { return mp.outbound }
  289. func (mp mockPeer) IsPersistent() bool { return mp.persistent }
  290. func (mp mockPeer) NodeInfo() p2p.NodeInfo {
  291. return p2p.NodeInfo{
  292. ID: mp.addr.ID,
  293. ListenAddr: mp.addr.DialString(),
  294. }
  295. }
  296. func (mp mockPeer) RemoteIP() net.IP { return net.ParseIP("127.0.0.1") }
  297. func (mp mockPeer) Status() conn.ConnectionStatus { return conn.ConnectionStatus{} }
  298. func (mp mockPeer) Send(byte, []byte) bool { return false }
  299. func (mp mockPeer) TrySend(byte, []byte) bool { return false }
  300. func (mp mockPeer) Set(string, interface{}) {}
  301. func (mp mockPeer) Get(string) interface{} { return nil }
  302. func assertPeersWithTimeout(
  303. t *testing.T,
  304. switches []*p2p.Switch,
  305. checkPeriod, timeout time.Duration,
  306. nPeers int,
  307. ) {
  308. var (
  309. ticker = time.NewTicker(checkPeriod)
  310. remaining = timeout
  311. )
  312. for {
  313. select {
  314. case <-ticker.C:
  315. // check peers are connected
  316. allGood := true
  317. for _, s := range switches {
  318. outbound, inbound, _ := s.NumPeers()
  319. if outbound+inbound < nPeers {
  320. allGood = false
  321. }
  322. }
  323. remaining -= checkPeriod
  324. if remaining < 0 {
  325. remaining = 0
  326. }
  327. if allGood {
  328. return
  329. }
  330. case <-time.After(remaining):
  331. numPeersStr := ""
  332. for i, s := range switches {
  333. outbound, inbound, _ := s.NumPeers()
  334. numPeersStr += fmt.Sprintf("%d => {outbound: %d, inbound: %d}, ", i, outbound, inbound)
  335. }
  336. t.Errorf(
  337. "expected all switches to be connected to at least one peer (switches: %s)",
  338. numPeersStr,
  339. )
  340. return
  341. }
  342. }
  343. }
  344. func createReactor(conf *PEXReactorConfig) (r *PEXReactor, book *addrBook) {
  345. // directory to store address book
  346. dir, err := ioutil.TempDir("", "pex_reactor")
  347. if err != nil {
  348. panic(err)
  349. }
  350. book = NewAddrBook(filepath.Join(dir, "addrbook.json"), true)
  351. book.SetLogger(log.TestingLogger())
  352. r = NewPEXReactor(book, conf)
  353. r.SetLogger(log.TestingLogger())
  354. return
  355. }
  356. func teardownReactor(book *addrBook) {
  357. err := os.RemoveAll(filepath.Dir(book.FilePath()))
  358. if err != nil {
  359. panic(err)
  360. }
  361. }
  362. func createSwitchAndAddReactors(reactors ...p2p.Reactor) *p2p.Switch {
  363. sw := p2p.MakeSwitch(cfg, 0, "127.0.0.1", "123.123.123", func(i int, sw *p2p.Switch) *p2p.Switch { return sw })
  364. sw.SetLogger(log.TestingLogger())
  365. for _, r := range reactors {
  366. sw.AddReactor(r.String(), r)
  367. r.SetSwitch(sw)
  368. }
  369. return sw
  370. }