Skip to content

Commit 8d70c22

Browse files
test
1 parent 549c696 commit 8d70c22

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

test/functional/data/invalid_txs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ def get_tx(self):
117117
# tree depth commitment (CVE-2017-12842)
118118
class SizeTooSmall(BadTxTemplate):
119119
reject_reason = "tx-size-small"
120-
expect_disconnect = False
121-
valid_in_block = True
120+
expect_disconnect = True
121+
valid_in_block = False
122122

123123
def get_tx(self):
124124
tx = CTransaction()

test/functional/feature_block.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def run_test(self):
160160
blockname = f"for_invalid.{TxTemplate.__name__}"
161161
self.next_block(blockname)
162162
badtx = template.get_tx()
163-
if TxTemplate != invalid_txs.InputMissing:
163+
if TxTemplate != invalid_txs.InputMissing and TxTemplate != invalid_txs.SizeTooSmall:
164164
self.sign_tx(badtx, attempt_spend_tx)
165165
badtx.rehash()
166166
badblock = self.update_block(blockname, [badtx])

test/functional/p2p_ibd_stalling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def run_test(self):
8282

8383
# Need to wait until 1023 blocks are received - the magic total bytes number is a workaround in lack of an rpc
8484
# returning the number of downloaded (but not connected) blocks.
85-
bytes_recv = 172761 if not self.options.v2transport else 169692
85+
bytes_recv = 174555 if not self.options.v2transport else 171486
8686
self.wait_until(lambda: self.total_bytes_recv_for_blocks() == bytes_recv)
8787

8888
self.all_sync_send_with_ping(peers)

test/functional/p2p_invalid_tx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def run_test(self):
165165
node.p2ps[0].send_txs_and_test([rejected_parent], node, success=False)
166166

167167
self.log.info('Test that a peer disconnection causes erase its transactions from the orphan pool')
168-
with node.assert_debug_log(['Erased 100 orphan transaction(s) from peer=26']):
168+
with node.assert_debug_log(['Erased 100 orphan transaction(s) from peer=']):
169169
self.reconnect_p2p(num_connections=1)
170170

171171
self.log.info('Test that a transaction in the orphan pool is included in a new tip block causes erase this transaction from the orphan pool')

test/functional/test_framework/blocktools.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,21 @@ def add_witness_commitment(block, nonce=0):
135135
block.rehash()
136136

137137

138-
def script_BIP34_coinbase_height(height):
138+
def script_BIP34_coinbase_height(height, pad=False):
139139
if height <= 16:
140140
res = CScriptOp.encode_op_n(height)
141141
# Append dummy to increase scriptSig size to 2 (see bad-cb-length consensus rule)
142-
return CScript([res, OP_0])
143-
return CScript([CScriptNum(height)])
142+
script_array = [res, OP_0]
143+
if pad:
144+
script_array.append(OP_0)
145+
script_array.append(OP_0)
146+
return CScript(script_array)
147+
148+
script_array = [CScriptNum(height)]
149+
if pad:
150+
script_array.append(OP_0)
151+
script_array.append(OP_0)
152+
return CScript(script_array)
144153

145154

146155
def create_coinbase(height, pubkey=None, *, script_pubkey=None, extra_output_script=None, fees=0, nValue=50, retarget_period=REGTEST_RETARGET_PERIOD):
@@ -171,6 +180,11 @@ def create_coinbase(height, pubkey=None, *, script_pubkey=None, extra_output_scr
171180
coinbaseoutput2.nValue = 0
172181
coinbaseoutput2.scriptPubKey = extra_output_script
173182
coinbase.vout.append(coinbaseoutput2)
183+
184+
# Add padding if coinbase is exactly 64 bytes long to comply with XEP consensus rules
185+
if len(coinbase.serialize_without_witness()) == 64:
186+
coinbase.vin = [CTxIn(COutPoint(0, 0xffffffff), script_BIP34_coinbase_height(height, True), SEQUENCE_FINAL)]
187+
174188
coinbase.calc_sha256()
175189
return coinbase
176190

0 commit comments

Comments
 (0)