Skip to content

Commit 51d51d3

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#26507: test: remove unused vars in feature_block
741c215 test: remove unused vars in `feature_block` (brunoerg) Pull request description: There is no need to assign `self.next_block` to variables if we're not using its return value. Most cases touched here, we're reassigning it right after with the value from `self.update_block`. Top commit has no ACKs. Tree-SHA512: 25bbea2a09f38c3a3483fa363f024d2a8edd06a00cccc93cef99e489b9a3485d58bbd6a1ed2dddc00f1cebec7e63aed8ad95701a2645ce20a0db9b69573c20a7
2 parents 8d69b61 + 741c215 commit 51d51d3

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

test/functional/feature_block.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def run_test(self):
161161

162162
self.log.info(f"Reject block with invalid tx: {TxTemplate.__name__}")
163163
blockname = f"for_invalid.{TxTemplate.__name__}"
164-
badblock = self.next_block(blockname)
164+
self.next_block(blockname)
165165
badtx = template.get_tx()
166166
if TxTemplate != invalid_txs.InputMissing:
167167
self.sign_tx(badtx, attempt_spend_tx)
@@ -473,7 +473,7 @@ def run_test(self):
473473
#
474474
self.log.info("Check P2SH SIGOPS are correctly counted")
475475
self.move_tip(35)
476-
b39 = self.next_block(39)
476+
self.next_block(39)
477477
b39_outputs = 0
478478
b39_sigops_per_output = 6
479479

@@ -672,7 +672,7 @@ def run_test(self):
672672

673673
self.log.info("Reject a block with two coinbase transactions")
674674
self.move_tip(44)
675-
b51 = self.next_block(51)
675+
self.next_block(51)
676676
cb2 = create_coinbase(51, self.coinbase_pubkey)
677677
b51 = self.update_block(51, [cb2])
678678
self.send_blocks([b51], success=False, reject_reason='bad-cb-multiple', reconnect=True)
@@ -752,7 +752,7 @@ def run_test(self):
752752

753753
# b57 - a good block with 2 txs, don't submit until end
754754
self.move_tip(55)
755-
b57 = self.next_block(57)
755+
self.next_block(57)
756756
tx = self.create_and_sign_transaction(out[16], 1)
757757
tx1 = self.create_tx(tx, 0, 1)
758758
b57 = self.update_block(57, [tx, tx1])
@@ -769,7 +769,7 @@ def run_test(self):
769769

