feature_dirsymlinks.py raw

   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  """Test successful startup with symlinked directories.
   6  """
   7  
   8  import os
   9  
  10  from test_framework.test_framework import BitcoinTestFramework
  11  
  12  
  13  def rename_and_link(*, from_name, to_name):
  14      os.rename(from_name, to_name)
  15      os.symlink(to_name, from_name)
  16      assert os.path.islink(from_name) and os.path.isdir(from_name)
  17  
  18  
  19  class SymlinkTest(BitcoinTestFramework):
  20      def set_test_params(self):
  21          self.num_nodes = 1
  22  
  23      def run_test(self):
  24          dir_new_blocks = self.nodes[0].chain_path / "new_blocks"
  25          dir_new_chainstate = self.nodes[0].chain_path / "new_chainstate"
  26          self.stop_node(0)
  27  
  28          rename_and_link(
  29              from_name=self.nodes[0].blocks_path,
  30              to_name=dir_new_blocks,
  31          )
  32          rename_and_link(
  33              from_name=self.nodes[0].chain_path / "chainstate",
  34              to_name=dir_new_chainstate,
  35          )
  36  
  37          self.start_node(0)
  38  
  39  
  40  if __name__ == "__main__":
  41      SymlinkTest(__file__).main()
  42