Browse Source

tw.unspent: addr grouping bugfix; add twview grouping tests

The MMGen Project 3 years ago
parent
commit
5ebd445957
3 changed files with 36 additions and 5 deletions
  1. 1 1
      mmgen/data/version
  2. 1 1
      mmgen/tw/unspent.py
  3. 34 3
      test/test_py_d/ts_regtest.py

+ 1 - 1
mmgen/data/version

@@ -1 +1 @@
-13.3.dev27
+13.3.dev28

+ 1 - 1
mmgen/tw/unspent.py

@@ -189,7 +189,7 @@ class TwUnspentOutputs(TwView):
 				v = ' ' + d.vout.fmt( width=cw.vout-1, color=color ) if cw.vout else None,
 				a = d.addr.fmtc( '|' + '.'*(cw.addr-1), width=cw.addr, color=color ) if d.skip == 'addr'
 					else d.addr.fmt( width=cw.addr, color=color ),
-				m = (d.twmmid.fmtc( '.'*cw.mmid, color=color ) if d.skip == 'addr'
+				m = (d.twmmid.fmtc( '.'*cw.mmid, width=cw.mmid, color=color ) if d.skip == 'addr'
 					else d.twmmid.fmt( width=cw.mmid, color=color )) if cw.mmid else None,
 				c = d.comment.fmt2( width=cw.comment, color=color, nullrepl='-' ) if cw.comment else None,
 				A = d.amt.fmt( color=color, iwidth=cw.iwidth, prec=self.disp_prec ),

+ 34 - 3
test/test_py_d/ts_regtest.py

@@ -365,6 +365,10 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared):
 		('alice_twview_date_time',        'twview (age_fmt=date_time)'),
 		('alice_txcreate_info',           'txcreate -i'),
 		('alice_txcreate_info_term',      'txcreate -i (pexpect_spawn)'),
+		('bob_send_to_alice_2addr',       'sending a TX to 2 addresses in Alice’s wallet'),
+		('bob_send_to_alice_reuse',       'sending a TX to a used address in Alice’s wallet'),
+		('generate',                      'mining a block'),
+		('alice_twview_grouped',          'twview (testing ‘grouped’ option for TX and address)'),
 	),
 	'auto_chg': (
 		'automatic change address selection',
@@ -1083,9 +1087,10 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared):
 		t.expect('updated successfully')
 		return t
 
-	def _usr_rescan_blockchain(self,user,add_args,expect):
+	def _usr_rescan_blockchain(self,user,add_args,expect=None):
 		t = self.spawn('mmgen-tool',[f'--{user}','rescan_blockchain'] + add_args)
-		t.expect(f'Scanning blocks {expect}')
+		if expect:
+			t.expect(f'Scanning blocks {expect}')
 		t.expect('Done')
 		return t
 
@@ -1502,6 +1507,32 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared):
 			return 'skip'
 		return self.alice_txcreate_info(pexpect_spawn=True)
 
+	# send one TX to 2 addrs in Alice’s wallet - required for alice_twview_grouped()
+	def bob_send_to_alice_2addr(self):
+		outputs_cl = self._create_tx_outputs('alice',[('C',1,',0.02'),('C',2,',0.2')])
+		outputs_cl += [self._user_sid('bob')+':C:5']
+		return self.user_txdo('bob','25s',outputs_cl,'1')
+
+	# send to a used addr in Alice’s wallet - required for alice_twview_grouped()
+	def bob_send_to_alice_reuse(self):
+		outputs_cl = self._create_tx_outputs('alice',[('C',1,',0.2')])
+		outputs_cl += [self._user_sid('bob')+':C:5']
+		return self.user_txdo('bob','25s',outputs_cl,'1')
+
+	def alice_twview_grouped(self):
+		t = self.spawn('mmgen-tool',['--alice','twview','interactive=1'])
+		prompt = 'abel:\b'
+		for s,dots in (
+				('o',False),
+				('M',False),
+				('t',True),
+				('q',True),
+			):
+			if dots:
+				t.expect('........')
+			t.expect(prompt,s)
+		return t
+
 	def bob_msgcreate(self):
 		sid1 = self._user_sid('bob')
 		sid2 = self._get_user_subsid('bob','29L')
@@ -1691,7 +1722,7 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared):
 			expect_str2 =  f'Found {u} unspent outputs in {b} blocks' )
 
 	def carol_rescan_blockchain(self):
-		return self._usr_rescan_blockchain('carol',[],'400-407')
+		return self._usr_rescan_blockchain('carol',[])
 
 	def carol_auto_chg1(self):
 		return self._usr_auto_chg( 'carol', self._user_sid('bob') + ':C' )