mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
p2p: Remove BIP61 reject messages
This commit is contained in:
@@ -22,9 +22,6 @@ from io import BytesIO
|
||||
|
||||
CLTV_HEIGHT = 1351
|
||||
|
||||
# Reject codes that we might receive in this test
|
||||
REJECT_INVALID = 16
|
||||
REJECT_NONSTANDARD = 64
|
||||
|
||||
def cltv_invalidate(tx):
|
||||
'''Modify the signature in vin 0 of the tx to fail CLTV
|
||||
|
||||
@@ -9,19 +9,15 @@ Test that the DERSIG soft-fork activates at (regtest) height 1251.
|
||||
|
||||
from test_framework.blocktools import create_coinbase, create_block, create_transaction
|
||||
from test_framework.messages import msg_block
|
||||
from test_framework.mininode import mininode_lock, P2PInterface
|
||||
from test_framework.mininode import P2PInterface
|
||||
from test_framework.script import CScript
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
wait_until,
|
||||
)
|
||||
|
||||
DERSIG_HEIGHT = 1251
|
||||
|
||||
# Reject codes that we might receive in this test
|
||||
REJECT_INVALID = 16
|
||||
REJECT_NONSTANDARD = 64
|
||||
|
||||
# A canonical signature consists of:
|
||||
# <30> <total len> <02> <len R> <R> <02> <len S> <S> <hashtype>
|
||||
@@ -44,7 +40,7 @@ def unDERify(tx):
|
||||
class BIP66Test(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 1
|
||||
self.extra_args = [['-whitelist=127.0.0.1', '-par=1', '-enablebip61']] # Use only one script thread to get the exact reject reason for testing
|
||||
self.extra_args = [['-whitelist=127.0.0.1', '-par=1']] # Use only one script thread to get the exact log msg for testing
|
||||
self.setup_clean_chain = True
|
||||
self.rpc_timeout = 120
|
||||
|
||||
@@ -129,12 +125,6 @@ class BIP66Test(BitcoinTestFramework):
|
||||
assert_equal(int(self.nodes[0].getbestblockhash(), 16), tip)
|
||||
self.nodes[0].p2p.sync_with_ping()
|
||||
|
||||
wait_until(lambda: "reject" in self.nodes[0].p2p.last_message.keys(), lock=mininode_lock)
|
||||
with mininode_lock:
|
||||
assert self.nodes[0].p2p.last_message["reject"].code in [REJECT_INVALID, REJECT_NONSTANDARD]
|
||||
assert_equal(self.nodes[0].p2p.last_message["reject"].data, block.sha256)
|
||||
assert b'Non-canonical DER signature' in self.nodes[0].p2p.last_message["reject"].reason
|
||||
|
||||
self.log.info("Test that a version 3 block with a DERSIG-compliant transaction is accepted")
|
||||
block.vtx[1] = create_transaction(self.nodes[0], self.coinbase_txids[1], self.nodeaddress, amount=1.0)
|
||||
block.hashMerkleRoot = block.calc_merkle_root()
|
||||
|
||||
@@ -1317,38 +1317,6 @@ class msg_headers:
|
||||
return "msg_headers(headers=%s)" % repr(self.headers)
|
||||
|
||||
|
||||
class msg_reject:
|
||||
__slots__ = ("code", "data", "message", "reason")
|
||||
command = b"reject"
|
||||
REJECT_MALFORMED = 1
|
||||
|
||||
def __init__(self):
|
||||
self.message = b""
|
||||
self.code = 0
|
||||
self.reason = b""
|
||||
self.data = 0
|
||||
|
||||
def deserialize(self, f):
|
||||
self.message = deser_string(f)
|
||||
self.code = struct.unpack("<B", f.read(1))[0]
|
||||
self.reason = deser_string(f)
|
||||
if (self.code != self.REJECT_MALFORMED and
|
||||
(self.message == b"block" or self.message == b"tx")):
|
||||
self.data = deser_uint256(f)
|
||||
|
||||
def serialize(self):
|
||||
r = ser_string(self.message)
|
||||
r += struct.pack("<B", self.code)
|
||||
r += ser_string(self.reason)
|
||||
if (self.code != self.REJECT_MALFORMED and
|
||||
(self.message == b"block" or self.message == b"tx")):
|
||||
r += ser_uint256(self.data)
|
||||
return r
|
||||
|
||||
def __repr__(self):
|
||||
return "msg_reject: %s %d %s [%064x]" \
|
||||
% (self.message, self.code, self.reason, self.data)
|
||||
|
||||
|
||||
class msg_feefilter:
|
||||
__slots__ = ("feerate",)
|
||||
|
||||
@@ -41,7 +41,6 @@ from test_framework.messages import (
|
||||
msg_notfound,
|
||||
msg_ping,
|
||||
msg_pong,
|
||||
msg_reject,
|
||||
msg_sendcmpct,
|
||||
msg_sendheaders,
|
||||
msg_tx,
|
||||
@@ -74,7 +73,6 @@ MESSAGEMAP = {
|
||||
b"notfound": msg_notfound,
|
||||
b"ping": msg_ping,
|
||||
b"pong": msg_pong,
|
||||
b"reject": msg_reject,
|
||||
b"sendcmpct": msg_sendcmpct,
|
||||
b"sendheaders": msg_sendheaders,
|
||||
b"tx": msg_tx,
|
||||
|
||||
Reference in New Issue
Block a user