def add( dispatcher, thread_pool, consensus_proxy, consensus_notifier, ): handler = handlers.ConsensusRegisterHandler(consensus_proxy, consensus_notifier) dispatcher.add_handler(handler.request_type, handler, thread_pool) handler = handlers.ConsensusRegisterBlockNewSyncHandler( consensus_proxy, consensus_notifier) dispatcher.add_handler(handler.request_type, handler, thread_pool) handler = handlers.ConsensusSendToHandler(consensus_proxy) dispatcher.add_handler(handler.request_type, handler, thread_pool) handler = handlers.ConsensusBroadcastHandler(consensus_proxy) dispatcher.add_handler(handler.request_type, handler, thread_pool) handler = handlers.ConsensusInitializeBlockHandler(consensus_proxy) dispatcher.add_handler(handler.request_type, handler, thread_pool) handler = handlers.ConsensusSummarizeBlockHandler(consensus_proxy) dispatcher.add_handler(handler.request_type, handler, thread_pool) handler = handlers.ConsensusFinalizeBlockHandler(consensus_proxy) dispatcher.add_handler(handler.request_type, handler, thread_pool) handler = handlers.ConsensusCancelBlockHandler(consensus_proxy) dispatcher.add_handler(handler.request_type, handler, thread_pool) handler = handlers.ConsensusCheckBlocksHandler(consensus_proxy) dispatcher.add_handler(handler.request_type, handler, thread_pool) handler = handlers.ConsensusCheckBlocksNotifier(consensus_proxy, consensus_notifier) dispatcher.add_handler(handler.request_type, handler, thread_pool) handler = handlers.ConsensusCommitBlockHandler(consensus_proxy) dispatcher.add_handler(handler.request_type, handler, thread_pool) handler = handlers.ConsensusIgnoreBlockHandler(consensus_proxy) dispatcher.add_handler(handler.request_type, handler, thread_pool) handler = handlers.ConsensusFailBlockHandler(consensus_proxy) dispatcher.add_handler(handler.request_type, handler, thread_pool) handler = handlers.ConsensusBlocksGetHandler(consensus_proxy) dispatcher.add_handler(handler.request_type, handler, thread_pool) handler = handlers.ConsensusChainHeadGetHandler(consensus_proxy) dispatcher.add_handler(handler.request_type, handler, thread_pool) handler = handlers.ConsensusSettingsGetHandler(consensus_proxy) dispatcher.add_handler(handler.request_type, handler, thread_pool) handler = handlers.ConsensusStateGetHandler(consensus_proxy) dispatcher.add_handler(handler.request_type, handler, thread_pool)
def test_consensus_blocks_get_handler(self): self.mock_proxy.blocks_get.return_value = [ Mock(identifier='abcd', previous_block_id='abcd', header_signature='abcd', signer_public_key='abcd', block_num=1, consensus=b'consensus') ] handler = handlers.ConsensusBlocksGetHandler(self.mock_proxy) request_class = handler.request_class request = request_class() request.block_ids.extend([b"test"]) result = handler.handle(None, request.SerializeToString()) response = result.message_out self.assertEqual(response.status, handler.response_class.OK) self.mock_proxy.blocks_get.assert_called_with(request.block_ids)