mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
pytest: test withdrawal transactions' nLockTime
This commit is contained in:
committed by
ZmnSCPxj, ZmnSCPxj jxPCSmnZ
parent
a589daa235
commit
d2638c99af
@@ -698,3 +698,44 @@ def test_fundchannel_listtransaction(node_factory, bitcoind):
|
||||
|
||||
tx = [t for t in txs if t['hash'] == txid][0]
|
||||
assert tx['blockheight'] == 0
|
||||
|
||||
|
||||
def test_withdraw_nlocktime(node_factory):
|
||||
"""
|
||||
Test that we don't set the nLockTime to 0 for withdrawal transactions.
|
||||
"""
|
||||
l1 = node_factory.get_node(1)
|
||||
l1.fundwallet(10**4)
|
||||
|
||||
addr = l1.rpc.newaddr()["bech32"]
|
||||
tx = l1.rpc.withdraw(addr, 10**3)["tx"]
|
||||
nlocktime = node_factory.bitcoind.rpc.decoderawtransaction(tx)["locktime"]
|
||||
tip = node_factory.bitcoind.rpc.getblockcount()
|
||||
|
||||
assert nlocktime > 0 and nlocktime <= tip
|
||||
|
||||
|
||||
@flaky
|
||||
@unittest.skipIf(VALGRIND, "A big loop is used to check fuzz.")
|
||||
def test_withdraw_nlocktime_fuzz(node_factory, bitcoind):
|
||||
"""
|
||||
Test that we eventually fuzz nLockTime for withdrawal transactions.
|
||||
Marked flaky "just in case" as we fuzz from 0 to 100 with a 10%
|
||||
probability.
|
||||
"""
|
||||
l1 = node_factory.get_node(1)
|
||||
l1.fundwallet(10**8)
|
||||
|
||||
for i in range(100):
|
||||
addr = l1.rpc.newaddr()["bech32"]
|
||||
withdraw = l1.rpc.withdraw(addr, 10**3)
|
||||
bitcoind.generate_block(1)
|
||||
l1.daemon.wait_for_log('Owning output .* txid {} CONFIRMED'.
|
||||
format(withdraw["txid"]))
|
||||
decoded = bitcoind.rpc.decoderawtransaction(withdraw["tx"])
|
||||
tip = node_factory.bitcoind.rpc.getblockcount()
|
||||
assert decoded["locktime"] > 0
|
||||
if decoded["locktime"] < tip:
|
||||
return
|
||||
else:
|
||||
raise Exception("No transaction with fuzzed nLockTime !")
|
||||
|
||||
Reference in New Issue
Block a user