770770
# b57p2 - a good block with 6 tx'es, don't submit until end
771771
self.move_tip(55)
772-
b57p2 = self.next_block("57p2")
772+
self.next_block("57p2")
773773
tx = self.create_and_sign_transaction(out[16], 1)
774774
tx1 = self.create_tx(tx, 0, 1)
775775
tx2 = self.create_tx(tx1, 0, 1)
@@ -803,7 +803,7 @@ def run_test(self):
803803
# tx with prevout.n out of range
804804
self.log.info("Reject a block with a transaction with prevout.n out of range")
805805
self.move_tip(57)
806-
b58 = self.next_block(58, spend=out[17])
806+
self.next_block(58, spend=out[17])
807807
tx = CTransaction()
808808
assert len(out[17].vout) < 42
809809
tx.vin.append(CTxIn(COutPoint(out[17].sha256, 42), CScript([OP_TRUE]), SEQUENCE_FINAL))
@@ -815,7 +815,7 @@ def run_test(self):
815815
# tx with output value > input value
816816
self.log.info("Reject a block with a transaction with outputs > inputs")
817817
self.move_tip(57)
818-
b59 = self.next_block(59)
818+
self.next_block(59)
819819
tx = self.create_and_sign_transaction(out[17], 51 * COIN)
820820
b59 = self.update_block(59, [tx])
821821
self.send_blocks([b59], success=False, reject_reason='bad-txns-in-belowout', reconnect=True)
@@ -851,7 +851,7 @@ def run_test(self):
851851
# \-> b_spend_dup_cb (b_dup_cb) -> b_dup_2 ()
852852
#
853853
self.move_tip(57)
854-
b_spend_dup_cb = self.next_block('spend_dup_cb')
854+
self.next_block('spend_dup_cb')
855855
tx = CTransaction()
856856
tx.vin.append(CTxIn(COutPoint(duplicate_tx.sha256, 0)))
857857
tx.vout.append(CTxOut(0, CScript([OP_TRUE])))
@@ -876,7 +876,7 @@ def run_test(self):
876876
#
877877
self.log.info("Reject a block with a transaction with a nonfinal locktime")
878878
self.move_tip('dup_2')
879-
b62 = self.next_block(62)
879+
self.next_block(62)
880880
tx = CTransaction()
881881
tx.nLockTime = 0xffffffff # this locktime is non-final
882882
tx.vin.append(CTxIn(COutPoint(out[18].sha256, 0))) # don't set nSequence
@@ -957,7 +957,7 @@ def run_test(self):
957957
#
958958
self.log.info("Accept a block with a transaction spending an output created in the same block")
959959
self.move_tip(64)
960-
b65 = self.next_block(65)
960+
self.next_block(65)
961961
tx1 = self.create_and_sign_transaction(out[19], out[19].vout[0].nValue)
962962
tx2 = self.create_and_sign_transaction(tx1, 0)
963963
b65 = self.update_block(65, [tx1, tx2])
@@ -970,7 +970,7 @@ def run_test(self):
970970
# \-> b66 (20)
971971
self.log.info("Reject a block with a transaction spending an output created later in the same block")
972972
self.move_tip(65)
973-
b66 = self.next_block(66)
973+
self.next_block(66)
974974
tx1 = self.create_and_sign_transaction(out[20], out[20].vout[0].nValue)
975975
tx2 = self.create_and_sign_transaction(tx1, 1)
976976
b66 = self.update_block(66, [tx2, tx1])
@@ -984,7 +984,7 @@ def run_test(self):
984984
#
985985
self.log.info("Reject a block with a transaction double spending a transaction created in the same block")
986986
self.move_tip(65)
987-
b67 = self.next_block(67)
987+
self.next_block(67)
988988
tx1 = self.create_and_sign_transaction(out[20], out[20].vout[0].nValue)
989989
tx2 = self.create_and_sign_transaction(tx1, 1)
990990
tx3 = self.create_and_sign_transaction(tx1, 2)
@@ -1005,7 +1005,7 @@ def run_test(self):
10051005
#
10061006
self.log.info("Reject a block trying to claim too much subsidy in the coinbase transaction")
10071007
self.move_tip(65)
1008-
b68 = self.next_block(68, additional_coinbase_value=10)
1008+
self.next_block(68, additional_coinbase_value=10)
10091009
tx = self.create_and_sign_transaction(out[20], out[20].vout[0].nValue - 9)
10101010
b68 = self.update_block(68, [tx])
10111011
self.send_blocks([b68], success=False, reject_reason='bad-cb-amount', reconnect=True)
@@ -1025,7 +1025,7 @@ def run_test(self):
10251025
#
10261026
self.log.info("Reject a block containing a transaction spending from a non-existent input")
10271027
self.move_tip(69)
1028-
b70 = self.next_block(70, spend=out[21])
1028+
self.next_block(70, spend=out[21])
10291029
bogus_tx = CTransaction()
10301030
bogus_tx.sha256 = uint256_from_str(b"23c70ed7c0506e9178fc1a987f40a33946d4ad4c962b5ae3a52546da53af0c5c")
10311031
tx = CTransaction()
@@ -1043,7 +1043,7 @@ def run_test(self):
10431043
# b71 is a copy of 72, but re-adds one of its transactions. However, it has the same hash as b72.
10441044
self.log.info("Reject a block containing a duplicate transaction but with the same Merkle root (Merkle tree malleability")
10451045
self.move_tip(69)
1046-
b72 = self.next_block(72)
1046+
self.next_block(72)
10471047
tx1 = self.create_and_sign_transaction(out[21], 2)
10481048
tx2 = self.create_and_sign_transaction(tx1, 1)
10491049
b72 = self.update_block(72, [tx1, tx2]) # now tip is 72
@@ -1081,7 +1081,7 @@ def run_test(self):
10811081
# bytearray[20,526] : OP_CHECKSIG (this puts us over the limit)
10821082
self.log.info("Reject a block containing too many sigops after a large script element")
10831083
self.move_tip(72)
1084-
b73 = self.next_block(73)
1084+
self.next_block(73)
10851085
size = MAX_BLOCK_SIGOPS - 1 + MAX_SCRIPT_ELEMENT_SIZE + 1 + 5 + 1
10861086
a = bytearray([OP_CHECKSIG] * size)
10871087
a[MAX_BLOCK_SIGOPS - 1] = int("4e", 16) # OP_PUSHDATA4
@@ -1109,7 +1109,7 @@ def run_test(self):
11091109
# b75 succeeds because we put MAX_BLOCK_SIGOPS before the element
11101110
self.log.info("Check sigops are counted correctly after an invalid script element")
11111111
self.move_tip(72)
1112-
b74 = self.next_block(74)
1112+
self.next_block(74)
11131113
size = MAX_BLOCK_SIGOPS - 1 + MAX_SCRIPT_ELEMENT_SIZE + 42 # total = 20,561
11141114
a = bytearray([OP_CHECKSIG] * size)
11151115
a[MAX_BLOCK_SIGOPS] = 0x4e
@@ -1122,7 +1122,7 @@ def run_test(self):
11221122
self.send_blocks([b74], success=False, reject_reason='bad-blk-sigops', reconnect=True)
11231123

