diff options
author | MarcoFalke <falke.marco@gmail.com> | 2019-05-08 10:03:06 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2019-05-08 10:06:21 -0400 |
commit | fa52eb55c9fe3f7f8517a5804a55edb7f7b3a625 (patch) | |
tree | 5ed0ba914b00a7c2c108626a287bc881d0499604 /test | |
parent | c459c5f70176928adcee4935813a2dbe7f4dbd51 (diff) | |
download | bitcoin-fa52eb55c9fe3f7f8517a5804a55edb7f7b3a625.tar.xz |
test: Remove True argument to CBlock::serialize
Unnamed arguments are confusing as to what they mean without looking up
the function signature.
Since segwit is active by default in regtest, and all blocks are
serialized with witness (#15664, c459c5f), remove the argument
`with_witness=True` from all calls to `CBlock::serialize` and
`BlockTransactions::serialize`.
This diff has been created with a script, but is better reviewed without
a scripted diff.
sed -i --regexp-extended -e 's/block(_?[2a-z]*)\.serialize\([a-z_]*=?True/block\1.serialize(/g' $(git grep -l serialize ./test)
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/feature_bip68_sequence.py | 2 | ||||
-rwxr-xr-x | test/functional/feature_nulldummy.py | 2 | ||||
-rwxr-xr-x | test/functional/p2p_segwit.py | 24 | ||||
-rwxr-xr-x | test/functional/test_framework/messages.py | 4 | ||||
-rwxr-xr-x | test/functional/wallet_bumpfee.py | 2 |
5 files changed, 17 insertions, 17 deletions
diff --git a/test/functional/feature_bip68_sequence.py b/test/functional/feature_bip68_sequence.py index fdb60fb0e8..d38eca6cbe 100755 --- a/test/functional/feature_bip68_sequence.py +++ b/test/functional/feature_bip68_sequence.py @@ -378,7 +378,7 @@ class BIP68Test(BitcoinTestFramework): add_witness_commitment(block) block.solve() - self.nodes[0].submitblock(block.serialize(True).hex()) + self.nodes[0].submitblock(block.serialize().hex()) assert_equal(self.nodes[0].getbestblockhash(), block.hash) def activateCSV(self): diff --git a/test/functional/feature_nulldummy.py b/test/functional/feature_nulldummy.py index a56c983ccc..60a703c48f 100755 --- a/test/functional/feature_nulldummy.py +++ b/test/functional/feature_nulldummy.py @@ -108,7 +108,7 @@ class NULLDUMMYTest(BitcoinTestFramework): witness and add_witness_commitment(block) block.rehash() block.solve() - node.submitblock(block.serialize(True).hex()) + node.submitblock(block.serialize().hex()) if (accept): assert_equal(node.getbestblockhash(), block.hash) self.tip = block.sha256 diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py index 000c30646a..512659f1d4 100755 --- a/test/functional/p2p_segwit.py +++ b/test/functional/p2p_segwit.py @@ -111,7 +111,7 @@ def get_virtual_size(witness_block): Virtual size is base + witness/4.""" base_size = len(witness_block.serialize(with_witness=False)) - total_size = len(witness_block.serialize(with_witness=True)) + total_size = len(witness_block.serialize()) # the "+3" is so we round up vsize = int((3 * base_size + total_size + 3) / 4) return vsize @@ -403,7 +403,7 @@ class SegWitTest(BitcoinTestFramework): block_hash = int(block_hash, 16) block = self.test_node.request_block(block_hash, 2) wit_block = self.test_node.request_block(block_hash, 2 | MSG_WITNESS_FLAG) - assert_equal(block.serialize(True), wit_block.serialize(True)) + assert_equal(block.serialize(), wit_block.serialize()) assert_equal(block.serialize(), hex_str_to_bytes(rpc_block)) else: # After activation, witness blocks and non-witness blocks should @@ -419,15 +419,15 @@ class SegWitTest(BitcoinTestFramework): rpc_block = self.nodes[0].getblock(block.hash, False) non_wit_block = self.test_node.request_block(block.sha256, 2) wit_block = self.test_node.request_block(block.sha256, 2 | MSG_WITNESS_FLAG) - assert_equal(wit_block.serialize(True), hex_str_to_bytes(rpc_block)) + assert_equal(wit_block.serialize(), hex_str_to_bytes(rpc_block)) assert_equal(wit_block.serialize(False), non_wit_block.serialize()) - assert_equal(wit_block.serialize(True), block.serialize(True)) + assert_equal(wit_block.serialize(), block.serialize()) # Test size, vsize, weight rpc_details = self.nodes[0].getblock(block.hash, True) - assert_equal(rpc_details["size"], len(block.serialize(True))) + assert_equal(rpc_details["size"], len(block.serialize())) assert_equal(rpc_details["strippedsize"], len(block.serialize(False))) - weight = 3 * len(block.serialize(False)) + len(block.serialize(True)) + weight = 3 * len(block.serialize(False)) + len(block.serialize()) assert_equal(rpc_details["weight"], weight) # Upgraded node should not ask for blocks from unupgraded @@ -884,13 +884,13 @@ class SegWitTest(BitcoinTestFramework): # We can't send over the p2p network, because this is too big to relay # TODO: repeat this test with a block that can be relayed - self.nodes[0].submitblock(block.serialize(True).hex()) + self.nodes[0].submitblock(block.serialize().hex()) assert self.nodes[0].getbestblockhash() != block.hash block.vtx[0].wit.vtxinwit[0].scriptWitness.stack.pop() assert get_virtual_size(block) < MAX_BLOCK_BASE_SIZE - self.nodes[0].submitblock(block.serialize(True).hex()) + self.nodes[0].submitblock(block.serialize().hex()) assert self.nodes[0].getbestblockhash() == block.hash @@ -969,7 +969,7 @@ class SegWitTest(BitcoinTestFramework): assert_equal(vsize, MAX_BLOCK_BASE_SIZE + 1) # Make sure that our test case would exceed the old max-network-message # limit - assert len(block.serialize(True)) > 2 * 1024 * 1024 + assert len(block.serialize()) > 2 * 1024 * 1024 test_witness_block(self.nodes[0], self.test_node, block, accepted=False) @@ -997,14 +997,14 @@ class SegWitTest(BitcoinTestFramework): add_witness_commitment(block, nonce=1) block.vtx[0].wit = CTxWitness() # drop the nonce block.solve() - self.nodes[0].submitblock(block.serialize(True).hex()) + self.nodes[0].submitblock(block.serialize().hex()) assert self.nodes[0].getbestblockhash() != block.hash # Now redo commitment with the standard nonce, but let bitcoind fill it in. add_witness_commitment(block, nonce=0) block.vtx[0].wit = CTxWitness() block.solve() - self.nodes[0].submitblock(block.serialize(True).hex()) + self.nodes[0].submitblock(block.serialize().hex()) assert_equal(self.nodes[0].getbestblockhash(), block.hash) # This time, add a tx with non-empty witness, but don't supply @@ -1019,7 +1019,7 @@ class SegWitTest(BitcoinTestFramework): block_2.vtx[0].vout.pop() block_2.vtx[0].wit = CTxWitness() - self.nodes[0].submitblock(block_2.serialize(True).hex()) + self.nodes[0].submitblock(block_2.serialize().hex()) # Tip should not advance! assert self.nodes[0].getbestblockhash() != block_2.hash diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index 954ae3c4df..00190e4cbd 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -1155,7 +1155,7 @@ class msg_generic: class msg_witness_block(msg_block): __slots__ = () def serialize(self): - r = self.block.serialize(with_witness=True) + r = self.block.serialize() return r @@ -1454,5 +1454,5 @@ class msg_witness_blocktxn(msg_blocktxn): def serialize(self): r = b"" - r += self.block_transactions.serialize(with_witness=True) + r += self.block_transactions.serialize() return r diff --git a/test/functional/wallet_bumpfee.py b/test/functional/wallet_bumpfee.py index 568b1f28d8..4d9bacf299 100755 --- a/test/functional/wallet_bumpfee.py +++ b/test/functional/wallet_bumpfee.py @@ -360,7 +360,7 @@ def submit_block_with_tx(node, tx): block.hashMerkleRoot = block.calc_merkle_root() add_witness_commitment(block) block.solve() - node.submitblock(block.serialize(True).hex()) + node.submitblock(block.serialize().hex()) return block def test_no_more_inputs_fails(rbf_node, dest_address): |