diff options
author | glozow <gloriajzhao@gmail.com> | 2024-02-05 14:13:21 +0000 |
---|---|---|
committer | glozow <gloriajzhao@gmail.com> | 2024-02-05 14:16:44 +0000 |
commit | cd3683c21a297cc926ffa11dbb3f0678505582a8 (patch) | |
tree | dff2096e53be738919a3da812e6bef65ebe3052d /test/functional | |
parent | a11585692e72cac468fb1496ea2c30e4c07f73e5 (diff) | |
parent | fa5cd66f0a47d1b759c93d01524ee4558432c0cc (diff) |
Merge bitcoin/bitcoin#29354: test: Assumeutxo with more than just coinbase transactions
fa5cd66f0a47d1b759c93d01524ee4558432c0cc 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 https://github.com/bitcoin/bitcoin/pull/29354/commits/fa5cd66f0a47d1b759c93d01524ee4558432c0cc
glozow:
concept ACK fa5cd66f0a47d1b759c93d01524ee4558432c0cc
Tree-SHA512: e090c41f73490ad72e36c478405bfd0716d46fbf5a131415095999da6503094a86689a179a84addae3562b760df64cdb67488f81692178c8ca8bf771b1e931ff
Diffstat (limited to 'test/functional')
-rwxr-xr-x | test/functional/feature_assumeutxo.py | 26 | ||||
-rwxr-xr-x | test/functional/wallet_assumeutxo.py | 11 |
2 files changed, 24 insertions, 13 deletions
diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py index f26a300f70..528680f2ca 100755 --- a/test/functional/feature_assumeutxo.py +++ b/test/functional/feature_assumeutxo.py @@ -7,7 +7,7 @@ a serialized version of the UTXO set at a certain height, which corresponds to a hash that has been compiled into bitcoind. The assumeutxo value generated and used here is committed to in -`CRegTestParams::m_assumeutxo_data` in `src/chainparams.cpp`. +`CRegTestParams::m_assumeutxo_data` in `src/kernel/chainparams.cpp`. ## Possible test improvements @@ -40,8 +40,10 @@ from test_framework.util import ( assert_equal, assert_raises_rpc_error, ) -from test_framework.wallet import getnewdestination - +from test_framework.wallet import ( + getnewdestination, + MiniWallet, +) START_HEIGHT = 199 SNAPSHOT_BASE_HEIGHT = 299 @@ -98,10 +100,10 @@ class AssumeutxoTest(BitcoinTestFramework): self.log.info(" - snapshot file with alternated UTXO data") cases = [ - [b"\xff" * 32, 0, "05030e506678f2eca8d624ffed97090ab3beadad1b51ee6e5985ba91c5720e37"], # wrong outpoint hash - [(1).to_bytes(4, "little"), 32, "7d29cfe2c1e242bc6f103878bb70cfffa8b4dac20dbd001ff6ce24b7de2d2399"], # wrong outpoint index - [b"\x81", 36, "f03939a195531f96d5dff983e294a1af62af86049fa7a19a7627246f237c03f1"], # wrong coin code VARINT((coinbase ? 1 : 0) | (height << 1)) - [b"\x83", 36, "e4577da84590fb288c0f7967e89575e1b0aa46624669640f6f5dfef028d39930"], # another wrong coin code + [b"\xff" * 32, 0, "7d52155c9a9fdc4525b637ef6170568e5dad6fabd0b1fdbb9432010b8453095b"], # wrong outpoint hash + [(1).to_bytes(4, "little"), 32, "9f4d897031ab8547665b4153317ae2fdbf0130c7840b66427ebc48b881cb80ad"], # wrong outpoint index + [b"\x81", 36, "3da966ba9826fb6d2604260e01607b55ba44e1a5de298606b08704bc62570ea8"], # wrong coin code VARINT((coinbase ? 1 : 0) | (height << 1)) + [b"\x80", 36, "091e893b3ccb4334378709578025356c8bcb0a623f37c7c4e493133c988648e5"], # another wrong coin code ] for content, offset, wrong_hash in cases: @@ -109,7 +111,7 @@ class AssumeutxoTest(BitcoinTestFramework): f.write(valid_snapshot_contents[:(32 + 8 + offset)]) f.write(content) f.write(valid_snapshot_contents[(32 + 8 + offset + len(content)):]) - expected_error(log_msg=f"[snapshot] bad snapshot content hash: expected 61d9c2b29a2571a5fe285fe2d8554f91f93309666fc9b8223ee96338de25ff53, got {wrong_hash}") + expected_error(log_msg=f"[snapshot] bad snapshot content hash: expected a4bf3407ccb2cc0145c49ebba8fa91199f8a3903daf0883875941497d2493c27, got {wrong_hash}") def test_invalid_chainstate_scenarios(self): self.log.info("Test different scenarios of invalid snapshot chainstate in datadir") @@ -145,6 +147,8 @@ class AssumeutxoTest(BitcoinTestFramework): n1 = self.nodes[1] n2 = self.nodes[2] + self.mini_wallet = MiniWallet(n0) + # Mock time for a deterministic chain for n in self.nodes: n.setmocktime(n.getblockheader(n.getbestblockhash())['time']) @@ -157,6 +161,8 @@ class AssumeutxoTest(BitcoinTestFramework): # isn't waiting forever to see the header of the snapshot's base block # while disconnected from n0. for i in range(100): + if i % 3 == 0: + self.mini_wallet.send_self_transfer(from_node=n0) self.generate(n0, nblocks=1, sync_fun=self.no_op) newblock = n0.getblock(n0.getbestblockhash(), 0) @@ -178,8 +184,8 @@ class AssumeutxoTest(BitcoinTestFramework): assert_equal( dump_output['txoutset_hash'], - '61d9c2b29a2571a5fe285fe2d8554f91f93309666fc9b8223ee96338de25ff53') - assert_equal(dump_output['nchaintx'], 300) + "a4bf3407ccb2cc0145c49ebba8fa91199f8a3903daf0883875941497d2493c27") + assert_equal(dump_output["nchaintx"], 334) assert_equal(n0.getblockchaininfo()["blocks"], SNAPSHOT_BASE_HEIGHT) # Mine more blocks on top of the snapshot that n1 hasn't yet seen. This diff --git a/test/functional/wallet_assumeutxo.py b/test/functional/wallet_assumeutxo.py index fce4868293..3c1a997bd1 100755 --- a/test/functional/wallet_assumeutxo.py +++ b/test/functional/wallet_assumeutxo.py @@ -16,6 +16,7 @@ from test_framework.util import ( assert_equal, assert_raises_rpc_error, ) +from test_framework.wallet import MiniWallet START_HEIGHT = 199 SNAPSHOT_BASE_HEIGHT = 299 @@ -55,6 +56,8 @@ class AssumeutxoTest(BitcoinTestFramework): n0 = self.nodes[0] n1 = self.nodes[1] + self.mini_wallet = MiniWallet(n0) + # Mock time for a deterministic chain for n in self.nodes: n.setmocktime(n.getblockheader(n.getbestblockhash())['time']) @@ -69,7 +72,9 @@ class AssumeutxoTest(BitcoinTestFramework): # though, we have to ferry over the new headers to n1 so that it # isn't waiting forever to see the header of the snapshot's base block # while disconnected from n0. - for _ in range(100): + for i in range(100): + if i % 3 == 0: + self.mini_wallet.send_self_transfer(from_node=n0) self.generate(n0, nblocks=1, sync_fun=self.no_op) newblock = n0.getblock(n0.getbestblockhash(), 0) @@ -94,8 +99,8 @@ class AssumeutxoTest(BitcoinTestFramework): assert_equal( dump_output['txoutset_hash'], - '61d9c2b29a2571a5fe285fe2d8554f91f93309666fc9b8223ee96338de25ff53') - assert_equal(dump_output['nchaintx'], 300) + "a4bf3407ccb2cc0145c49ebba8fa91199f8a3903daf0883875941497d2493c27") + assert_equal(dump_output["nchaintx"], 334) assert_equal(n0.getblockchaininfo()["blocks"], SNAPSHOT_BASE_HEIGHT) # Mine more blocks on top of the snapshot that n1 hasn't yet seen. This |