11241124
self.move_tip(72)
1125-
b75 = self.next_block(75)
1125+
self.next_block(75)
11261126
size = MAX_BLOCK_SIGOPS - 1 + MAX_SCRIPT_ELEMENT_SIZE + 42
11271127
a = bytearray([OP_CHECKSIG] * size)
11281128
a[MAX_BLOCK_SIGOPS - 1] = 0x4e
@@ -1137,7 +1137,7 @@ def run_test(self):
11371137

11381138
# Check that if we push an element filled with CHECKSIGs, they are not counted
11391139
self.move_tip(75)
1140-
b76 = self.next_block(76)
1140+
self.next_block(76)
11411141
size = MAX_BLOCK_SIGOPS - 1 + MAX_SCRIPT_ELEMENT_SIZE + 1 + 5
11421142
a = bytearray([OP_CHECKSIG] * size)
11431143
a[MAX_BLOCK_SIGOPS - 1] = 0x4e # PUSHDATA4, but leave the following bytes as just checksigs
@@ -1165,18 +1165,18 @@ def run_test(self):
11651165
# updated. (Perhaps to spend to a P2SH OP_TRUE script)
11661166
self.log.info("Test transaction resurrection during a re-org")
11671167
self.move_tip(76)
1168-
b77 = self.next_block(77)
1168+
self.next_block(77)
11691169
tx77 = self.create_and_sign_transaction(out[24], 10 * COIN)
11701170
b77 = self.update_block(77, [tx77])
11711171
self.send_blocks([b77], True)
11721172
self.save_spendable_output()
11731173

1174-
b78 = self.next_block(78)
1174+
self.next_block(78)
11751175
tx78 = self.create_tx(tx77, 0, 9 * COIN)
11761176
b78 = self.update_block(78, [tx78])
11771177
self.send_blocks([b78], True)
11781178

1179-
b79 = self.next_block(79)
1179+
self.next_block(79)
11801180
tx79 = self.create_tx(tx78, 0, 8 * COIN)
11811181
b79 = self.update_block(79, [tx79])
11821182
self.send_blocks([b79], True)
@@ -1208,7 +1208,7 @@ def run_test(self):
12081208
# -> b81 (26) -> b82 (27) -> b83 (28)
12091209
#
12101210
self.log.info("Accept a block with invalid opcodes in dead execution paths")
1211-
b83 = self.next_block(83)
1211+
self.next_block(83)
12121212
op_codes = [OP_IF, OP_INVALIDOPCODE, OP_ELSE, OP_TRUE, OP_ENDIF]
12131213
script = CScript(op_codes)
12141214
tx1 = self.create_and_sign_transaction(out[28], out[28].vout[0].nValue, script)
@@ -1227,7 +1227,7 @@ def run_test(self):
12271227
# \-> b85 (29) -> b86 (30) \-> b89a (32)
12281228
#
12291229
self.log.info("Test re-orging blocks with OP_RETURN in them")
1230-
b84 = self.next_block(84)
1230+
self.next_block(84)
12311231
tx1 = self.create_tx(out[29], 0, 0, CScript([OP_RETURN]))
12321232
tx1.vout.append(CTxOut(0, CScript([OP_TRUE])))
12331233
tx1.vout.append(CTxOut(0, CScript([OP_TRUE])))
@@ -1265,7 +1265,7 @@ def run_test(self):
12651265
self.save_spendable_output()
12661266

12671267
# trying to spend the OP_RETURN output is rejected
1268-
b89a = self.next_block("89a", spend=out[32])
1268+
self.next_block("89a", spend=out[32])
12691269
tx = self.create_tx(tx1, 0, 0, CScript([OP_TRUE]))
12701270
b89a = self.update_block("89a", [tx])
12711271
self.send_blocks([b89a], success=False, reject_reason='bad-txns-inputs-missingorspent', reconnect=True)

0 commit comments

Comments
 (0)