From 8a32340d27ca8d2b3a1a09b26188ba23425278d1 Mon Sep 17 00:00:00 2001 From: Jude Nelson Date: Tue, 23 May 2017 17:21:58 -0400 Subject: [PATCH 1/2] debug withdraw --- blockstack_client/actions.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/blockstack_client/actions.py b/blockstack_client/actions.py index f9c629ba6..bf77ba677 100644 --- a/blockstack_client/actions.py +++ b/blockstack_client/actions.py @@ -474,6 +474,7 @@ def cli_withdraw(args, password=None, interactive=True, wallet_keys=None, config change = 0 if amt is None: # total transfer, minus tx fee + log.debug("No amount given; assuming all ({})".format(total_value - tx_fee)) amt = total_value - tx_fee if amt < 0: log.error("Dust: total value = {}, tx fee = {}".format(total_value, tx_fee)) @@ -481,6 +482,7 @@ def cli_withdraw(args, password=None, interactive=True, wallet_keys=None, config else: change = virtualchain.calculate_change_amount(inputs, amt, tx_fee) + log.debug("Withdraw {}, tx fee {}".format(amt, tx_fee)) outputs = [ {'script': virtualchain.make_payment_script(recipient_addr), @@ -510,6 +512,8 @@ def cli_withdraw(args, password=None, interactive=True, wallet_keys=None, config if tx_only: return {'status': True, 'tx': tx} + log.debug("Withdraw {} from {} to {}".format(amount, send_addr, recipient_addr)) + res = broadcast_tx( tx, config_path=config_path ) return res From 43444f265f5a04ed3ea37647378ae6d04c9db7b6 Mon Sep 17 00:00:00 2001 From: Jude Nelson Date: Tue, 23 May 2017 17:22:06 -0400 Subject: [PATCH 2/2] better debugging of balance and utxos --- .../scenarios/rest_noauth_withdraw.py | 15 ++++++++++----- .../scenarios/testlib.py | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/integration_tests/blockstack_integration_tests/scenarios/rest_noauth_withdraw.py b/integration_tests/blockstack_integration_tests/scenarios/rest_noauth_withdraw.py index 6fc7b2086..a7582fb84 100644 --- a/integration_tests/blockstack_integration_tests/scenarios/rest_noauth_withdraw.py +++ b/integration_tests/blockstack_integration_tests/scenarios/rest_noauth_withdraw.py @@ -124,7 +124,7 @@ def scenario( wallets, **kw ): balance_before = testlib.get_balance(wallets[8].addr) # can we move the funds? - res = testlib.blockstack_REST_call('POST', '/v1/wallet/balance', None, api_pass=api_pass, data={'address': wallets[8].addr, 'amount': wallet_balance - 10000, 'message': "hello world!"}) + res = testlib.blockstack_REST_call('POST', '/v1/wallet/balance', None, api_pass=api_pass, data={'address': wallets[8].addr, 'amount': wallet_balance / 2, 'message': "hello world!"}) if res['http_status'] != 200: res['test'] = 'failed to transfer funds' print json.dumps(res) @@ -138,18 +138,23 @@ def scenario( wallets, **kw ): print "\n\nTransaction: {}\n\n".format(res['response']['transaction_hash']) # confirm it - for i in xrange(0, 10): + for i in xrange(0, 12): testlib.next_block(**kw) new_balance = testlib.get_balance(wallets[5].addr) balance_after = testlib.get_balance(wallets[8].addr) - if new_balance > 10000: + print "wallet balance: {}".format(wallet_balance) + print "new balance {}: {}".format(wallets[5].addr, new_balance) + print "balance after {}: {}".format(wallets[8].addr, balance_after) + print "balance before {}: {}".format(wallets[8].addr, balance_before) + + if new_balance > wallet_balance / 2: print 'new balance of {} is {}'.format(wallets[5].addr, new_balance) return False - if abs(balance_before + wallet_balance - balance_after) > 10000: - print "{} + {} != {}".format(balance_before, wallet_balance, balance_after) + if abs(balance_after - balance_before) > abs(wallet_balance / 2) + 54500: + print "{} - {} != {}".format(balance_after, balance_before, wallet_balance / 2) return False diff --git a/integration_tests/blockstack_integration_tests/scenarios/testlib.py b/integration_tests/blockstack_integration_tests/scenarios/testlib.py index 3ea306822..fe60bf28e 100644 --- a/integration_tests/blockstack_integration_tests/scenarios/testlib.py +++ b/integration_tests/blockstack_integration_tests/scenarios/testlib.py @@ -2426,6 +2426,7 @@ def get_balance( addr ): Get the address balance """ inputs = blockstack_client.backend.blockchain.get_utxos(addr) + log.debug("UTXOS of {} are {}".format(addr, inputs)) return sum([inp['value'] for inp in inputs])