p2p_i2p_sessions.py
1 #!/usr/bin/env python3 2 # Copyright (c) 2022-present The Bitcoin Core developers 3 # Distributed under the MIT software license, see the accompanying 4 # file COPYING or http://www.opensource.org/licenses/mit-license.php. 5 """ 6 Test whether persistent or transient I2P sessions are being used, based on `-i2pacceptincoming`. 7 """ 8 9 from test_framework.test_framework import BitcoinTestFramework 10 11 12 class I2PSessions(BitcoinTestFramework): 13 def set_test_params(self): 14 self.num_nodes = 2 15 # The test assumes that an I2P SAM proxy is not listening here. 16 self.extra_args = [ 17 ["-i2psam=127.0.0.1:60000", "-i2pacceptincoming=1"], 18 ["-i2psam=127.0.0.1:60000", "-i2pacceptincoming=0"], 19 ] 20 21 def run_test(self): 22 addr = "zsxwyo6qcn3chqzwxnseusqgsnuw3maqnztkiypyfxtya4snkoka.b32.i2p" 23 24 self.log.info("Ensure we create a persistent session when -i2pacceptincoming=1") 25 node0 = self.nodes[0] 26 with node0.assert_debug_log(expected_msgs=["Creating persistent I2P SAM session"]): 27 node0.addnode(node=addr, command="onetry") 28 29 self.log.info("Ensure we create a transient session when -i2pacceptincoming=0") 30 node1 = self.nodes[1] 31 with node1.assert_debug_log(expected_msgs=["Creating transient I2P SAM session"]): 32 node1.addnode(node=addr, command="onetry") 33 34 35 if __name__ == '__main__': 36 I2PSessions(__file__).main()