MERGE-FIX: functional tests

This commit is contained in:
Gregory Sanders 2019-01-28 18:09:48 +00:00
parent 51584e73a3
commit 90f7d18c8f
6 changed files with 10 additions and 18 deletions

View file

@ -6,11 +6,11 @@
from test_framework.blocktools import create_coinbase, create_block, create_transaction from test_framework.blocktools import create_coinbase, create_block, create_transaction
from test_framework.messages import msg_block from test_framework.messages import msg_block
from test_framework.mininode import mininode_lock, P2PInterface from test_framework.mininode import P2PInterface
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, wait_until from test_framework.util import assert_equal
from feature_cltv import cltv_validate, REJECT_OBSOLETE from feature_cltv import cltv_validate
class BlockV4Test(BitcoinTestFramework): class BlockV4Test(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
@ -32,19 +32,13 @@ class BlockV4Test(BitcoinTestFramework):
block.nVersion = 3 block.nVersion = 3
block.solve() block.solve()
# Send it to the node
self.nodes[0].p2p.send_and_ping(msg_block(block))
# The best block should not have changed, because... # The best block should not have changed, because...
assert_equal(self.nodes[0].getbestblockhash(), tip) assert_equal(self.nodes[0].getbestblockhash(), tip)
# ... we rejected it because it is v3 # ... we rejected it because it is v3
wait_until(lambda: "reject" in self.nodes[0].p2p.last_message.keys(), lock=mininode_lock) with self.nodes[0].assert_debug_log(expected_msgs=['{}, bad-version(0x00000003)'.format(block.hash)]):
with mininode_lock: # Send it to the node
assert_equal(self.nodes[0].p2p.last_message["reject"].code, REJECT_OBSOLETE) self.nodes[0].p2p.send_and_ping(msg_block(block))
assert_equal(self.nodes[0].p2p.last_message["reject"].reason, b'bad-version(0x00000003)')
assert_equal(self.nodes[0].p2p.last_message["reject"].data, block.sha256)
del self.nodes[0].p2p.last_message["reject"]
self.log.info("Test that a version 4 block with a valid-according-to-CLTV transaction is accepted") self.log.info("Test that a version 4 block with a valid-according-to-CLTV transaction is accepted")

View file

@ -64,10 +64,11 @@ class MandatoryCoinbaseTest(BitcoinTestFramework):
block.proof = CProof(bytearray.fromhex('51')) block.proof = CProof(bytearray.fromhex('51'))
block.vtx = [coinbase_tx] block.vtx = [coinbase_tx]
block.block_height = int(tmpl["height"]) block.block_height = int(tmpl["height"])
block.hashMerkleRoot = block.calc_merkle_root()
self.log.info("getblocktemplate: Test block on both nodes") self.log.info("getblocktemplate: Test block on both nodes")
assert_equal(node0.submitblock(b2x(block.serialize())), 'invalid')
assert_template(node1, block, None) assert_template(node1, block, None)
assert_template(node0, block, 'bad-coinbase-txos')
self.log.info("getblocktemplate: Test non-subsidy block on both nodes") self.log.info("getblocktemplate: Test non-subsidy block on both nodes")
# Without block reward anything goes, this allows commitment outputs like segwit # Without block reward anything goes, this allows commitment outputs like segwit

View file

@ -156,8 +156,6 @@ class MiningTest(BitcoinTestFramework):
self.log.info('submitheader tests') self.log.info('submitheader tests')
assert_raises_rpc_error(-22, 'Block header decode failed', lambda: node.submitheader(hexdata='xx' * TX_COUNT_OFFSET)) assert_raises_rpc_error(-22, 'Block header decode failed', lambda: node.submitheader(hexdata='xx' * TX_COUNT_OFFSET))
assert_raises_rpc_error(-22, 'Block header decode failed', lambda: node.submitheader(hexdata='ff' * (TX_COUNT_OFFSET-2))) assert_raises_rpc_error(-22, 'Block header decode failed', lambda: node.submitheader(hexdata='ff' * (TX_COUNT_OFFSET-2)))
import pdb
pdb.set_trace()
assert_raises_rpc_error(-25, 'Must submit previous header', lambda: node.submitheader(hexdata=super(CBlock, bad_block).serialize().hex())) assert_raises_rpc_error(-25, 'Must submit previous header', lambda: node.submitheader(hexdata=super(CBlock, bad_block).serialize().hex()))
block.nTime += 1 block.nTime += 1

View file

@ -92,7 +92,7 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
block2_orig.hashMerkleRoot = block2_orig.calc_merkle_root() block2_orig.hashMerkleRoot = block2_orig.calc_merkle_root()
block2_orig.rehash() block2_orig.rehash()
block2_orig.solve() block2_orig.solve()
node.p2p.send_blocks_and_test([block2_orig], node, success=False, request_block=False, reject_reason=b'bad-txns-inputs-duplicate') node.p2p.send_blocks_and_test([block2_orig], node, success=False, request_block=False, reject_reason='bad-txns-inputs-duplicate')
self.log.info("Test very broken block.") self.log.info("Test very broken block.")

View file

@ -250,7 +250,7 @@ class TestNode():
@contextlib.contextmanager @contextlib.contextmanager
def assert_debug_log(self, expected_msgs): def assert_debug_log(self, expected_msgs):
debug_log = os.path.join(self.datadir, 'regtest', 'debug.log') debug_log = os.path.join(self.datadir, 'regtest2', 'debug.log')
with open(debug_log, encoding='utf-8') as dl: with open(debug_log, encoding='utf-8') as dl:
dl.seek(0, 2) dl.seek(0, 2)
prev_size = dl.tell() prev_size = dl.tell()

View file

@ -163,7 +163,6 @@ BASE_SCRIPTS = [
'rpc_uptime.py', 'rpc_uptime.py',
'wallet_resendwallettransactions.py', 'wallet_resendwallettransactions.py',
'wallet_fallbackfee.py', 'wallet_fallbackfee.py',
'feature_minchainwork.py',
'rpc_getblockstats.py', 'rpc_getblockstats.py',
'p2p_fingerprint.py', 'p2p_fingerprint.py',
'feature_uacomment.py', 'feature_uacomment.py',