Browse Source

cmdtest.py xmr_autosign: support compat mode testing

Testing:

    # Compat mode is now enabled by default:
    $ test/cmdtest.py -ne xmr_autosign

    # The old testing behavior is also supported:
    $ test/cmdtest.py -ne xmr_autosign_nocompat
The MMGen Project 2 weeks ago
parent
commit
851335106f

+ 4 - 1
mmgen/cfg.py

@@ -231,6 +231,7 @@ class Config(Lockable):
 	bob          = False
 	bob          = False
 	alice        = False
 	alice        = False
 	carol        = False
 	carol        = False
+	miner        = False
 	test_user    = ''
 	test_user    = ''
 
 
 	# altcoin:
 	# altcoin:
@@ -284,7 +285,7 @@ class Config(Lockable):
 
 
 	_incompatible_opts = (
 	_incompatible_opts = (
 		('help', 'longhelp'),
 		('help', 'longhelp'),
-		('bob', 'alice', 'carol'),
+		('bob', 'alice', 'carol', 'miner'),
 		('label', 'keep_label'),
 		('label', 'keep_label'),
 		('tx_id', 'info'),
 		('tx_id', 'info'),
 		('tx_id', 'terse_info'),
 		('tx_id', 'terse_info'),
@@ -559,6 +560,7 @@ class Config(Lockable):
 				self.bob or
 				self.bob or
 				self.alice or
 				self.alice or
 				self.carol or
 				self.carol or
+				self.miner or
 				gc.prog_name == f'{gc.proj_id}-regtest'):
 				gc.prog_name == f'{gc.proj_id}-regtest'):
 			if self.coin != 'XMR':
 			if self.coin != 'XMR':
 				self.network = 'regtest'
 				self.network = 'regtest'
@@ -566,6 +568,7 @@ class Config(Lockable):
 				'bob' if self.bob else
 				'bob' if self.bob else
 				'alice' if self.alice else
 				'alice' if self.alice else
 				'carol' if self.carol else
 				'carol' if self.carol else
+				'miner' if self.miner else
 				'')
 				'')
 		else:
 		else:
 			self.network = 'testnet' if self.testnet else 'mainnet'
 			self.network = 'testnet' if self.testnet else 'mainnet'

+ 1 - 1
mmgen/data/version

@@ -1 +1 @@
-16.1.dev13
+16.1.dev14

+ 1 - 0
mmgen/opts.py

@@ -320,6 +320,7 @@ class UserOpts(Opts):
 			x- --bob                  Specify user ‘Bob’ in MMGen regtest or test mode
 			x- --bob                  Specify user ‘Bob’ in MMGen regtest or test mode
 			x- --alice                Specify user ‘Alice’ in MMGen regtest or test mode
 			x- --alice                Specify user ‘Alice’ in MMGen regtest or test mode
 			x- --carol                Specify user ‘Carol’ in MMGen regtest or test mode
 			x- --carol                Specify user ‘Carol’ in MMGen regtest or test mode
+			x- --miner                Specify user ‘Miner’ in MMGen regtest or test mode
 			rr COIN-SPECIFIC OPTIONS:
 			rr COIN-SPECIFIC OPTIONS:
 			rr   For descriptions, refer to the non-prefixed versions of these options above
 			rr   For descriptions, refer to the non-prefixed versions of these options above
 			rr   Prefixed options override their non-prefixed counterparts
 			rr   Prefixed options override their non-prefixed counterparts

+ 1 - 0
test/cmdtest_d/include/cfg.py

@@ -61,6 +61,7 @@ cmd_groups_extra = {
 	'autosign_live':          gd('CmdTestAutosignLive',         {'modname': 'autosign'}),
 	'autosign_live':          gd('CmdTestAutosignLive',         {'modname': 'autosign'}),
 	'autosign_live_simulate': gd('CmdTestAutosignLiveSimulate', {'modname': 'autosign'}),
 	'autosign_live_simulate': gd('CmdTestAutosignLiveSimulate', {'modname': 'autosign'}),
 	'create_ref_tx':          gd('CmdTestRefTX',                {'modname': 'misc', 'full_data': True}),
 	'create_ref_tx':          gd('CmdTestRefTX',                {'modname': 'misc', 'full_data': True}),
+	'xmr_autosign_nocompat':  gd('CmdTestXMRAutosignNoCompat',  {'modname': 'xmr_autosign'}),
 }
 }
 
 
 cfgs = { # addr_idx_lists (except 31, 32, 33, 34) must contain exactly 8 addresses
 cfgs = { # addr_idx_lists (except 31, 32, 33, 34) must contain exactly 8 addresses

+ 18 - 6
test/cmdtest_d/xmr_autosign.py

@@ -33,7 +33,7 @@ def make_burn_addr(cfg):
 
 
 class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded):
 class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded):
 	"""
 	"""
