From c6b319d9d25d384ef506f2b56218674082a1f381 Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Mon, 21 Dec 2020 20:23:16 -0800 Subject: [PATCH] Litecoin: More functional tests --- test/functional/feature_nulldummy.py | 6 +++--- test/functional/feature_taproot.py | 4 ++-- test/functional/p2p_segwit.py | 14 ++++++-------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/test/functional/feature_nulldummy.py b/test/functional/feature_nulldummy.py index 897009a471..d20b714ce3 100755 --- a/test/functional/feature_nulldummy.py +++ b/test/functional/feature_nulldummy.py @@ -96,19 +96,19 @@ class NULLDUMMYTest(BitcoinTestFramework): test6txs = [CTransaction(test4tx)] trueDummy(test4tx) assert_raises_rpc_error(-26, NULLDUMMY_ERROR, self.nodes[0].sendrawtransaction, test4tx.serialize_with_witness().hex(), 0) - self.block_submit(self.nodes[0], [test4tx]) + self.block_submit(self.nodes[0], [test4tx], version=VB_TOP_BITS) self.log.info("Test 5: Non-NULLDUMMY P2WSH multisig transaction invalid after activation") test5tx = create_transaction(self.nodes[0], txid3, self.wit_address, amount=48) test6txs.append(CTransaction(test5tx)) test5tx.wit.vtxinwit[0].scriptWitness.stack[0] = b'\x01' assert_raises_rpc_error(-26, NULLDUMMY_ERROR, self.nodes[0].sendrawtransaction, test5tx.serialize_with_witness().hex(), 0) - self.block_submit(self.nodes[0], [test5tx], True) + self.block_submit(self.nodes[0], [test5tx], True, version=VB_TOP_BITS) self.log.info("Test 6: NULLDUMMY compliant base/witness transactions should be accepted to mempool and in block after activation [432]") for i in test6txs: self.nodes[0].sendrawtransaction(i.serialize_with_witness().hex(), 0) - self.block_submit(self.nodes[0], test6txs, True, True) + self.block_submit(self.nodes[0], test6txs, True, True, VB_TOP_BITS) def block_submit(self, node, txs, witness=False, accept=False, version=4): tmpl = node.getblocktemplate(NORMAL_GBT_REQUEST_PARAMS) diff --git a/test/functional/feature_taproot.py b/test/functional/feature_taproot.py index 2b9b614878..5e7a99c9cc 100755 --- a/test/functional/feature_taproot.py +++ b/test/functional/feature_taproot.py @@ -1210,7 +1210,7 @@ class TaprootTest(BitcoinTestFramework): extra_output_script = CScript([OP_CHECKSIG]*((MAX_BLOCK_SIGOPS_WEIGHT - sigops_weight) // WITNESS_SCALE_FACTOR)) block = create_block(self.tip, create_coinbase(self.lastblockheight + 1, pubkey=cb_pubkey, extra_output_script=extra_output_script, fees=fees), self.lastblocktime + 1) - block.nVersion = 4 + block.nVersion = 0x20000000 for tx in txs: tx.rehash() block.vtx.append(tx) @@ -1458,7 +1458,7 @@ class TaprootTest(BitcoinTestFramework): rawtx = self.nodes[1].signrawtransactionwithwallet(rawtx)['hex'] # Mine a block with the transaction - block = create_block(tmpl=self.nodes[1].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS), txlist=[rawtx]) + block = create_block(tmpl=self.nodes[1].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS), txlist=[rawtx], version=0x20000000) add_witness_commitment(block) block.rehash() block.solve() diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py index 64f4ec63b2..540bc9b1e8 100755 --- a/test/functional/p2p_segwit.py +++ b/test/functional/p2p_segwit.py @@ -220,9 +220,9 @@ class SegWitTest(BitcoinTestFramework): self.num_nodes = 3 # This test tests SegWit both pre and post-activation, so use the normal BIP9 activation. self.extra_args = [ - ["-acceptnonstdtxn=1", "-segwitheight={}".format(SEGWIT_HEIGHT), "-whitelist=noban@127.0.0.1", "-mempoolreplacement=1"], - ["-acceptnonstdtxn=0", "-segwitheight={}".format(SEGWIT_HEIGHT), "-mempoolreplacement=1"], - ["-acceptnonstdtxn=1", "-segwitheight=-1"], "-mempoolreplacement=1", + ["-acceptnonstdtxn=1", "-segwitheight={}".format(SEGWIT_HEIGHT), "-whitelist=noban@127.0.0.1"], + ["-acceptnonstdtxn=0", "-segwitheight={}".format(SEGWIT_HEIGHT)], + ["-acceptnonstdtxn=1", "-segwitheight=-1"], ] self.supports_cli = False @@ -405,7 +405,6 @@ class SegWitTest(BitcoinTestFramework): assert self.test_node.last_message["getdata"].inv[0].type == blocktype test_witness_block(self.nodes[0], self.test_node, block1, True) - block2 = self.build_next_block() block2.solve() @@ -557,9 +556,8 @@ class SegWitTest(BitcoinTestFramework): # 'non-mandatory-script-verify-flag (Witness program was passed an # empty witness)' (otherwise). # TODO: support multiple acceptable reject reasons. - # Litecoin: SCRIPT_VERIFY_WITNESS is enforced when segwit is activated - test_witness_block(self.nodes[0], self.test_node, block, accepted=True, with_witness=False) - + test_witness_block(self.nodes[0], self.test_node, block, accepted=False, with_witness=False) + self.connect_nodes(0, 2) self.utxo.pop(0) @@ -1944,7 +1942,7 @@ class SegWitTest(BitcoinTestFramework): def test_upgrade_after_activation(self): """Test the behavior of starting up a segwit-aware node after the softfork has activated.""" - block = self.build_next_block(nVersion=4) + block = self.build_next_block(version=4) block.solve() resp = self.nodes[0].submitblock(block.serialize().hex()) assert_equal(resp, 'bad-version(0x00000004)')