def peer_manager(channel_message_handler, routing_message_handler): our_node_secret = SecretKey(get_random_sk_bytes()) ephemeral_random_data = get_random_bytes(32) logger = LDKLogger(Logger()) return PeerManager(channel_message_handler, routing_message_handler, our_node_secret, ephemeral_random_data, logger)
def test_update_monitor(channel_monitor, channel_monitor_update_data): update = ChannelMonitorUpdate.from_bytes(channel_monitor_update_data) broadcaster = BroadcasterInterface(Broadcaster()) fee_estimator = FeeEstimator(FeeEst()) logger = LDKLogger(Logger()) channel_monitor.update_monitor(update, broadcaster, fee_estimator, logger)
def test_block_disconnected(channel_monitor, tx): block_header = BlockHeader(get_random_bytes(80)) height = 1 broadcaster = BroadcasterInterface(Broadcaster()) fee_estimator = FeeEstimator(FeeEst()) logger = LDKLogger(Logger()) channel_monitor.block_disconnected(block_header, height, broadcaster, fee_estimator, logger)
def chain_monitor(in_mem_chan_keys): chain_source = Filter(F()) broadcaster = BroadcasterInterface(Broadcaster()) fee_estimator = FeeEstimator(FeeEst()) logger = LDKLogger(Logger()) persister = Persist(Persister()) return ChainMonitor(chain_source, broadcaster, logger, fee_estimator, persister)
def test_net_graph_msg_handler_get_graph(net_graph_bytes): access = Access(A()) logger = LDKLogger(Logger()) empty_graph_handler = NetGraphMsgHandler.from_net_graph(access, logger, NetworkGraph()) net_graph_handler = NetGraphMsgHandler.from_net_graph(access, logger, NetworkGraph.from_bytes(net_graph_bytes)) assert empty_graph_handler.graph.serialize() == bytes(16) assert net_graph_handler.graph.serialize() == net_graph_bytes
def test_block_connected(channel_monitor, tx): block_header = BlockHeader(get_random_bytes(80)) txdata = [(len(tx), Transaction.from_bytes(tx))] height = 1 broadcaster = BroadcasterInterface(Broadcaster()) fee_estimator = FeeEstimator(FeeEst()) logger = LDKLogger(Logger()) outs_to_watch = channel_monitor.block_connected(block_header, txdata, height, broadcaster, fee_estimator, logger) # The data is completely made up, so there should be no outputs to watch assert outs_to_watch == []
def test_net_graph_msg_handler_from_net_graph(channel_announcement_bytes): access = Access(A()) logger = LDKLogger(Logger()) net_graph = NetworkGraph() assert isinstance(NetGraphMsgHandler.from_net_graph(access, logger, net_graph), NetGraphMsgHandler) assert isinstance(NetGraphMsgHandler.from_net_graph(None, logger, net_graph), NetGraphMsgHandler) # Check also with a non-empty graph chan_announcement = ChannelAnnouncement.from_bytes(channel_announcement_bytes) net_graph.update_channel_from_announcement(chan_announcement) assert isinstance(NetGraphMsgHandler.from_net_graph(access, logger, net_graph), NetGraphMsgHandler) assert isinstance(NetGraphMsgHandler.from_net_graph(None, logger, net_graph), NetGraphMsgHandler)
def test_net_graph_msg_handler(): access = Access(A()) logger = LDKLogger(Logger()) assert isinstance(NetGraphMsgHandler(access, logger), NetGraphMsgHandler) assert isinstance(NetGraphMsgHandler(None, logger), NetGraphMsgHandler)
def test_get_latest_holder_commitment_txn(channel_monitor): # Not the best UX at the moment, but looks like this may change for 0.0.13. # FIXME: #PANIC-ERROR with pytest.raises(BaseException, match="must accept before signing"): channel_monitor.get_latest_holder_commitment_txn(LDKLogger(Logger()))