-	Monero autosigning operations
+	Monero autosigning operations (xmrwallet compat mode)
 	"""
 	"""
 	tmpdir_nums = [39]
 	tmpdir_nums = [39]
 
 
@@ -46,6 +46,7 @@ class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded):
 
 
 	# autosign attrs:
 	# autosign attrs:
 	coins = ['xmr']
 	coins = ['xmr']
+	compat = True
 
 
 	cmd_group = (
 	cmd_group = (
 		('daemon_version',           'checking daemon version'),
 		('daemon_version',           'checking daemon version'),
@@ -109,10 +110,14 @@ class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded):
 		self.alice_cfg = Config({
 		self.alice_cfg = Config({
 			'coin': 'XMR',
 			'coin': 'XMR',
 			'outdir': self.users['alice'].udir,
 			'outdir': self.users['alice'].udir,
-			'wallet_dir': self.users['alice'].udir,
 			'wallet_rpc_password': 'passwOrd',
 			'wallet_rpc_password': 'passwOrd',
 			'test_suite': True,
 			'test_suite': True,
-		})
+		} | ({
+			'alice': True,
+			'compat': True
+		} if self.compat else {
+			'wallet_dir': self.users['alice'].udir
+		}))
 
 
 		self.burn_addr = make_burn_addr(cfg)
 		self.burn_addr = make_burn_addr(cfg)
 
 
@@ -178,7 +183,7 @@ class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded):
 		t = self.spawn(
 		t = self.spawn(
 			'mmgen-xmrwallet',
 			'mmgen-xmrwallet',
 			self.extra_opts
 			self.extra_opts
-			+ [f'--wallet-dir={data.udir}']
+			+ (['--alice', '--compat'] if self.compat else [f'--wallet-dir={data.udir}'])
 			+ [f'--daemon=localhost:{data.md.rpc_port}']
 			+ [f'--daemon=localhost:{data.md.rpc_port}']
 			+ (self.autosign_opts if autosign else [])
 			+ (self.autosign_opts if autosign else [])
 			+ ['dump']
 			+ ['dump']
@@ -191,8 +196,9 @@ class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded):
 	def _delete_files(self, *ext_list):
 	def _delete_files(self, *ext_list):
 		data = self.users['alice']
 		data = self.users['alice']
 		self.spawn(msg_only=True)
 		self.spawn(msg_only=True)
+		wdir = data.wd.wallet_dir if self.compat else data.udir
 		for ext in ext_list:
 		for ext in ext_list:
-			get_file_with_ext(data.udir, ext, no_dot=True, delete_all=True)
+			get_file_with_ext(wdir, ext, no_dot=True, delete_all=True)
 		return 'ok'
 		return 'ok'
 
 
 	def delete_tmp_wallets(self):
 	def delete_tmp_wallets(self):
@@ -312,7 +318,7 @@ class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded):
 		args = (
 		args = (
 			self.extra_opts
 			self.extra_opts
 			+ self.autosign_opts
 			+ self.autosign_opts
-			+ [f'--wallet-dir={data.udir}']
+			+ (['--alice', '--compat'] if self.compat else [f'--wallet-dir={data.udir}'])
 			+ [f'--daemon=localhost:{data.md.rpc_port}']
 			+ [f'--daemon=localhost:{data.md.rpc_port}']
 			+ add_opts
 			+ add_opts
 			+ [op]
 			+ [op]
@@ -472,3 +478,9 @@ class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded):
 
 
 	def listview(self):
 	def listview(self):
 		return self.sync_wallets('alice', op='listview', wallets='2')
 		return self.sync_wallets('alice', op='listview', wallets='2')
+
+class CmdTestXMRAutosignNoCompat(CmdTestXMRAutosign):
+	"""
+	Monero autosigning operations (non-xmrwallet compat mode)
+	"""
+	compat = False

+ 13 - 5
test/cmdtest_d/xmrwallet.py

@@ -72,6 +72,7 @@ class CmdTestXMRWallet(CmdTestBase):
 	)
 	)
 	tx_relay_user = 'bob'
 	tx_relay_user = 'bob'
 	daemon_datadir_base = os.path.join('test', 'daemons', 'xmrtest')
 	daemon_datadir_base = os.path.join('test', 'daemons', 'xmrtest')
