Skip to content

Commit 82bcf40

Browse files
committed
Merge pull request #7171
2f601d2 test: remove necessity to call create_callback_map (Wladimir J. van der Laan)
2 parents 075faae + 2f601d2 commit 82bcf40

File tree

7 files changed

+2
-32
lines changed

7 files changed

+2
-32
lines changed

qa/rpc-tests/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ implements the test logic.
4747
* ```NodeConn``` is the class used to connect to a bitcoind. If you implement
4848
a callback class that derives from ```NodeConnCB``` and pass that to the
4949
```NodeConn``` object, your code will receive the appropriate callbacks when
50-
events of interest arrive. NOTE: be sure to call
51-
```self.create_callback_map()``` in your derived classes' ```__init__```
52-
function, so that the correct mappings are set up between p2p messages and your
53-
callback functions.
50+
events of interest arrive.
5451

5552
* You can pass the same handler to multiple ```NodeConn```'s if you like, or pass
5653
different ones to each -- whatever makes the most sense for your test.

qa/rpc-tests/maxblocksinflight.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def on_close(self, conn):
3434
def __init__(self):
3535
NodeConnCB.__init__(self)
3636
self.log = logging.getLogger("BlockRelayTest")
37-
self.create_callback_map()
3837

3938
def add_new_connection(self, connection):
4039
self.connection = connection

qa/rpc-tests/maxuploadtarget.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
class TestNode(NodeConnCB):
2626
def __init__(self):
2727
NodeConnCB.__init__(self)
28-
self.create_callback_map()
2928
self.connection = None
3029
self.ping_counter = 1
3130
self.last_pong = msg_pong()

qa/rpc-tests/p2p-acceptblock.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
class TestNode(NodeConnCB):
6363
def __init__(self):
6464
NodeConnCB.__init__(self)
65-
self.create_callback_map()
6665
self.connection = None
6766
self.ping_counter = 1
6867
self.last_pong = msg_pong()

qa/rpc-tests/sendheaders.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
class BaseNode(NodeConnCB):
7171
def __init__(self):
7272
NodeConnCB.__init__(self)
73-
self.create_callback_map()
7473
self.connection = None
7574
self.last_inv = None
7675
self.last_headers = None

qa/rpc-tests/test_framework/comptool.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class TestNode(NodeConnCB):
4545

4646
def __init__(self, block_store, tx_store):
4747
NodeConnCB.__init__(self)
48-
self.create_callback_map()
4948
self.conn = None
5049
self.bestblockhash = None
5150
self.block_store = block_store

qa/rpc-tests/test_framework/mininode.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,32 +1015,10 @@ def wait_for_verack(self):
10151015
return
10161016
time.sleep(0.05)
10171017

1018-
# Derived classes should call this function once to set the message map
1019-
# which associates the derived classes' functions to incoming messages
1020-
def create_callback_map(self):
1021-
self.cbmap = {
1022-
"version": self.on_version,
1023-
"verack": self.on_verack,
1024-
"addr": self.on_addr,
1025-
"alert": self.on_alert,
1026-
"inv": self.on_inv,
1027-
"getdata": self.on_getdata,
1028-
"getblocks": self.on_getblocks,
1029-
"tx": self.on_tx,
1030-
"block": self.on_block,
1031-
"getaddr": self.on_getaddr,
1032-
"ping": self.on_ping,
1033-
"pong": self.on_pong,
1034-
"headers": self.on_headers,
1035-
"getheaders": self.on_getheaders,
1036-
"reject": self.on_reject,
1037-
"mempool": self.on_mempool
1038-
}
1039-
10401018
def deliver(self, conn, message):
10411019
with mininode_lock:
10421020
try:
1043-
self.cbmap[message.command](conn, message)
1021+
getattr(self, 'on_' + message.command)(conn, message)
10441022
except:
10451023
print "ERROR delivering %s (%s)" % (repr(message),
10461024
sys.exc_info()[0])

0 commit comments

Comments
 (0)