python functional wallet tests fixed; p2p-segwit only test not fixed
This commit is contained in:
parent
f4c1ef6a5b
commit
60f8d26a9b
@ -33,7 +33,7 @@ class WalletAccountsTest(BitcoinTestFramework):
|
||||
# the same address, so we call twice to get two addresses w/50 each
|
||||
node.generate(1)
|
||||
node.generate(101)
|
||||
assert_equal(node.getbalance(), 100)
|
||||
assert_equal(node.getbalance(), 200)
|
||||
|
||||
# there should be 2 address groups
|
||||
# each with 1 address with a balance of 50 Bitcoins
|
||||
@ -45,7 +45,7 @@ class WalletAccountsTest(BitcoinTestFramework):
|
||||
for address_group in address_groups:
|
||||
assert_equal(len(address_group), 1)
|
||||
assert_equal(len(address_group[0]), 2)
|
||||
assert_equal(address_group[0][1], 50)
|
||||
assert_equal(address_group[0][1], 100)
|
||||
linked_addresses.add(address_group[0][0])
|
||||
|
||||
# send 50 from each address to a third address not in this wallet
|
||||
@ -54,7 +54,7 @@ class WalletAccountsTest(BitcoinTestFramework):
|
||||
common_address = "msf4WtN1YQKXvNtvdFYt9JBnUD2FB41kjr"
|
||||
txid = node.sendmany(
|
||||
fromaccount="",
|
||||
amounts={common_address: 100},
|
||||
amounts={common_address: 200},
|
||||
subtractfeefrom=[common_address],
|
||||
minconf=1,
|
||||
)
|
||||
@ -105,13 +105,13 @@ class WalletAccountsTest(BitcoinTestFramework):
|
||||
|
||||
node.generate(101)
|
||||
|
||||
expected_account_balances = {"": 5200}
|
||||
expected_account_balances = {"": 10400}
|
||||
for account in accounts:
|
||||
expected_account_balances[account] = 0
|
||||
|
||||
assert_equal(node.listaccounts(), expected_account_balances)
|
||||
|
||||
assert_equal(node.getbalance(""), 5200)
|
||||
assert_equal(node.getbalance(""), 10400)
|
||||
|
||||
for account in accounts:
|
||||
address = node.getaccountaddress("")
|
||||
|
||||
@ -11,6 +11,8 @@ class WalletTest(BitcoinTestFramework):
|
||||
def check_fee_amount(self, curr_balance, balance_with_fee, fee_per_byte, tx_size):
|
||||
"""Return curr_balance after asserting the fee was in range"""
|
||||
fee = balance_with_fee - curr_balance
|
||||
|
||||
# print("check_fee_amount curr_balance: "+str(curr_balance)+"\tbalance_with_fee: "+str(balance_with_fee)+"\tfee_per_byte: "+str(fee_per_byte)+"\ttx_size: "+str(tx_size))
|
||||
assert_fee_amount(fee, tx_size, fee_per_byte * 1000)
|
||||
return curr_balance
|
||||
|
||||
@ -39,15 +41,15 @@ class WalletTest(BitcoinTestFramework):
|
||||
self.nodes[0].generate(1)
|
||||
|
||||
walletinfo = self.nodes[0].getwalletinfo()
|
||||
assert_equal(walletinfo['immature_balance'], 50)
|
||||
assert_equal(walletinfo['immature_balance'], 100)
|
||||
assert_equal(walletinfo['balance'], 0)
|
||||
|
||||
self.sync_all()
|
||||
self.nodes[1].generate(101)
|
||||
self.sync_all()
|
||||
|
||||
assert_equal(self.nodes[0].getbalance(), 50)
|
||||
assert_equal(self.nodes[1].getbalance(), 50)
|
||||
assert_equal(self.nodes[0].getbalance(), 100)
|
||||
assert_equal(self.nodes[1].getbalance(), 100)
|
||||
assert_equal(self.nodes[2].getbalance(), 0)
|
||||
|
||||
# Check that only first and second nodes have UTXOs
|
||||
@ -70,7 +72,7 @@ class WalletTest(BitcoinTestFramework):
|
||||
# but invisible if you include mempool
|
||||
confirmed_txid, confirmed_index = utxos[0]["txid"], utxos[0]["vout"]
|
||||
txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, False)
|
||||
assert_equal(txout['value'], 50)
|
||||
assert_equal(txout['value'], 100)
|
||||
txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, True)
|
||||
assert txout is None
|
||||
# new utxo from mempool should be invisible if you exclude mempool
|
||||
@ -103,9 +105,9 @@ class WalletTest(BitcoinTestFramework):
|
||||
self.nodes[1].generate(100)
|
||||
self.sync_all()
|
||||
|
||||
# node0 should end up with 100 btc in block rewards plus fees, but
|
||||
# node0 should end up with 200 flo in block rewards plus fees, but
|
||||
# minus the 21 plus fees sent to node2
|
||||
assert_equal(self.nodes[0].getbalance(), 100-21)
|
||||
assert_equal(self.nodes[0].getbalance(), 200-21)
|
||||
assert_equal(self.nodes[2].getbalance(), 21)
|
||||
|
||||
# Node0 should have two unspent outputs.
|
||||
@ -133,8 +135,8 @@ class WalletTest(BitcoinTestFramework):
|
||||
self.sync_all()
|
||||
|
||||
assert_equal(self.nodes[0].getbalance(), 0)
|
||||
assert_equal(self.nodes[2].getbalance(), 94)
|
||||
assert_equal(self.nodes[2].getbalance("from1"), 94-21)
|
||||
assert_equal(self.nodes[2].getbalance(), 194)
|
||||
assert_equal(self.nodes[2].getbalance("from1"), 194-21)
|
||||
|
||||
# Send 10 BTC normal
|
||||
address = self.nodes[0].getnewaddress("test")
|
||||
@ -143,7 +145,7 @@ class WalletTest(BitcoinTestFramework):
|
||||
txid = self.nodes[2].sendtoaddress(address, 10, "", "", False)
|
||||
self.nodes[2].generate(1)
|
||||
self.sync_all()
|
||||
node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), Decimal('84'), fee_per_byte, count_bytes(self.nodes[2].getrawtransaction(txid)))
|
||||
node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), Decimal('184'), fee_per_byte, count_bytes(self.nodes[2].getrawtransaction(txid)))
|
||||
assert_equal(self.nodes[0].getbalance(), Decimal('10'))
|
||||
|
||||
# Send 10 BTC with subtract fee from amount
|
||||
@ -199,7 +201,7 @@ class WalletTest(BitcoinTestFramework):
|
||||
#4. check if recipient (node0) can list the zero value tx
|
||||
usp = self.nodes[1].listunspent()
|
||||
inputs = [{"txid":usp[0]['txid'], "vout":usp[0]['vout']}]
|
||||
outputs = {self.nodes[1].getnewaddress(): 49.998, self.nodes[0].getnewaddress(): 11.11}
|
||||
outputs = {self.nodes[1].getnewaddress(): 99.998, self.nodes[0].getnewaddress(): 11.11}
|
||||
|
||||
rawTx = self.nodes[1].createrawtransaction(inputs, outputs).replace("c0833842", "00000000") #replace 11.11 with 0.0 (int32)
|
||||
decRawTx = self.nodes[1].decoderawtransaction(rawTx)
|
||||
|
||||
@ -107,9 +107,9 @@ class WalletBackupTest(BitcoinTestFramework):
|
||||
self.nodes[3].generate(100)
|
||||
sync_blocks(self.nodes)
|
||||
|
||||
assert_equal(self.nodes[0].getbalance(), 50)
|
||||
assert_equal(self.nodes[1].getbalance(), 50)
|
||||
assert_equal(self.nodes[2].getbalance(), 50)
|
||||
assert_equal(self.nodes[0].getbalance(), 100)
|
||||
assert_equal(self.nodes[1].getbalance(), 100)
|
||||
assert_equal(self.nodes[2].getbalance(), 100)
|
||||
assert_equal(self.nodes[3].getbalance(), 0)
|
||||
|
||||
self.log.info("Creating transactions")
|
||||
@ -142,7 +142,7 @@ class WalletBackupTest(BitcoinTestFramework):
|
||||
|
||||
# At this point, there are 214 blocks (103 for setup, then 10 rounds, then 101.)
|
||||
# 114 are mature, so the sum of all wallets should be 114 * 50 = 5700.
|
||||
assert_equal(total, 5700)
|
||||
assert_equal(total, 11400)
|
||||
|
||||
##
|
||||
# Test restoring spender wallets from backups
|
||||
|
||||
Loading…
Reference in New Issue
Block a user