test: use `MiniWallet` in `test/functional/interface_zmq` #24653

pull josibake wants to merge 2 commits into bitcoin:master from josibake:josibake-make-interfaces-zmq-test-use-miniwallet changing 1 files +138 −140
  1. josibake commented at 4:02 PM on March 23, 2022: member

    While working on #24584 , interface_zmq started failing due to coin selection not running deterministically. The test doesn't actually need the wallet, so this PR migrates it to use MiniWallet

    Note for reviewers: the second commit moves large chunks of code out of an if block, so it may be helpful to review with something that ignores whitespace, e.g git diff -w master

  2. fanquake added the label Tests on Mar 23, 2022
  3. josibake force-pushed on Mar 23, 2022
  4. in test/functional/interface_zmq.py:407 in a156633623 outdated
     489 | +        add_witness_commitment(block)
     490 | +        block.solve()
     491 | +        assert_equal(self.nodes[0].submitblock(block.serialize().hex()), None)
     492 | +        tip = self.nodes[0].getbestblockhash()
     493 | +        assert_equal(int(tip, 16), block.sha256)
     494 | +        orig_tx_2 = self.wallet.send_self_transfer(from_node=self.nodes[0])
    


    maflcko commented at 4:15 PM on March 23, 2022:

    I think you can just assign to orig_txid_2 to minimize the diff (also elsewhere)


    josibake commented at 4:44 PM on March 23, 2022:

    fixed! in the other cases where i reassign, i belive its because i need both the txid, wtxid, and tx body. but ill double check


    josibake commented at 5:47 PM on March 23, 2022:

    maflcko commented at 6:10 AM on March 24, 2022:

    I don't think this is fixed?


    josibake commented at 9:39 AM on March 24, 2022:

    where are you still seeing an issue? I renamed orig_tx_2 -> orig_txid_2 and also added payment_txid as a variable to avoid touching lines just to rename payment_txid -> payment_tx['txid']


    maflcko commented at 9:43 AM on March 24, 2022:

    where are you still seeing an issue?

    In GitHub.

    Usually GitHub will display "outdated" if a review comment was addressed.

    You can also check the files tab and use your browsers search feature to see that the orig_tx_2 still exists.


    josibake commented at 9:50 AM on March 24, 2022:

    sorry, you're right! it was fixed in the first commit, but not in the second commit. it's fixed now.

  5. in test/functional/interface_zmq.py:417 in a156633623 outdated
     497 | +        (hash_str, label, mempool_seq) = seq.receive_sequence()
     498 | +        while hash_str != orig_tx['txid']:
     499 | +<<<<<<< HEAD
     500 | +>>>>>>> ec13426c0d (self_transfer)
     501 | +=======
     502 | +>>>>>>> ead059e477 ([move only] remove `is_wallet_compiled` checks)
    


    maflcko commented at 4:15 PM on March 23, 2022:

    ?


    josibake commented at 4:16 PM on March 23, 2022:

    whoops! fixing

  6. josibake force-pushed on Mar 23, 2022
  7. josibake force-pushed on Mar 23, 2022
  8. josibake force-pushed on Mar 23, 2022
  9. theStack commented at 11:10 PM on March 23, 2022: contributor

    Nice, Concept ACK, will review this one soon!

    Some quick findings: Note that there's a typo in the PR title (s/zmg/zmq/), also I'm not sure if "refactor" is really applying here. For the second commit, adding a review suggestion for ignoring whitespace (not tested, but the very popular --color-moved=dimmed-zebra should work) would be probably very helpful for reviewers.

  10. josibake renamed this:
    test, refactor: use `MiniWallet` in `test/functional/interface_zmg`
    test: use `MiniWallet` in `test/functional/interface_zmq`
    on Mar 24, 2022
  11. josibake force-pushed on Mar 24, 2022
  12. test: use MiniWallet in `interfaces_zmq`
    make interfaces_zmg run deterministically.
    this test is for the zmg notifications,
    so it doesn't need the wallet compiled to run
    0bfbf7fb24
  13. [move only] remove `is_wallet_compiled` checks bc90b8d869
  14. maflcko approved
  15. josibake force-pushed on Mar 24, 2022
  16. josibake commented at 10:14 AM on March 24, 2022: member

    Nice, Concept ACK, will review this one soon!

    Some quick findings: Note that there's a typo in the PR title (s/zmg/zmq/), also I'm not sure if "refactor" is really applying here. For the second commit, adding a review suggestion for ignoring whitespace (not tested, but the very popular --color-moved=dimmed-zebra should work) would be probably very helpful for reviewers.

    thanks for the suggestions, @theStack ! I updated the title and also added a note for reviewers. I found that git diff -w master worked best for me

  17. DrahtBot commented at 3:48 PM on March 24, 2022: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #23127 (tests: Use test framework utils where possible by vincenzopalazzo)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  18. vincenzopalazzo approved
  19. maflcko merged this on Mar 24, 2022
  20. maflcko closed this on Mar 24, 2022

  21. in test/functional/interface_zmq.py:455 in bc90b8d869
     451 | @@ -455,10 +452,10 @@ def test_mempool_sync(self):
     452 |  
     453 |          # Some transactions have been happening but we aren't consuming zmq notifications yet
     454 |          # or we lost a ZMQ message somehow and want to start over
     455 | -        txids = []
     456 | +        txs = []
    


    maflcko commented at 7:35 PM on March 24, 2022:

    Unrelated: It looks like this array is unused beside the last value? Could remove it and just assign the last value to a non-array name?


    josibake commented at 11:24 AM on March 25, 2022:

    agreed, was very confused by this array. ended up leaving it alone just to minimize my changes to just MiniWallet


    maflcko commented at 11:54 AM on March 25, 2022:

    Yes, it is good to keep unrelated changes for separate commits and/or follow-ups.

  22. in test/functional/interface_zmq.py:486 in bc90b8d869
     480 | @@ -484,11 +481,12 @@ def test_mempool_sync(self):
     481 |          # Things continue to happen in the "interim" while waiting for snapshot results
     482 |          # We have node 0 do all these to avoid p2p races with RBF announcements
     483 |          for _ in range(num_txs):
     484 | -            txids.append(self.nodes[0].sendtoaddress(address=self.nodes[0].getnewaddress(), amount=0.1, replaceable=True))
     485 | -        self.nodes[0].bumpfee(txids[-1])
     486 | +            txs.append(self.wallet.send_self_transfer(from_node=self.nodes[0]))
     487 | +        txs[-1]['tx'].vout[0].nValue -= 1000
     488 | +        self.nodes[0].sendrawtransaction(txs[-1]['tx'].serialize().hex())
    


    maflcko commented at 7:36 PM on March 24, 2022:

    I recall that you asked on IRC whether it makes sense to introduce a bumpfee method for the wallet. On a second thought, I think it could make sense.

    Currently it looks like send_self_transfer will put an utxo in the wallet which will never exist if the tx is bumped?

    So a helper could drop the utxo(s?) and even add the new ones?


    josibake commented at 12:07 PM on March 25, 2022:

    yep, I think it would be a useful method to have. I'll open a follow-up PR for adding it as a method to MiniWallet

  23. maflcko commented at 7:37 PM on March 24, 2022: member

    Left some thoughts

  24. sidhujag referenced this in commit fad0b37317 on Apr 2, 2022
  25. bitcoin locked this on Mar 25, 2023
  26. josibake deleted the branch on Jan 26, 2024

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: 2026-04-18 12:14 UTC

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