tests: Ensure sorted/multi_a descriptors always generate different addrs #24490

pull achow101 wants to merge 1 commits into bitcoin:master from achow101:fix-wallet-tr-unique-descs changing 1 files +3 −3
  1. achow101 commented at 11:01 am on March 7, 2022: member

    Sometimes the multi_a and sortedmulti_a descriptors will produce some of the same addresses in the tests. This causes the wallets to start generating addresses at a different index as they detect that one of the addresses is used. This subsequently causes a test failure.

    To avoid this problem, use descriptors that will produce unique addresses by putting one of the multi_a in a different branch.

  2. achow101 force-pushed on Mar 7, 2022
  3. achow101 force-pushed on Mar 7, 2022
  4. tests: Ensure sorted/multi_a descriptors always generate different addrs
    Sometimes the multi_a and sortedmulti_a descriptors will produce some of
    the same addresses in the tests. This causes the wallets to start
    generating addresses at a different index as they detect that one of
    the addresses is used. This subsequently causes a test failure.
    
    To avoid this problem, use descriptors that will produce unique
    addresses by putting one of the multi_a in a different branch.
    db27ac9354
  5. achow101 force-pushed on Mar 7, 2022
  6. theStack commented at 11:37 am on March 7, 2022: member
    Concept ACK
  7. fanquake added the label Tests on Mar 7, 2022
  8. theStack approved
  9. theStack commented at 1:19 pm on March 7, 2022: member

    Tested ACK db27ac935480aeec40a1cfc9d5f10a48be55d61b

    On master, generating the same addresses causing the problem described in the OP can be reproduced with the following patch (determined in the course of investigating the CI failure #24486 (comment), unrelated to the linked PR):

     0diff --git a/test/functional/wallet_taproot.py b/test/functional/wallet_taproot.py
     1index 54c992852..5443f815a 100755
     2--- a/test/functional/wallet_taproot.py
     3+++ b/test/functional/wallet_taproot.py
     4@@ -333,6 +333,10 @@ class WalletTaprootTest(BitcoinTestFramework):
     5     def do_test(self, comment, pattern, privmap, treefn):
     6         nkeys = len(privmap)
     7         keys = self.rand_keys(nkeys * 4)
     8+
     9+        if nkeys == 2:  # these keys will result in same addresses for sorted_a/multi_a descriptors
    10+            keys = [KEYS[i] for i in [11, 6, 0, 1, 2, 3, 4, 5]]
    11+
    12         self.do_test_addr(comment, pattern, privmap, treefn, keys[0:nkeys])
    13         self.do_test_sendtoaddress(comment, pattern, privmap, treefn, keys[0:nkeys], keys[nkeys:2*nkeys])
    14         self.do_test_psbt(comment, pattern, privmap, treefn, keys[2*nkeys:3*nkeys], keys[3*nkeys:4*nkeys])
    
     0.....
     12022-03-07T13:12:18.658000Z TestFramework (INFO): Testing tr(H,multi_a(1,XPUB,XPRV)) address derivation
     22022-03-07T13:12:18.914000Z TestFramework (ERROR): Assertion failed
     3Traceback (most recent call last):
     4  File "/home/honey/bitcoin/test/functional/test_framework/test_framework.py", line 132, in main
     5    self.run_test()
     6  File "./test/functional/wallet_taproot.py", line 435, in run_test
     7    self.do_test(
     8  File "./test/functional/wallet_taproot.py", line 340, in do_test
     9    self.do_test_addr(comment, pattern, privmap, treefn, keys[0:nkeys])
    10  File "./test/functional/wallet_taproot.py", line 251, in do_test_addr
    11    assert_equal(addr_g, addr_r)
    12  File "/home/honey/bitcoin/test/functional/test_framework/util.py", line 51, in assert_equal
    13    raise AssertionError("not(%s)" % " == ".join(str(arg) for arg in (thing1, thing2) + args))
    14AssertionError: not(bcrt1px3pnh5n8npeqr3cv0aq6dvqpcsujrgksfd6hup8dpa62z3m9jf9s3sk3ve == bcrt1pn2xq83tt55vfsxtwhkx96sanchkjzwg6yqxuewvn6emkfyqnyp0qe5cteg)
    152022-03-07T13:12:18.987000Z TestFramework (INFO): Stopping nodes
    16
    17.....
    

    Running the PR branch with this patch succeeds.

  10. ajtowns commented at 5:30 pm on March 7, 2022: member

    ACK db27ac935480aeec40a1cfc9d5f10a48be55d61b

    100 runs with no more failures and explanation makes sense

  11. fanquake requested review from instagibbs on Mar 7, 2022
  12. MarcoFalke merged this on Mar 9, 2022
  13. MarcoFalke closed this on Mar 9, 2022

  14. sidhujag referenced this in commit 0d66767abc on Mar 9, 2022
  15. DrahtBot locked this on Mar 9, 2023


achow101 theStack ajtowns


instagibbs

Labels
Tests


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-21 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me