def setUp(self): self.node = MockGatewayNode(gateway_helpers.get_gateway_opts( 8000, include_default_btc_args=True, compact_block_min_tx_count=5 )) self.node.block_processing_service = MagicMock() self.connection = BtcNodeConnection( MockSocketConnection(node=self.node, ip_address=LOCALHOST, port=123), self.node ) self.connection.node = self.node self.connection.peer_ip = LOCALHOST self.connection.peer_port = 8001 self.connection.network_num = 2 self.sut = BtcNodeConnectionProtocol(self.connection) full_block_msg = BlockBtcMessage( buf=bytearray(convert.hex_to_bytes(self.FULL_BLOCK_BYTES_HEX)) ) if self.node.opts.use_extensions: transaction_service = ExtensionTransactionService(self.node, 0) else: transaction_service = TransactionService(self.node, 0) short_id = 1 for tx in full_block_msg.txns(): tx_hash = btc_common_utils.get_txid(tx) transaction_service.set_transaction_contents(tx_hash, tx) transaction_service.assign_short_id(tx_hash, short_id) short_id += 1 self.sut.connection.node._tx_service = transaction_service
def __init__(self, opts: Namespace): super(MockNode, self).__init__(opts) self.alarm_queue = AlarmQueue() self.network_num = DEFAULT_NETWORK_NUM self.broadcast_messages = [] self._tx_service = TransactionService(self, self.network_num) self._tx_services = {}
def __init__(self, opts, node_ssl_service: Optional[NodeSSLService] = None): if opts.use_extensions: helpers.set_extensions_parallelism() if node_ssl_service is None: node_ssl_service = MockNodeSSLService(self.NODE_TYPE, MagicMock()) super(MockOntGatewayNode, self).__init__(opts, node_ssl_service) self.requester = MagicMock() self.broadcast_messages = [] self.broadcast_to_nodes_messages = [] self._tx_service = TransactionService(self, 0) self.block_cleanup_service = self._get_cleanup_service() self.block_queuing_service = OntBlockQueuingService(self) self.message_converter = MockMessageConverter() if opts.use_extensions: from bxcommon.services.extension_transaction_service import ExtensionTransactionService self._tx_service = ExtensionTransactionService(self, self.network_num) else: self._tx_service = TransactionService(self, self.network_num) self.opts.has_fully_updated_tx_service = True self.has_active_blockchain_peer = MagicMock(return_value=True)
def __init__(self, opts: CommonOpts, node_ssl_service: Optional[NodeSSLService] = None) -> None: if node_ssl_service is None: node_ssl_service = MockNodeSSLService(self.NODE_TYPE, MagicMock()) super(MockNode, self).__init__(opts, node_ssl_service) self.alarm_queue = AlarmQueue() self.network_num = DEFAULT_NETWORK_NUM self.broadcast_messages = [] self._tx_service = TransactionService(self, self.network_num) self._tx_services = {}
def init(self, use_extensions: bool): opts = Namespace() opts.use_extensions = use_extensions opts.import_extensions = use_extensions opts.tx_mem_pool_bucket_size = DEFAULT_TX_MEM_POOL_BUCKET_SIZE ont_message_converter = converter_factory.create_ont_message_converter(self.MAGIC, opts) if use_extensions: helpers.set_extensions_parallelism() tx_service = ExtensionTransactionService(MockNode( gateway_helpers.get_gateway_opts(8999)), 0) else: tx_service = TransactionService(MockNode( gateway_helpers.get_gateway_opts(8999)), 0) return tx_service, ont_message_converter
def init(self, use_extensions: bool): opts = Namespace() opts.use_extensions = use_extensions opts.import_extensions = use_extensions opts.tx_mem_pool_bucket_size = DEFAULT_TX_MEM_POOL_BUCKET_SIZE btc_message_converter = converter_factory.create_btc_message_converter(self.MAGIC, opts=opts) if use_extensions: helpers.set_extensions_parallelism() tx_service = ExtensionTransactionService(MockNode( gateway_helpers.get_gateway_opts(8999)), 0) else: tx_service = TransactionService(MockNode( gateway_helpers.get_gateway_opts(8999)), 0) if self.txns: for idx, txn in enumerate(self.txns): sha = btc_common_utils.get_txid(txn) if idx % 2 == 0: tx_service.assign_short_id(sha, self.short_ids[int(idx/2)]) tx_service.set_transaction_contents(sha, txn) return tx_service, btc_message_converter
def _get_transaction_service(self) -> TransactionService: return TransactionService(self.mock_node, 0)
def setUp(self) -> None: self.node = MockNode(helpers.get_common_opts(1234)) self.network_num = 4 self.transaction_service = TransactionService(self.node, self.network_num)