(self)
| 1899 | |
| 1900 | |
| 1901 | def run_test(self): |
| 1902 | util.node_fastmerkle = self.nodes[0] |
| 1903 | |
| 1904 | global g_genesis_hash |
| 1905 | g_genesis_hash = uint256_from_str(bytes.fromhex(self.nodes[1].getblockhash(0))[::-1]) |
| 1906 | |
| 1907 | self.gen_test_vectors() |
| 1908 | |
| 1909 | # Post-taproot activation tests go first (pre-taproot tests' blocks are invalid post-taproot). |
| 1910 | self.log.info("Post-activation tests...") |
| 1911 | |
| 1912 | self.test_spenders(self.nodes[1], spenders_taproot_active(), input_counts=[1, 2, 2, 2, 2, 3]) |
| 1913 | |
| 1914 | # Re-connect nodes in case they have been disconnected |
| 1915 | self.disconnect_nodes(0, 1) |
| 1916 | self.connect_nodes(0, 1) |
| 1917 | |
| 1918 | # Transfer value of the largest 500 coins to pre-taproot node. |
| 1919 | addr = self.nodes[0].getnewaddress() |
| 1920 | |
| 1921 | unsp = self.nodes[1].listunspent() |
| 1922 | unsp = sorted(unsp, key=lambda i: i['amount'], reverse=True) |
| 1923 | unsp = unsp[:500] |
| 1924 | |
| 1925 | rawtx = self.nodes[1].createrawtransaction( |
| 1926 | inputs=[{ |
| 1927 | 'txid': i['txid'], |
| 1928 | 'vout': i['vout'] |
| 1929 | } for i in unsp], |
| 1930 | outputs=[{addr: sum(i['amount'] for i in unsp)}] |
| 1931 | ) |
| 1932 | rawtx = self.nodes[1].signrawtransactionwithwallet(rawtx)['hex'] |
| 1933 | |
| 1934 | # Mine a block with the transaction |
| 1935 | block = create_block(tmpl=self.nodes[1].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS), txlist=[rawtx]) |
| 1936 | add_witness_commitment(block) |
| 1937 | block.solve() |
| 1938 | assert_equal(None, self.nodes[1].submitblock(block.serialize().hex())) |
| 1939 | self.sync_blocks() |
| 1940 | |
| 1941 | # Pre-taproot activation tests. |
| 1942 | self.log.info("Pre-activation tests...") |
| 1943 | # Run each test twice; once in isolation, and once combined with others. Testing in isolation |
| 1944 | # means that the standardness is verified in every test (as combined transactions are only standard |
| 1945 | # when all their inputs are standard). |
| 1946 | self.test_spenders(self.nodes[0], spenders_taproot_inactive(), input_counts=[1]) |
| 1947 | self.test_spenders(self.nodes[0], spenders_taproot_inactive(), input_counts=[2, 3]) |
| 1948 | |
| 1949 | |
| 1950 | if __name__ == '__main__': |
nothing calls this directly
no test coverage detected