Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_p2p_proof_inventory.py
Show First 20 Lines • Show All 251 Lines • ▼ Show 20 Lines | def test_unbroadcast(self): | ||||
# Restart and add connect a new set of peers | # Restart and add connect a new set of peers | ||||
self.restart_node(0) | self.restart_node(0) | ||||
# Broadcast the proof | # Broadcast the proof | ||||
peers = add_peers(3) | peers = add_peers(3) | ||||
assert node.sendavalancheproof(proof.serialize().hex()) | assert node.sendavalancheproof(proof.serialize().hex()) | ||||
wait_until(lambda: proof_inv_received(peers)) | wait_until(lambda: proof_inv_received(peers)) | ||||
# Sanity check our node knows the proof, and it is valid | |||||
wait_for_proof(node, proofid_hex) | |||||
raw_proof = node.getrawavalancheproof(proofid_hex) | |||||
assert_equal(raw_proof["orphan"], False) | |||||
# Mature the utxo then spend it | # Mature the utxo then spend it | ||||
node.generate(100) | node.generate(100) | ||||
utxo = proof.stakes[0].stake.utxo | utxo = proof.stakes[0].stake.utxo | ||||
raw_tx = node.createrawtransaction( | raw_tx = node.createrawtransaction( | ||||
inputs=[{ | inputs=[{ | ||||
# coinbase | # coinbase | ||||
"txid": "{:064x}".format(utxo.hash), | "txid": "{:064x}".format(utxo.hash), | ||||
"vout": utxo.n | "vout": utxo.n | ||||
}], | }], | ||||
outputs={ADDRESS_BCHREG_UNSPENDABLE: 25_000_000 - 250.00}, | outputs={ADDRESS_BCHREG_UNSPENDABLE: 25_000_000 - 250.00}, | ||||
) | ) | ||||
signed_tx = self.nodes[0].signrawtransactionwithkey( | signed_tx = self.nodes[0].signrawtransactionwithkey( | ||||
hexstring=raw_tx, | hexstring=raw_tx, | ||||
privkeys=[node.get_deterministic_priv_key().key], | privkeys=[node.get_deterministic_priv_key().key], | ||||
) | ) | ||||
node.sendrawtransaction(signed_tx['hex']) | node.sendrawtransaction(signed_tx['hex']) | ||||
# Mine the tx in a block | # Mine the tx in a block | ||||
node.generate(1) | node.generate(1) | ||||
wait_for_proof(node, proofid_hex) | |||||
raw_proof = node.getrawavalancheproof(proofid_hex) | # Wait for the proof to be orphaned | ||||
assert_equal(raw_proof["orphan"], True) | wait_until(lambda: node.getrawavalancheproof( | ||||
proofid_hex)["orphan"] is True) | |||||
# It should no longer be broadcasted | # It should no longer be broadcasted | ||||
peers = add_peers(3) | peers = add_peers(3) | ||||
node.mockscheduler(MAX_INITIAL_BROADCAST_DELAY + 1) | node.mockscheduler(MAX_INITIAL_BROADCAST_DELAY + 1) | ||||
peers[-1].sync_with_ping() | peers[-1].sync_with_ping() | ||||
assert not proof_inv_received(peers) | assert not proof_inv_received(peers) | ||||
Show All 10 Lines |