Browse Source

mmgen-autosign: add --wallet-dir opt; update test

The MMGen Project 2 years ago
parent
commit
d757bb2949
3 changed files with 10 additions and 2 deletions
  1. 2 1
      mmgen/autosign.py
  2. 1 0
      mmgen/main_autosign.py
  3. 7 1
      test/test_py_d/ts_autosign.py

+ 2 - 1
mmgen/autosign.py

@@ -27,7 +27,7 @@ class AutosignConfig(Config):
 class Autosign:
 
 	dfl_mountpoint = os.path.join(os.sep,'mnt','mmgen_autosign')
-	wallet_dir     = os.path.join(os.sep,'dev','shm','autosign')
+	dfl_wallet_dir = os.path.join(os.sep,'dev','shm','autosign')
 	disk_label_dir = os.path.join(os.sep,'dev','disk','by-label')
 	part_label = 'MMGEN_TX'
 
@@ -62,6 +62,7 @@ class Autosign:
 		self.cfg = cfg
 
 		self.mountpoint = cfg.mountpoint or self.dfl_mountpoint
+		self.wallet_dir = cfg.wallet_dir or self.dfl_wallet_dir
 
 		self.tx_dir  = os.path.join( self.mountpoint, 'tx' )
 		self.msg_dir = os.path.join( self.mountpoint, 'msg' )

+ 1 - 0
mmgen/main_autosign.py

@@ -49,6 +49,7 @@ opts_data = {
                       will not be printed.
 -q, --quiet           Produce quieter output
 -v, --verbose         Produce more verbose output
+-w, --wallet-dir=D    Specify an alternate wallet dir (default: {asi.dfl_wallet_dir!r})
 """,
 	'notes': """
 

+ 7 - 1
test/test_py_d/ts_autosign.py

@@ -92,12 +92,16 @@ class TestSuiteAutosignBase(TestSuiteBase):
 
 		self.network_ids = [c+'_tn' for c in self.daemon_coins] + self.daemon_coins
 
+		if not self.live:
+			self.wallet_dir = os.path.join(self.tmpdir,'dev.shm.autosign')
+
 		self.asi = Autosign(
 			AutosignConfig({
 				'mountpoint': (
 					None if self.live else
 					os.path.join(self.tmpdir,self.mountpoint_basename)
-				)
+				),
+				'wallet_dir': None if self.live else self.wallet_dir,
 			})
 		)
 		self.mountpoint = self.asi.mountpoint
@@ -116,9 +120,11 @@ class TestSuiteAutosignBase(TestSuiteBase):
 			init_led(self.simulate)
 		else:
 			os.makedirs(self.asi.tx_dir,exist_ok=True) # creates mountpoint
+			os.makedirs(self.wallet_dir,exist_ok=True)
 			self.opts.extend([
 				'--mountpoint=' + self.mountpoint,
 				'--no-insert-check',
+				'--wallet-dir=' + self.wallet_dir,
 			])
 
 		self.tx_file_ops('set_count') # initialize tx_count here so we can resume anywhere