Skip to content

Commit 876dbdf

Browse files
committed
tests: drop expect_disconnect behaviour for tx relay
1 parent b29ae9e commit 876dbdf

File tree

4 files changed

+2
-35
lines changed

4 files changed

+2
-35
lines changed

test/functional/data/invalid_txs.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ class BadTxTemplate:
7373
# Only specified if it differs from mempool acceptance error.
7474
block_reject_reason = ""
7575

76-
# Do we expect to be disconnected after submitting this tx?
77-
expect_disconnect = False
78-
7976
# Is this tx considered valid when included in a block, but not for acceptance into
8077
# the mempool (i.e. does it violate policy but not consensus)?
8178
valid_in_block = False
@@ -93,7 +90,6 @@ def get_tx(self, *args, **kwargs):
9390

9491
class OutputMissing(BadTxTemplate):
9592
reject_reason = "bad-txns-vout-empty"
96-
expect_disconnect = False
9793

9894
def get_tx(self):
9995
tx = CTransaction()
@@ -103,7 +99,6 @@ def get_tx(self):
10399

104100
class InputMissing(BadTxTemplate):
105101
reject_reason = "bad-txns-vin-empty"
106-
expect_disconnect = False
107102

108103
# We use a blank transaction here to make sure
109104
# it is interpreted as a non-witness transaction.
@@ -119,7 +114,6 @@ def get_tx(self):
119114
# tree depth commitment (CVE-2017-12842)
120115
class SizeTooSmall(BadTxTemplate):
121116
reject_reason = "tx-size-small"
122-
expect_disconnect = False
123117
valid_in_block = True
124118

125119
def get_tx(self):
@@ -137,7 +131,6 @@ class BadInputOutpointIndex(BadTxTemplate):
137131
reject_reason = None
138132
# But fails in block
139133
block_reject_reason = "bad-txns-inputs-missingorspent"
140-
expect_disconnect = False
141134

142135
def get_tx(self):
143136
num_indices = len(self.spend_tx.vin)
@@ -151,7 +144,6 @@ def get_tx(self):
151144

152145
class DuplicateInput(BadTxTemplate):
153146
reject_reason = 'bad-txns-inputs-duplicate'
154-
expect_disconnect = False
155147

156148
def get_tx(self):
157149
tx = CTransaction()
@@ -163,7 +155,6 @@ def get_tx(self):
163155

164156
class PrevoutNullInput(BadTxTemplate):
165157
reject_reason = 'bad-txns-prevout-null'
166-
expect_disconnect = False
167158

168159
def get_tx(self):
169160
tx = CTransaction()
@@ -175,7 +166,6 @@ def get_tx(self):
175166

176167
class NonexistentInput(BadTxTemplate):
177168
reject_reason = None # Added as an orphan tx.
178-
expect_disconnect = False
179169
# But fails in block
180170
block_reject_reason = "bad-txns-inputs-missingorspent"
181171

@@ -189,7 +179,6 @@ def get_tx(self):
189179

190180
class SpendTooMuch(BadTxTemplate):
191181
reject_reason = 'bad-txns-in-belowout'
192-
expect_disconnect = False
193182

