diff --git a/test/functional/feature_remote_staking.py b/test/functional/feature_remote_staking.py index 8d0529b6b2..cb7158776d 100755 --- a/test/functional/feature_remote_staking.py +++ b/test/functional/feature_remote_staking.py @@ -14,9 +14,7 @@ P2PInterface, sha256, ) -from test_framework.regtest_mnemonics import ( - regtest_mnemonics, -) +from test_framework.regtest_mnemonics import regtest_mnemonics from test_framework.script import ( CScript, OP_2, @@ -66,7 +64,7 @@ def build_block_with_remote_stake(node): stakes = node.liststakeablecoins() coin = stakes['stakeable_coins'][0]['coin'] - pubkey = hex_str_to_bytes(coin['script_pub_key']['hex']) + script_pubkey = hex_str_to_bytes(coin['script_pub_key']['hex']) stake = { 'txid': coin['out_point']['txid'], 'vout': coin['out_point']['n'], @@ -78,7 +76,7 @@ def build_block_with_remote_stake(node): node.getbestblockhash())['time'] + 1 coinbase = sign_coinbase( node, create_coinbase( - height, stake, snapshot_meta.hash, raw_script_pubkey=pubkey)) + height, stake, snapshot_meta.hash, raw_script_pubkey=script_pubkey)) return create_block(tip, coinbase, block_time) @@ -124,7 +122,6 @@ def run_test(self): self.sync_all() # Estimate Alice balance - # Fee is the sum of two transactions - p2wpkh and p2wsh tx1_fee = alice.gettransaction(tx1_hash)['fee'] tx2_fee = alice.gettransaction(tx2_hash)['fee'] alice_balance = regtest_mnemonics[0]['balance'] + tx1_fee + tx2_fee @@ -144,8 +141,7 @@ def bob_is_staking_the_new_coin(): self.sync_all() # Reward from the Bob's block comes to remote staking balance of Alice - # But stake output from the Bob's block must be ignored - # Actual spendable balance shouldn't change + # Actual spendable balance shouldn't change because the reward is not yet mature wi = alice.getwalletinfo() assert_equal(wi['remote_staking_balance'], 2 + PROPOSER_REWARD) assert_equal(wi['balance'], alice_balance) @@ -154,7 +150,7 @@ def bob_is_staking_the_new_coin(): assert_equal(len(alice.listunspent()), 2 + (regtest_mnemonics[0]['balance'] // STAKE_SPLIT_THRESHOLD)) - # Spend coins, given to remote stake + # Chech that Alice can spend remotely staked coins inputs = [] for coin in bob.liststakeablecoins()['stakeable_coins']: out_point = coin['coin']['out_point'] diff --git a/test/functional/test_framework/blocktools.py b/test/functional/test_framework/blocktools.py index 08a96a9141..b880535ca3 100644 --- a/test/functional/test_framework/blocktools.py +++ b/test/functional/test_framework/blocktools.py @@ -69,7 +69,7 @@ def serialize_script_num(value): # If pubkey is passed in, the coinbase outputs will be P2PK outputs; # otherwise anyone-can-spend outputs. The first output is the reward, # which is not spendable for COINBASE_MATURITY blocks. -def create_coinbase(height, stake, snapshot_hash, pubkey = None, raw_script_pubkey = None, n_pieces = 1): +def create_coinbase(height, stake, snapshot_hash, pubkey=None, raw_script_pubkey=None, n_pieces = 1): assert n_pieces > 0 stake_in = COutPoint(int(stake['txid'], 16), stake['vout']) coinbase = CTransaction() @@ -81,7 +81,7 @@ def create_coinbase(height, stake, snapshot_hash, pubkey = None, raw_script_pubk output_script = None if (pubkey != None): output_script = CScript([pubkey, OP_CHECKSIG]) - elif (raw_script_pubkey != None): + elif raw_script_pubkey is not None: output_script = CScript(raw_script_pubkey) else: output_script = CScript([OP_TRUE])