Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_permissions.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2015-2018 The Bitcoin Core developers | # Copyright (c) 2015-2018 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Test p2p permission message. | """Test p2p permission message. | ||||
Test that permissions are correctly calculated and applied | Test that permissions are correctly calculated and applied | ||||
""" | """ | ||||
from test_framework.address import ADDRESS_ECREG_P2SH_OP_TRUE | from test_framework.address import ( | ||||
ADDRESS_ECREG_P2SH_OP_TRUE, | |||||
SCRIPTSIG_OP_TRUE, | |||||
) | |||||
from test_framework.messages import CTransaction, FromHex | from test_framework.messages import CTransaction, FromHex | ||||
from test_framework.p2p import P2PDataStore | from test_framework.p2p import P2PDataStore | ||||
from test_framework.script import OP_TRUE, CScript, CScriptOp | |||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.test_node import ErrorMatch | from test_framework.test_node import ErrorMatch | ||||
from test_framework.txtools import pad_tx | from test_framework.txtools import pad_tx | ||||
from test_framework.util import assert_equal, connect_nodes, p2p_port | from test_framework.util import assert_equal, connect_nodes, p2p_port | ||||
class P2PPermissionsTests(BitcoinTestFramework): | class P2PPermissionsTests(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | def check_tx_relay(self): | ||||
P2PDataStore()) | P2PDataStore()) | ||||
self.log.debug("Send a tx from the wallet initially") | self.log.debug("Send a tx from the wallet initially") | ||||
tx = FromHex(CTransaction(), | tx = FromHex(CTransaction(), | ||||
self.nodes[0].createrawtransaction( | self.nodes[0].createrawtransaction( | ||||
inputs=[{'txid': block_op_true['tx'][0], 'vout': 0}], | inputs=[{'txid': block_op_true['tx'][0], 'vout': 0}], | ||||
outputs=[{ADDRESS_ECREG_P2SH_OP_TRUE: 50}])) | outputs=[{ADDRESS_ECREG_P2SH_OP_TRUE: 50}])) | ||||
# push the one byte script to the stack | # push the one byte script to the stack | ||||
tx.vin[0].scriptSig = CScriptOp.encode_op_pushdata(CScript([OP_TRUE])) | tx.vin[0].scriptSig = SCRIPTSIG_OP_TRUE | ||||
pad_tx(tx) | pad_tx(tx) | ||||
txid = tx.rehash() | txid = tx.rehash() | ||||
self.log.debug("Wait until tx is in node[1]'s mempool") | self.log.debug("Wait until tx is in node[1]'s mempool") | ||||
p2p_rebroadcast_wallet.send_txs_and_test([tx], self.nodes[1]) | p2p_rebroadcast_wallet.send_txs_and_test([tx], self.nodes[1]) | ||||
self.log.debug( | self.log.debug( | ||||
"Check that node[1] will send the tx to node[0] even though it" | "Check that node[1] will send the tx to node[0] even though it" | ||||
Show All 39 Lines |