|
13 | 13 | from test_framework.address import script_to_p2sh, key_to_p2pkh |
14 | 14 | from test_framework.script import CScript, OP_HASH160, OP_CHECKSIG, OP_0, hash160, OP_EQUAL, OP_DUP, OP_EQUALVERIFY, OP_1, OP_2, OP_CHECKMULTISIG |
15 | 15 | from io import BytesIO |
| 16 | +from test_framework.mininode import FromHex |
16 | 17 |
|
17 | 18 | NODE_0 = 0 |
18 | 19 | NODE_1 = 1 |
@@ -83,8 +84,8 @@ def setup_chain(self): |
83 | 84 |
|
84 | 85 | def setup_network(self): |
85 | 86 | self.nodes = [] |
86 | | - self.nodes.append(start_node(0, self.options.tmpdir, ["-logtimemicros", "-debug", "-walletprematurewitness"])) |
87 | | - self.nodes.append(start_node(1, self.options.tmpdir, ["-logtimemicros", "-debug", "-blockversion=4", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness"])) |
| 87 | + self.nodes.append(start_node(0, self.options.tmpdir, ["-logtimemicros", "-debug", "-walletprematurewitness", "-rpcserialversion=0"])) |
| 88 | + self.nodes.append(start_node(1, self.options.tmpdir, ["-logtimemicros", "-debug", "-blockversion=4", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness", "-rpcserialversion=2"])) |
88 | 89 | self.nodes.append(start_node(2, self.options.tmpdir, ["-logtimemicros", "-debug", "-blockversion=536870915", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness"])) |
89 | 90 | connect_nodes(self.nodes[1], 0) |
90 | 91 | connect_nodes(self.nodes[2], 1) |
@@ -210,7 +211,20 @@ def run_test(self): |
210 | 211 | block = self.nodes[2].generate(1) #block 432 (first block with new rules; 432 = 144 * 3) |
211 | 212 | sync_blocks(self.nodes) |
212 | 213 | assert_equal(len(self.nodes[2].getrawmempool()), 0) |
213 | | - assert_equal(len(self.nodes[2].getblock(block[0])["tx"]), 5) |
| 214 | + segwit_tx_list = self.nodes[2].getblock(block[0])["tx"] |
| 215 | + assert_equal(len(segwit_tx_list), 5) |
| 216 | + |
| 217 | + print("Verify block and transaction serialization rpcs return differing serializations depending on rpc serialization flag") |
| 218 | + # Note: node1 has version 2, which is simply >0 and will catch future upgrades in tests |
| 219 | + assert(self.nodes[2].getblock(block[0], False) != self.nodes[0].getblock(block[0], False)) |
| 220 | + assert(self.nodes[1].getblock(block[0], False) == self.nodes[2].getblock(block[0], False)) |
| 221 | + for i in range(len(segwit_tx_list)): |
| 222 | + tx = FromHex(CTransaction(), self.nodes[2].gettransaction(segwit_tx_list[i])["hex"]) |
| 223 | + assert(self.nodes[2].getrawtransaction(segwit_tx_list[i]) != self.nodes[0].getrawtransaction(segwit_tx_list[i])) |
| 224 | + assert(self.nodes[1].getrawtransaction(segwit_tx_list[i], 0) == self.nodes[2].getrawtransaction(segwit_tx_list[i])) |
| 225 | + assert(self.nodes[0].getrawtransaction(segwit_tx_list[i]) != self.nodes[2].gettransaction(segwit_tx_list[i])["hex"]) |
| 226 | + assert(self.nodes[1].getrawtransaction(segwit_tx_list[i]) == self.nodes[2].gettransaction(segwit_tx_list[i])["hex"]) |
| 227 | + assert(self.nodes[0].getrawtransaction(segwit_tx_list[i]) == bytes_to_hex_str(tx.serialize_without_witness())) |
214 | 228 |
|
215 | 229 | print("Verify witness txs without witness data are invalid after the fork") |
216 | 230 | self.fail_mine(self.nodes[2], wit_ids[NODE_2][WIT_V0][2], False) |
|
0 commit comments