194183
def get_tx(self):
195184
return create_tx_with_script(
@@ -198,23 +187,20 @@ def get_tx(self):
198187

199188
class CreateNegative(BadTxTemplate):
200189
reject_reason = 'bad-txns-vout-negative'
201-
expect_disconnect = False
202190

203191
def get_tx(self):
204192
return create_tx_with_script(self.spend_tx, 0, amount=-1)
205193

206194

207195
class CreateTooLarge(BadTxTemplate):
208196
reject_reason = 'bad-txns-vout-toolarge'
209-
expect_disconnect = False
210197

211198
def get_tx(self):
212199
return create_tx_with_script(self.spend_tx, 0, amount=MAX_MONEY + 1)
213200

214201

215202
class CreateSumTooLarge(BadTxTemplate):
216203
reject_reason = 'bad-txns-txouttotal-toolarge'
217-
expect_disconnect = False
218204

219205
def get_tx(self):
220206
tx = create_tx_with_script(self.spend_tx, 0, amount=MAX_MONEY)
@@ -224,7 +210,6 @@ def get_tx(self):
224210

225211
class InvalidOPIFConstruction(BadTxTemplate):
226212
reject_reason = "mempool-script-verify-flag-failed (Invalid OP_IF construction)"
227-
expect_disconnect = False
228213

229214
def get_tx(self):
230215
return create_tx_with_script(
@@ -235,7 +220,6 @@ def get_tx(self):
235220
class TooManySigopsPerBlock(BadTxTemplate):
236221
reject_reason = "bad-txns-too-many-sigops"
237222
block_reject_reason = "bad-blk-sigops, out-of-bounds SigOpCount"
238-
expect_disconnect = False
239223

240224
def get_tx(self):
241225
lotsa_checksigs = CScript([OP_CHECKSIG] * (MAX_BLOCK_SIGOPS))
@@ -247,7 +231,6 @@ def get_tx(self):
247231

248232
class TooManySigopsPerTransaction(BadTxTemplate):
249233
reject_reason = "bad-txns-too-many-sigops"
250-
expect_disconnect = False
251234
valid_in_block = True
252235

253236
def get_tx(self):
@@ -270,7 +253,6 @@ def get_tx(self):
270253

271254
return type('DisabledOpcode_' + str(opcode), (BadTxTemplate,), {
272255
'reject_reason': "disabled opcode",
273-
'expect_disconnect': True,
274256
'get_tx': get_tx,
275257
'valid_in_block' : False
276258
})
@@ -279,7 +261,6 @@ class NonStandardAndInvalid(BadTxTemplate):
279261
"""A non-standard transaction which is also consensus-invalid should return the first error."""
280262
reject_reason = "mempool-script-verify-flag-failed (Using OP_CODESEPARATOR in non-witness script)"
281263
block_reject_reason = "mandatory-script-verify-flag-failed (OP_RETURN was encountered)"
282-
expect_disconnect = False
283264
valid_in_block = False
284265

285266
def get_tx(self):

test/functional/feature_block.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,6 @@ def run_test(self):
177177
for TxTemplate in invalid_txs.iter_all_templates():
178178
template = TxTemplate(spend_tx=attempt_spend_tx)
179179

180-
# belt-and-suspenders checking we won't pass up validating something
181-
# we expect a disconnect from
182-
if template.expect_disconnect:
183-
assert not template.valid_in_block
184-
185180
if template.valid_in_block:
186181
continue
187182

test/functional/p2p_invalid_tx.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,9 @@ def run_test(self):
7373
tx = template.get_tx()
7474
node.p2ps[0].send_txs_and_test(
7575
[tx], node, success=False,
76-
expect_disconnect=False,
7776
reject_reason=template.reject_reason,
7877
)
7978

80-
if template.expect_disconnect:
81-
self.log.info("Reconnecting to peer")
82-
self.reconnect_p2p()
83-
8479
# Make two p2p connections to provide the node with orphans
8580
# * p2ps[0] will send valid orphan txs (one with low fee)
8681
# * p2ps[1] will send an invalid orphan tx (and is later disconnected for that)

test/functional/test_framework/p2p.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -900,13 +900,12 @@ def send_blocks_and_test(self, blocks, node, *, success=True, force_send=False,
900900
else:
901901
assert_not_equal(node.getbestblockhash(), blocks[-1].hash_hex)
902902

903-
def send_txs_and_test(self, txs, node, *, success=True, expect_disconnect=False, reject_reason=None):
903+
def send_txs_and_test(self, txs, node, *, success=True, reject_reason=None):
904904
"""Send txs to test node and test whether they're accepted to the mempool.
905905
906906
- add all txs to our tx_store
907907
- send tx messages for all txs
908908
- if success is True/False: assert that the txs are/are not accepted to the mempool
909-
- if expect_disconnect is True: Skip the sync with ping
910909
- if reject_reason is set: assert that the correct reject message is logged."""
911910

912911
with p2p_lock:
@@ -918,10 +917,7 @@ def send_txs_and_test(self, txs, node, *, success=True, expect_disconnect=False,
918917
for tx in txs:
919918
self.send_without_ping(msg_tx(tx))
920919

921-
if expect_disconnect:
922-
self.wait_for_disconnect()
923-
else:
924-
self.sync_with_ping()
920+
self.sync_with_ping()
925921

926922
raw_mempool = node.getrawmempool()
927923
if success:

0 commit comments

Comments
 (0)