blob: a71cec6607dee35aed278957b7fa898f9d21ba16 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#!/usr/bin/env python3
# Copyright (c) 2022 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
class WalletLocktimeTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
def run_test(self):
node = self.nodes[0]
mtp_tip = node.getblockheader(node.getbestblockhash())["mediantime"]
self.log.info("Get new address with label")
label = "timelock⌛🔓"
address = node.getnewaddress(label=label)
self.log.info("Send to new address with locktime")
node.send(
outputs={address: 5},
options={"locktime": mtp_tip - 1},
)
self.generate(node, 1)
self.log.info("Check that clock cannot change finality of confirmed txs")
amount_before_ad = node.getreceivedbyaddress(address)
amount_before_lb = node.getreceivedbylabel(label)
list_before_ad = node.listreceivedbyaddress(address_filter=address)
list_before_lb = node.listreceivedbylabel(include_empty=False)
balance_before = node.getbalances()["mine"]["trusted"]
coin_before = node.listunspent(maxconf=1)
node.setmocktime(mtp_tip - 1)
assert_equal(node.getreceivedbyaddress(address), amount_before_ad)
assert_equal(node.getreceivedbylabel(label), amount_before_lb)
assert_equal(node.listreceivedbyaddress(address_filter=address), list_before_ad)
assert_equal(node.listreceivedbylabel(include_empty=False), list_before_lb)
assert_equal(node.getbalances()["mine"]["trusted"], balance_before)
assert_equal(node.listunspent(maxconf=1), coin_before)
if __name__ == "__main__":
WalletLocktimeTest().main()
|