Skip to content

Commit cd3683c

Browse files
committed
Merge bitcoin/bitcoin#29354: test: Assumeutxo with more than just coinbase transactions
fa5cd66 test: Assumeutxo with more than just coinbase transactions (MarcoFalke) Pull request description: Currently the AU tests only check that loading a txout set with only coinbase outputs works. Fix that by adding other transactions. ACKs for top commit: jamesob: ACK bitcoin/bitcoin@fa5cd66 glozow: concept ACK fa5cd66 Tree-SHA512: e090c41f73490ad72e36c478405bfd0716d46fbf5a131415095999da6503094a86689a179a84addae3562b760df64cdb67488f81692178c8ca8bf771b1e931ff
2 parents a115856 + fa5cd66 commit cd3683c

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

src/kernel/chainparams.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,9 @@ class CRegTestParams : public CChainParams
501501
{
502502
// For use by test/functional/feature_assumeutxo.py
503503
.height = 299,
504-
.hash_serialized = AssumeutxoHash{uint256S("0x61d9c2b29a2571a5fe285fe2d8554f91f93309666fc9b8223ee96338de25ff53")},
505-
.nChainTx = 300,
506-
.blockhash = uint256S("0x7e0517ef3ea6ecbed9117858e42eedc8eb39e8698a38dcbd1b3962a283233f4c")
504+
.hash_serialized = AssumeutxoHash{uint256S("0xa4bf3407ccb2cc0145c49ebba8fa91199f8a3903daf0883875941497d2493c27")},
505+
.nChainTx = 334,
506+
.blockhash = uint256S("0x3bb7ce5eba0be48939b7a521ac1ba9316afee2c7bada3a0cca24188e6d7d96c0")
507507
},
508508
};
509509

test/functional/feature_assumeutxo.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
to a hash that has been compiled into bitcoind.
88
99
The assumeutxo value generated and used here is committed to in
10-
`CRegTestParams::m_assumeutxo_data` in `src/chainparams.cpp`.
10+
`CRegTestParams::m_assumeutxo_data` in `src/kernel/chainparams.cpp`.
1111
1212
## Possible test improvements
1313
@@ -40,8 +40,10 @@
4040
assert_equal,
4141
assert_raises_rpc_error,
4242
)
43-
from test_framework.wallet import getnewdestination
44-
43+
from test_framework.wallet import (
44+
getnewdestination,
45+
MiniWallet,
46+
)
4547

4648
START_HEIGHT = 199
4749
SNAPSHOT_BASE_HEIGHT = 299
@@ -98,18 +100,18 @@ def expected_error(log_msg="", rpc_details=""):
98100

99101
self.log.info(" - snapshot file with alternated UTXO data")
100102
cases = [
101-
[b"\xff" * 32, 0, "05030e506678f2eca8d624ffed97090ab3beadad1b51ee6e5985ba91c5720e37"], # wrong outpoint hash
102-
[(1).to_bytes(4, "little"), 32, "7d29cfe2c1e242bc6f103878bb70cfffa8b4dac20dbd001ff6ce24b7de2d2399"], # wrong outpoint index
103-
[b"\x81", 36, "f03939a195531f96d5dff983e294a1af62af86049fa7a19a7627246f237c03f1"], # wrong coin code VARINT((coinbase ? 1 : 0) | (height << 1))
104-
[b"\x83", 36, "e4577da84590fb288c0f7967e89575e1b0aa46624669640f6f5dfef028d39930"], # another wrong coin code
103+
[b"\xff" * 32, 0, "7d52155c9a9fdc4525b637ef6170568e5dad6fabd0b1fdbb9432010b8453095b"], # wrong outpoint hash
104+
[(1).to_bytes(4, "little"), 32, "9f4d897031ab8547665b4153317ae2fdbf0130c7840b66427ebc48b881cb80ad"], # wrong outpoint index
105+
[b"\x81", 36, "3da966ba9826fb6d2604260e01607b55ba44e1a5de298606b08704bc62570ea8"], # wrong coin code VARINT((coinbase ? 1 : 0) | (height << 1))
106+
[b"\x80", 36, "091e893b3ccb4334378709578025356c8bcb0a623f37c7c4e493133c988648e5"], # another wrong coin code
105107
]
106108

