@@ -14,23 +14,27 @@ def pak_to_option(pak):
1414# 'reject' and finally to pak2. There are 5 nodes each with different
1515# configurations
1616# All nodes validate pegouts but the first one
17- args = [[ "-acceptnonstdtxn=1" ]] + [[ "-acceptnonstdtxn=0" , "-enforce_pak=1" ]] * 4
18- # The node at index 0 doesn't validate pegouts
17+
18+ # The node at index 0 doesn't validate pegouts, just normal standardness
1919i_novalidate = 0
2020# The node at index 1 has no paklist in config
2121i_undefined = 1
2222# Paklist 1 in config
2323i_pak1 = 2
24- pak1 = [("02fcba7ecf41bc7e1be4ee122d9d22e3333671eb0a3a87b5cdf099d59874e1940f" , "02a28b3078b6fe9d2b0f098ffb491b8e98a7fe56ebe321ba52f90becdd06507bbf" ),
25- ("02101bed11081c19b25e02dd618da53af1ba29849bbe4006fb3d6e2d3b0d874405" , "02c9cf4bdef23d38e6c9ae73b83001711debea113573cfbe0fb729ff81638549da" )]
2624# Paklist 2 in config
2725i_pak2 = 3
28- pak2 = [("03767a74373b7207c5ae1214295197a88ec2abdf92e9e2a29daf024c322fae9fcb" , "033e4740d0ba639e28963f3476157b7cf2fb7c6fdf4254f97099cf8670b505ea59" ),
29- ("02f4a7445f9c48ee8590a930d3fc4f0f5763e3d1d003fdf5fc822e7ba18f380632" , "036b3786f029751ada9f02f519a86c7e02fb2963a7013e7e668eb5f7ec069b9e7e" )]
3026# Reject in config
3127i_reject = 4
32- args [i_reject ] = args [i_reject ] + ['-pak=reject' ]
3328
29+ # The two conflicting pak lists
30+ pak1 = [("02fcba7ecf41bc7e1be4ee122d9d22e3333671eb0a3a87b5cdf099d59874e1940f" , "02a28b3078b6fe9d2b0f098ffb491b8e98a7fe56ebe321ba52f90becdd06507bbf" ),
31+ ("02101bed11081c19b25e02dd618da53af1ba29849bbe4006fb3d6e2d3b0d874405" , "02c9cf4bdef23d38e6c9ae73b83001711debea113573cfbe0fb729ff81638549da" )]
32+ pak2 = [("03767a74373b7207c5ae1214295197a88ec2abdf92e9e2a29daf024c322fae9fcb" , "033e4740d0ba639e28963f3476157b7cf2fb7c6fdf4254f97099cf8670b505ea59" ),
33+ ("02f4a7445f9c48ee8590a930d3fc4f0f5763e3d1d003fdf5fc822e7ba18f380632" , "036b3786f029751ada9f02f519a86c7e02fb2963a7013e7e668eb5f7ec069b9e7e" )]
34+
35+ # Args that will be re-used in slightly different ways across runs
36+ args = [["-acceptnonstdtxn=0" ]] + [["-acceptnonstdtxn=0" , "-enforce_pak=1" ]]* 4
37+ args [i_reject ] = args [i_reject ] + ['-pak=reject' ]
3438# Novalidate has pak entry, should not act on it ever
3539args [i_novalidate ] = args [i_novalidate ] + pak_to_option (pak1 )
3640
@@ -54,11 +58,11 @@ class CTTest (BitcoinTestFramework):
5458# self.is_network_split=False
5559# self.sync_all()
5660
57- def setup_network (self , split = False ):
58- extra_args = copy .deepcopy (args )
59- extra_args [i_pak1 ] = extra_args [i_pak1 ] + pak_to_option (pak1 )
60- extra_args [i_pak2 ] = extra_args [i_pak2 ] + pak_to_option (pak2 )
61- self ._setup_network (extra_args , split )
61+ # def setup_network(self, split=False):
62+ # extra_args = copy.deepcopy(args)
63+ # extra_args[i_pak1] = extra_args[i_pak1] + pak_to_option(pak1)
64+ # extra_args[i_pak2] = extra_args[i_pak2] + pak_to_option(pak2)
65+ # self._setup_network(extra_args, split)
6266
6367 # Set up blockchain such that all coins belong to node i_undefined
6468# def _setup_initial_state(self):
@@ -75,6 +79,12 @@ def setup_network(self, split=False):
7579# assert("bitcoin" not in self.nodes[4].getbalance())
7680
7781 def set_test_params (self ):
82+ self .num_nodes = 5
83+ self .setup_clean_chain = True
84+ self .extra_args = copy .deepcopy (args )
85+ self .extra_args [i_pak1 ] = self .extra_args [i_pak1 ] + pak_to_option (pak1 )
86+ self .extra_args [i_pak2 ] = self .extra_args [i_pak2 ] + pak_to_option (pak2 )
87+
7888
7989 def run_test (self ):
8090 self ._setup_initial_state ()
@@ -212,14 +222,15 @@ def compare(actual, expected):
212222
213223 # PAK transition: reject -> pak2
214224 # Restart nodes while putting pak2 in i_pak1's config instead of pak1.
215- stop_nodes ( self .nodes )
225+ self .stop_nodes ( )
216226 extra_args = copy .deepcopy (args )
217227 extra_args [i_pak1 ] = extra_args [i_pak1 ] + pak_to_option (pak2 )
218228 extra_args [i_pak2 ] = extra_args [i_pak2 ] + pak_to_option (pak2 )
219229 # Also test novalidate behaves correctly when set to reject after removing
220230 # the two pak entries
221231 extra_args [i_novalidate ] = extra_args [i_novalidate ][:- 2 ] + ['-pak=reject' ]
222- self ._setup_network (extra_args , False )
232+ self .start_nodes (extra_args )
233+
223234 # Check current state of i_pak1
224235 test_pak (self .nodes [i_pak1 ], pak2 , "reject" , True )
225236 # Create a new block with i_pak1 which should have a commitment to pak2
@@ -229,6 +240,7 @@ def compare(actual, expected):
229240 assert_equal (self .nodes [i_undefined ].testproposedblock (block_proposal ), None )
230241 assert_equal (self .nodes [i_pak1 ].testproposedblock (block_proposal ), None )
231242 assert_equal (self .nodes [i_pak2 ].testproposedblock (block_proposal ), None )
243+ assert_raises_rpc_error ()
232244 try :
233245 assert_equal (self .nodes [i_reject ].testproposedblock (block_proposal ), None )
234246 except JSONRPCException as e :
@@ -361,7 +373,5 @@ def compare(actual, expected):
361373 assert_equal ("bitcoin_xpub is invalid for this network" in errorString , True )
362374 errorString = ""
363375
364- # TODO add manual peg-out checks
365-
366376if __name__ == '__main__' :
367377 CTTest ().main ()
0 commit comments