Skip to content

Commit

Permalink
Fix nits
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Saveliev <dima@thirdhash.com>
  • Loading branch information
dsaveliev committed Apr 17, 2019
1 parent b9058ad commit 316e45d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
14 changes: 5 additions & 9 deletions test/functional/feature_remote_staking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'],
Expand All @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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']
Expand Down
4 changes: 2 additions & 2 deletions test/functional/test_framework/blocktools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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])
Expand Down

0 comments on commit 316e45d

Please sign in to comment.