107109
for content, offset, wrong_hash in cases:
108110
with open(bad_snapshot_path, "wb") as f:
109111
f.write(valid_snapshot_contents[:(32 + 8 + offset)])
110112
f.write(content)
111113
f.write(valid_snapshot_contents[(32 + 8 + offset + len(content)):])
112-
expected_error(log_msg=f"[snapshot] bad snapshot content hash: expected 61d9c2b29a2571a5fe285fe2d8554f91f93309666fc9b8223ee96338de25ff53, got {wrong_hash}")
114+
expected_error(log_msg=f"[snapshot] bad snapshot content hash: expected a4bf3407ccb2cc0145c49ebba8fa91199f8a3903daf0883875941497d2493c27, got {wrong_hash}")
113115

114116
def test_invalid_chainstate_scenarios(self):
115117
self.log.info("Test different scenarios of invalid snapshot chainstate in datadir")
@@ -145,6 +147,8 @@ def run_test(self):
145147
n1 = self.nodes[1]
146148
n2 = self.nodes[2]
147149

150+
self.mini_wallet = MiniWallet(n0)
151+
148152
# Mock time for a deterministic chain
149153
for n in self.nodes:
150154
n.setmocktime(n.getblockheader(n.getbestblockhash())['time'])
@@ -157,6 +161,8 @@ def run_test(self):
157161
# isn't waiting forever to see the header of the snapshot's base block
158162
# while disconnected from n0.
159163
for i in range(100):
164+
if i % 3 == 0:
165+
self.mini_wallet.send_self_transfer(from_node=n0)
160166
self.generate(n0, nblocks=1, sync_fun=self.no_op)
161167
newblock = n0.getblock(n0.getbestblockhash(), 0)
162168

@@ -178,8 +184,8 @@ def run_test(self):
178184

179185
assert_equal(
180186
dump_output['txoutset_hash'],
181-
'61d9c2b29a2571a5fe285fe2d8554f91f93309666fc9b8223ee96338de25ff53')
182-
assert_equal(dump_output['nchaintx'], 300)
187+
"a4bf3407ccb2cc0145c49ebba8fa91199f8a3903daf0883875941497d2493c27")
188+
assert_equal(dump_output["nchaintx"], 334)
183189
assert_equal(n0.getblockchaininfo()["blocks"], SNAPSHOT_BASE_HEIGHT)
184190

185191
# Mine more blocks on top of the snapshot that n1 hasn't yet seen. This

test/functional/wallet_assumeutxo.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
assert_equal,
1717
assert_raises_rpc_error,
1818
)
19+
from test_framework.wallet import MiniWallet
1920

2021
START_HEIGHT = 199
2122
SNAPSHOT_BASE_HEIGHT = 299
@@ -55,6 +56,8 @@ def run_test(self):
5556
n0 = self.nodes[0]
5657
n1 = self.nodes[1]
5758

59+
self.mini_wallet = MiniWallet(n0)
60+
5861
# Mock time for a deterministic chain
5962
for n in self.nodes:
6063
n.setmocktime(n.getblockheader(n.getbestblockhash())['time'])
@@ -69,7 +72,9 @@ def run_test(self):
6972
# though, we have to ferry over the new headers to n1 so that it
7073
# isn't waiting forever to see the header of the snapshot's base block
7174
# while disconnected from n0.
72-
for _ in range(100):
75+
for i in range(100):
76+
if i % 3 == 0:
77+
self.mini_wallet.send_self_transfer(from_node=n0)
7378
self.generate(n0, nblocks=1, sync_fun=self.no_op)
7479
newblock = n0.getblock(n0.getbestblockhash(), 0)
7580

@@ -94,8 +99,8 @@ def run_test(self):
9499

95100
assert_equal(
96101
dump_output['txoutset_hash'],
97-
'61d9c2b29a2571a5fe285fe2d8554f91f93309666fc9b8223ee96338de25ff53')
98-
assert_equal(dump_output['nchaintx'], 300)
102+
"a4bf3407ccb2cc0145c49ebba8fa91199f8a3903daf0883875941497d2493c27")
103+
assert_equal(dump_output["nchaintx"], 334)
99104
assert_equal(n0.getblockchaininfo()["blocks"], SNAPSHOT_BASE_HEIGHT)
100105

101106
# Mine more blocks on top of the snapshot that n1 hasn't yet seen. This

0 commit comments

Comments
 (0)