Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_node.py
Show First 20 Lines • Show All 324 Lines • ▼ Show 20 Lines | def calculate_fee(self, tx): | ||||
billable_size_estimate += len(tx.vin) * 81 | billable_size_estimate += len(tx.vin) * 81 | ||||
return int(self.relay_fee() / 1000 * billable_size_estimate * COIN) | return int(self.relay_fee() / 1000 * billable_size_estimate * COIN) | ||||
def calculate_fee_from_txid(self, txid): | def calculate_fee_from_txid(self, txid): | ||||
ctx = FromHex(CTransaction(), self.getrawtransaction(txid)) | ctx = FromHex(CTransaction(), self.getrawtransaction(txid)) | ||||
return self.calculate_fee(ctx) | return self.calculate_fee(ctx) | ||||
def add_p2p_connection(self, p2p_conn, *args, **kwargs): | def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs): | ||||
"""Add a p2p connection to the node. | """Add a p2p connection to the node. | ||||
This method adds the p2p connection to the self.p2ps list and also | This method adds the p2p connection to the self.p2ps list and also | ||||
returns the connection to the caller.""" | returns the connection to the caller.""" | ||||
if 'dstport' not in kwargs: | if 'dstport' not in kwargs: | ||||
kwargs['dstport'] = p2p_port(self.index) | kwargs['dstport'] = p2p_port(self.index) | ||||
if 'dstaddr' not in kwargs: | if 'dstaddr' not in kwargs: | ||||
kwargs['dstaddr'] = '127.0.0.1' | kwargs['dstaddr'] = '127.0.0.1' | ||||
p2p_conn.peer_connect(*args, **kwargs)() | p2p_conn.peer_connect(**kwargs)() | ||||
self.p2ps.append(p2p_conn) | self.p2ps.append(p2p_conn) | ||||
if wait_for_verack: | |||||
p2p_conn.wait_for_verack() | |||||
return p2p_conn | return p2p_conn | ||||
@property | @property | ||||
def p2p(self): | def p2p(self): | ||||
"""Return the first p2p connection | """Return the first p2p connection | ||||
Convenience property - most tests only use a single p2p connection to each | Convenience property - most tests only use a single p2p connection to each | ||||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |