Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_avoidreuse.py
Show First 20 Lines • Show All 234 Lines • ▼ Show 20 Lines | def test_fund_send_fund_send(self): | ||||
[0] sends 10 BCH to A. | [0] sends 10 BCH to A. | ||||
[1] spends 5 BCH from A. (leaving roughly 5 BCH useable) | [1] spends 5 BCH from A. (leaving roughly 5 BCH useable) | ||||
[0] sends 10 BCH to A again. | [0] sends 10 BCH to A again. | ||||
[1] tries to spend 10 BCH (fails; dirty). | [1] tries to spend 10 BCH (fails; dirty). | ||||
[1] tries to spend 4 BCH (succeeds; change address sufficient) | [1] tries to spend 4 BCH (succeeds; change address sufficient) | ||||
''' | ''' | ||||
self.log.info("Test fund send fund send") | self.log.info("Test fund send fund send") | ||||
fundaddr = self.nodes[1].getnewaddress() | fundaddr = self.nodes[1].getnewaddress(label="", address_type="legacy") | ||||
retaddr = self.nodes[0].getnewaddress() | retaddr = self.nodes[0].getnewaddress() | ||||
self.nodes[0].sendtoaddress(fundaddr, 10) | self.nodes[0].sendtoaddress(fundaddr, 10) | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
self.sync_all() | self.sync_all() | ||||
# listunspent should show 1 single, unused 10 BCH output | # listunspent should show 1 single, unused 10 BCH output | ||||
assert_unspent( | assert_unspent( | ||||
Show All 14 Lines | def test_fund_send_fund_send(self): | ||||
self.nodes[1], | self.nodes[1], | ||||
total_count=1, | total_count=1, | ||||
total_sum=5, | total_sum=5, | ||||
reused_supported=True, | reused_supported=True, | ||||
reused_count=0) | reused_count=0) | ||||
# getbalances should show no used, 5 BCH trusted | # getbalances should show no used, 5 BCH trusted | ||||
assert_balances(self.nodes[1], mine={"used": 0, "trusted": 5}) | assert_balances(self.nodes[1], mine={"used": 0, "trusted": 5}) | ||||
self.nodes[0].sendtoaddress(fundaddr, 10) | # For the second send, we transmute it to a related single-key address | ||||
# to make sure it's also detected as re-use | |||||
# NB: this is not very useful for ABC, but we keep the new variable | |||||
# name for consistency. | |||||
new_fundaddr = fundaddr | |||||
self.nodes[0].sendtoaddress(new_fundaddr, 10) | |||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
self.sync_all() | self.sync_all() | ||||
# listunspent should show 2 total outputs (5, 10 BCH), one unused (5), | # listunspent should show 2 total outputs (5, 10 BCH), one unused (5), | ||||
# one reused (10) | # one reused (10) | ||||
assert_unspent( | assert_unspent( | ||||
self.nodes[1], | self.nodes[1], | ||||
total_count=2, | total_count=2, | ||||
Show All 35 Lines |