mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-29 21:42:32 +02:00
test: test sendall and send do anti-fee-sniping
This commit is contained in:
parent
8e5778a9fb
commit
fa1fa35158
@ -142,7 +142,12 @@ class WalletSendTest(BitcoinTestFramework):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if locktime:
|
if locktime:
|
||||||
|
assert_equal(from_wallet.gettransaction(txid=res["txid"], verbose=True)["decoded"]["locktime"], locktime)
|
||||||
return res
|
return res
|
||||||
|
else:
|
||||||
|
if add_to_wallet:
|
||||||
|
decoded_tx = from_wallet.gettransaction(txid=res["txid"], verbose=True)["decoded"]
|
||||||
|
assert_greater_than(decoded_tx["locktime"], from_wallet.getblockcount() - 100)
|
||||||
|
|
||||||
if from_wallet.getwalletinfo()["private_keys_enabled"] and not include_watching:
|
if from_wallet.getwalletinfo()["private_keys_enabled"] and not include_watching:
|
||||||
assert_equal(res["complete"], True)
|
assert_equal(res["complete"], True)
|
||||||
|
@ -379,6 +379,18 @@ class SendallTest(BitcoinTestFramework):
|
|||||||
assert_equal(len(self.wallet.listunspent()), 1)
|
assert_equal(len(self.wallet.listunspent()), 1)
|
||||||
assert_equal(self.wallet.listunspent()[0]['confirmations'], 6)
|
assert_equal(self.wallet.listunspent()[0]['confirmations'], 6)
|
||||||
|
|
||||||
|
@cleanup
|
||||||
|
def sendall_anti_fee_sniping(self):
|
||||||
|
self.log.info("Testing sendall does anti-fee-sniping when locktime is not specified")
|
||||||
|
self.add_utxos([10,11])
|
||||||
|
tx_from_wallet = self.test_sendall_success(sendall_args = [self.remainder_target])
|
||||||
|
|
||||||
|
assert_greater_than(tx_from_wallet["decoded"]["locktime"], tx_from_wallet["blockheight"] - 100)
|
||||||
|
|
||||||
|
self.add_utxos([10,11])
|
||||||
|
txid = self.wallet.sendall(recipients=[self.remainder_target], options={"locktime":0})["txid"]
|
||||||
|
assert_equal(self.wallet.gettransaction(txid=txid, verbose=True)["decoded"]["locktime"], 0)
|
||||||
|
|
||||||
# This tests needs to be the last one otherwise @cleanup will fail with "Transaction too large" error
|
# This tests needs to be the last one otherwise @cleanup will fail with "Transaction too large" error
|
||||||
def sendall_fails_with_transaction_too_large(self):
|
def sendall_fails_with_transaction_too_large(self):
|
||||||
self.log.info("Test that sendall fails if resulting transaction is too large")
|
self.log.info("Test that sendall fails if resulting transaction is too large")
|
||||||
@ -460,6 +472,9 @@ class SendallTest(BitcoinTestFramework):
|
|||||||
# Sendall only uses outputs with less than a given number of confirmation when using minconf
|
# Sendall only uses outputs with less than a given number of confirmation when using minconf
|
||||||
self.sendall_with_maxconf()
|
self.sendall_with_maxconf()
|
||||||
|
|
||||||
|
# Sendall discourages fee-sniping when a locktime is not specified
|
||||||
|
self.sendall_anti_fee_sniping()
|
||||||
|
|
||||||
# Sendall fails when many inputs result to too large transaction
|
# Sendall fails when many inputs result to too large transaction
|
||||||
self.sendall_fails_with_transaction_too_large()
|
self.sendall_fails_with_transaction_too_large()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user