+	compat = False
 
 
 	cmd_group = (
 	cmd_group = (
 		('daemon_version',                'checking daemon version'),
 		('daemon_version',                'checking daemon version'),
@@ -183,6 +184,13 @@ class CmdTestXMRWallet(CmdTestBase):
 			udir = os.path.join(tmpdir, user)
 			udir = os.path.join(tmpdir, user)
 			daemon_datadir = os.path.join(self.daemon_datadir_base, user)
 			daemon_datadir = os.path.join(self.daemon_datadir_base, user)
 
 
+			if self.compat:
+				from mmgen.tw.ctl import TwCtl
+				twctl_cls = self.proto.base_proto_subclass(TwCtl, 'tw.ctl')
+				wallet_dir = os.path.join(self.tr.data_dir, user, 'altcoins', 'xmr', twctl_cls.tw_subdir)
+			else:
+				wallet_dir = udir
+
 			md = CoinDaemon(
 			md = CoinDaemon(
 				cfg        = self.cfg,
 				cfg        = self.cfg,
 				proto      = self.proto,
 				proto      = self.proto,
@@ -205,7 +213,7 @@ class CmdTestXMRWallet(CmdTestBase):
 				cfg          = self.cfg,
 				cfg          = self.cfg,
 				proto        = self.proto,
 				proto        = self.proto,
 				test_suite   = True,
 				test_suite   = True,
-				wallet_dir   = udir,
+				wallet_dir   = wallet_dir,
 				user         = 'foo',
 				user         = 'foo',
 				passwd       = 'bar',
 				passwd       = 'bar',
 				port_shift   = shift,
 				port_shift   = shift,
@@ -294,7 +302,7 @@ class CmdTestXMRWallet(CmdTestBase):
 		t = self.spawn(
 		t = self.spawn(
 			'mmgen-xmrwallet',
 			'mmgen-xmrwallet',
 			self.extra_opts
 			self.extra_opts
-			+ [f'--wallet-dir={data.udir}']
+			+ ([f'--{user}', '--compat'] if self.compat else [f'--wallet-dir={data.udir}'])
 			+ (self.autosign_opts if data.autosign else [])
 			+ (self.autosign_opts if data.autosign else [])
 			+ add_opts
 			+ add_opts
 			+ [op]
 			+ [op]
@@ -313,7 +321,7 @@ class CmdTestXMRWallet(CmdTestBase):
 		t = self.spawn(
 		t = self.spawn(
 			'mmgen-xmrwallet',
 			'mmgen-xmrwallet',
 			self.extra_opts
 			self.extra_opts
-			+ [f'--wallet-dir={data.udir}']
+			+ (['--alice', '--compat'] if self.compat else [f'--wallet-dir={data.udir}'])
 			+ [f'--daemon=localhost:{data.md.rpc_port}']
 			+ [f'--daemon=localhost:{data.md.rpc_port}']
 			+ (['--no-start-wallet-daemon'] if cfg in ('continue', 'stop') else [])
 			+ (['--no-start-wallet-daemon'] if cfg in ('continue', 'stop') else [])
 			+ (['--no-stop-wallet-daemon'] if cfg in ('start', 'continue') else [])
 			+ (['--no-stop-wallet-daemon'] if cfg in ('start', 'continue') else [])
@@ -415,7 +423,7 @@ class CmdTestXMRWallet(CmdTestBase):
 		t = self.spawn(
 		t = self.spawn(
 			'mmgen-xmrwallet',
 			'mmgen-xmrwallet',
 			self.extra_opts
 			self.extra_opts
-			+ [f'--wallet-dir={data.udir}']
+			+ ([f'--{user}', '--compat'] if self.compat else [f'--wallet-dir={data.udir}'])
 			+ [f'--daemon=localhost:{data.md.rpc_port}']
 			+ [f'--daemon=localhost:{data.md.rpc_port}']
 			+ (self.autosign_opts if data.autosign else [])
 			+ (self.autosign_opts if data.autosign else [])
 			+ add_opts
 			+ add_opts
@@ -466,7 +474,7 @@ class CmdTestXMRWallet(CmdTestBase):
 		t = self.spawn(
 		t = self.spawn(
 			'mmgen-xmrwallet',
 			'mmgen-xmrwallet',
 			self.extra_opts
 			self.extra_opts
-			+ [f'--wallet-dir={data.udir}']
+			+ ([f'--{user}', '--compat'] if self.compat else [f'--wallet-dir={data.udir}'])
 			+ cmd_opts
 			+ cmd_opts
 			+ add_opts
 			+ add_opts
 			+ (self.autosign_opts if data.autosign else [])
 			+ (self.autosign_opts if data.autosign else [])

+ 2 - 0
test/test-release.d/cfg.sh

@@ -295,7 +295,9 @@ init_tests() {
 	d_xmr="Monero xmrwallet operations"
 	d_xmr="Monero xmrwallet operations"
 	t_xmr="
 	t_xmr="
 		- $xmr_env1$xmr_env2$xmr_env3$cmdtest_py --coin=xmr --exclude help
 		- $xmr_env1$xmr_env2$xmr_env3$cmdtest_py --coin=xmr --exclude help
+		s $xmr_env1$xmr_env2$xmr_env3$cmdtest_py --coin=xmr xmr_autosign_nocompat
 	"
 	"
+	[ "$FAST" ]  && t_xmr_skip='s'
 
 
 	d_tool2="'mmgen-tool' utility with data check"
 	d_tool2="'mmgen-tool' utility with data check"
 	t_tool2="
 	t_tool2="