(self)
| 73 | super().setup_network() |
| 74 | |
| 75 | def run_test(self): |
| 76 | if self.is_wallet_compiled(): |
| 77 | # Setup the descriptors to be imported to the wallet |
| 78 | xpriv = ExtendedPrivateKey.generate().to_string() |
| 79 | desc_imports = [{ |
| 80 | "desc": descsum_create(f"wpkh({xpriv}/0/*)"), |
| 81 | "timestamp": 0, |
| 82 | "active": True, |
| 83 | "keypool": True, |
| 84 | },{ |
| 85 | "desc": descsum_create(f"wpkh({xpriv}/1/*)"), |
| 86 | "timestamp": 0, |
| 87 | "active": True, |
| 88 | "keypool": True, |
| 89 | "internal": True, |
| 90 | }] |
| 91 | # Make the wallets and import the descriptors |
| 92 | # Ensures that node 0 and node 1 share the same wallet for the conflicting transaction tests below. |
| 93 | for i, name in enumerate(self.wallet_names): |
| 94 | self.nodes[i].createwallet(wallet_name=name, blank=True, load_on_startup=True) |
| 95 | self.nodes[i].importdescriptors(desc_imports) |
| 96 | |
| 97 | self.log.info("test -blocknotify") |
| 98 | block_count = 10 |
| 99 | blocks = self.generatetoaddress(self.nodes[1], block_count, self.nodes[1].getnewaddress() if self.is_wallet_compiled() else ADDRESS_BCRT1_UNSPENDABLE) |
| 100 | |
| 101 | # wait at most 10 seconds for expected number of files before reading the content |
| 102 | self.wait_until(lambda: len(os.listdir(self.blocknotify_dir)) == block_count, timeout=10) |
| 103 | |
| 104 | # directory content should equal the generated blocks hashes |
| 105 | assert_equal(sorted(blocks), sorted(os.listdir(self.blocknotify_dir))) |
| 106 | |
| 107 | if self.is_wallet_compiled(): |
| 108 | self.log.info("test -walletnotify") |
| 109 | # wait at most 10 seconds for expected number of files before reading the content |
| 110 | self.wait_until(lambda: len(os.listdir(self.walletnotify_dir)) == block_count, timeout=10) |
| 111 | |
| 112 | # directory content should equal the generated transaction hashes |
| 113 | tx_details = list(map(lambda t: (t['txid'], t['blockheight'], t['blockhash']), self.nodes[1].listtransactions("*", block_count))) |
| 114 | self.expect_wallet_notify(tx_details) |
| 115 | |
| 116 | self.log.info("test -walletnotify after rescan") |
| 117 | # rescan to force wallet notifications |
| 118 | self.nodes[1].rescanblockchain() |
| 119 | self.wait_until(lambda: len(os.listdir(self.walletnotify_dir)) == block_count, timeout=10) |
| 120 | |
| 121 | self.connect_nodes(0, 1) |
| 122 | |
| 123 | # directory content should equal the generated transaction hashes |
| 124 | tx_details = list(map(lambda t: (t['txid'], t['blockheight'], t['blockhash']), self.nodes[1].listtransactions("*", block_count))) |
| 125 | self.expect_wallet_notify(tx_details) |
| 126 | |
| 127 | # Conflicting transactions tests. |
| 128 | # Generate spends from node 0, and check notifications |
| 129 | # triggered by node 1 |
| 130 | self.log.info("test -walletnotify with conflicting transactions") |
| 131 | self.nodes[0].rescanblockchain() |
| 132 | self.generatetoaddress(self.nodes[0], 100, ADDRESS_BCRT1_UNSPENDABLE) |
nothing calls this directly
no test coverage detected