Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_rpc_getavalancheinfo.py
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.log.info("The test node has no proof") | self.log.info("The test node has no proof") | ||||
assert_avalancheinfo({ | assert_avalancheinfo({ | ||||
"active": False, | "active": False, | ||||
"network": { | "network": { | ||||
"proof_count": 0, | "proof_count": 0, | ||||
"connected_proof_count": 0, | "connected_proof_count": 0, | ||||
"dangling_proof_count": 0, | |||||
"finalized_proof_count": 0, | "finalized_proof_count": 0, | ||||
"conflicting_proof_count": 0, | "conflicting_proof_count": 0, | ||||
"orphan_proof_count": 0, | "orphan_proof_count": 0, | ||||
"total_stake_amount": Decimal('0.00'), | "total_stake_amount": Decimal('0.00'), | ||||
"connected_stake_amount": Decimal('0.00'), | "connected_stake_amount": Decimal('0.00'), | ||||
"dangling_stake_amount": Decimal('0.00'), | |||||
"node_count": 0, | "node_count": 0, | ||||
"connected_node_count": 0, | "connected_node_count": 0, | ||||
"pending_node_count": 0, | "pending_node_count": 0, | ||||
} | } | ||||
}) | }) | ||||
self.log.info("The test node has a proof") | self.log.info("The test node has a proof") | ||||
Show All 9 Lines | def run_test(self): | ||||
"proofid": f"{proof.proofid:0{64}x}", | "proofid": f"{proof.proofid:0{64}x}", | ||||
"limited_proofid": f"{proof.limited_proofid:0{64}x}", | "limited_proofid": f"{proof.limited_proofid:0{64}x}", | ||||
"master": privkey.get_pubkey().get_bytes().hex(), | "master": privkey.get_pubkey().get_bytes().hex(), | ||||
"stake_amount": coinbase_amount, | "stake_amount": coinbase_amount, | ||||
}, | }, | ||||
"network": { | "network": { | ||||
"proof_count": 0, | "proof_count": 0, | ||||
"connected_proof_count": 0, | "connected_proof_count": 0, | ||||
"dangling_proof_count": 0, | |||||
"finalized_proof_count": 0, | "finalized_proof_count": 0, | ||||
"conflicting_proof_count": 0, | "conflicting_proof_count": 0, | ||||
"orphan_proof_count": 0, | "orphan_proof_count": 0, | ||||
"total_stake_amount": Decimal('0.00'), | "total_stake_amount": Decimal('0.00'), | ||||
"connected_stake_amount": Decimal('0.00'), | "connected_stake_amount": Decimal('0.00'), | ||||
"dangling_stake_amount": Decimal('0.00'), | |||||
"node_count": 0, | "node_count": 0, | ||||
"connected_node_count": 0, | "connected_node_count": 0, | ||||
"pending_node_count": 0, | "pending_node_count": 0, | ||||
} | } | ||||
}) | }) | ||||
# Mine a block to trigger proof validation | # Mine a block to trigger proof validation | ||||
node.generate(1) | node.generate(1) | ||||
self.wait_until( | self.wait_until( | ||||
lambda: node.getavalancheinfo() == handle_legacy_format({ | lambda: node.getavalancheinfo() == handle_legacy_format({ | ||||
"active": False, | "active": False, | ||||
"local": { | "local": { | ||||
"live": True, | "live": True, | ||||
"proofid": f"{proof.proofid:0{64}x}", | "proofid": f"{proof.proofid:0{64}x}", | ||||
"limited_proofid": f"{proof.limited_proofid:0{64}x}", | "limited_proofid": f"{proof.limited_proofid:0{64}x}", | ||||
"master": privkey.get_pubkey().get_bytes().hex(), | "master": privkey.get_pubkey().get_bytes().hex(), | ||||
"stake_amount": coinbase_amount, | "stake_amount": coinbase_amount, | ||||
}, | }, | ||||
"network": { | "network": { | ||||
"proof_count": 0, | "proof_count": 0, | ||||
"connected_proof_count": 0, | "connected_proof_count": 0, | ||||
"dangling_proof_count": 0, | |||||
"finalized_proof_count": 0, | "finalized_proof_count": 0, | ||||
"conflicting_proof_count": 0, | "conflicting_proof_count": 0, | ||||
"orphan_proof_count": 0, | "orphan_proof_count": 0, | ||||
"total_stake_amount": Decimal('0.00'), | "total_stake_amount": Decimal('0.00'), | ||||
"connected_stake_amount": Decimal('0.00'), | "connected_stake_amount": Decimal('0.00'), | ||||
"dangling_stake_amount": Decimal('0.00'), | |||||
"node_count": 0, | "node_count": 0, | ||||
"connected_node_count": 0, | "connected_node_count": 0, | ||||
"pending_node_count": 0, | "pending_node_count": 0, | ||||
} | } | ||||
}) | }) | ||||
) | ) | ||||
self.log.info("Connect a bunch of peers and nodes") | self.log.info("Connect a bunch of peers and nodes") | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
"proofid": f"{proof.proofid:0{64}x}", | "proofid": f"{proof.proofid:0{64}x}", | ||||
"limited_proofid": f"{proof.limited_proofid:0{64}x}", | "limited_proofid": f"{proof.limited_proofid:0{64}x}", | ||||
"master": privkey.get_pubkey().get_bytes().hex(), | "master": privkey.get_pubkey().get_bytes().hex(), | ||||
"stake_amount": coinbase_amount, | "stake_amount": coinbase_amount, | ||||
}, | }, | ||||
"network": { | "network": { | ||||
"proof_count": N, | "proof_count": N, | ||||
"connected_proof_count": N, | "connected_proof_count": N, | ||||
"dangling_proof_count": 0, | |||||
"finalized_proof_count": 0, | "finalized_proof_count": 0, | ||||
"conflicting_proof_count": N, | "conflicting_proof_count": N, | ||||
"orphan_proof_count": 1, | "orphan_proof_count": 1, | ||||
"total_stake_amount": coinbase_amount * N, | "total_stake_amount": coinbase_amount * N, | ||||
"connected_stake_amount": coinbase_amount * N, | "connected_stake_amount": coinbase_amount * N, | ||||
"dangling_stake_amount": Decimal('0.00'), | |||||
"node_count": N, | "node_count": N, | ||||
"connected_node_count": N, | "connected_node_count": N, | ||||
"pending_node_count": 0, | "pending_node_count": 0, | ||||
} | } | ||||
}) | }) | ||||
) | ) | ||||
self.log.info("Disconnect some nodes") | self.log.info("Disconnect some nodes") | ||||
Show All 12 Lines | def run_test(self): | ||||
"proofid": f"{proof.proofid:0{64}x}", | "proofid": f"{proof.proofid:0{64}x}", | ||||
"limited_proofid": f"{proof.limited_proofid:0{64}x}", | "limited_proofid": f"{proof.limited_proofid:0{64}x}", | ||||
"master": privkey.get_pubkey().get_bytes().hex(), | "master": privkey.get_pubkey().get_bytes().hex(), | ||||
"stake_amount": coinbase_amount, | "stake_amount": coinbase_amount, | ||||
}, | }, | ||||
"network": { | "network": { | ||||
"proof_count": N, | "proof_count": N, | ||||
"connected_proof_count": N - D, | "connected_proof_count": N - D, | ||||
"dangling_proof_count": D, | |||||
"finalized_proof_count": 0, | "finalized_proof_count": 0, | ||||
"conflicting_proof_count": N, | "conflicting_proof_count": N, | ||||
"orphan_proof_count": 1, | "orphan_proof_count": 1, | ||||
"total_stake_amount": coinbase_amount * N, | "total_stake_amount": coinbase_amount * N, | ||||
"connected_stake_amount": coinbase_amount * (N - D), | "connected_stake_amount": coinbase_amount * (N - D), | ||||
"dangling_stake_amount": coinbase_amount * D, | |||||
"node_count": N - D, | "node_count": N - D, | ||||
"connected_node_count": N - D, | "connected_node_count": N - D, | ||||
"pending_node_count": 0, | "pending_node_count": 0, | ||||
} | } | ||||
}) | }) | ||||
) | ) | ||||
self.log.info("Add some pending nodes") | self.log.info("Add some pending nodes") | ||||
Show All 30 Lines | def run_test(self): | ||||
"limited_proofid": f"{proof.limited_proofid:0{64}x}", | "limited_proofid": f"{proof.limited_proofid:0{64}x}", | ||||
"master": privkey.get_pubkey().get_bytes().hex(), | "master": privkey.get_pubkey().get_bytes().hex(), | ||||
"stake_amount": coinbase_amount, | "stake_amount": coinbase_amount, | ||||
}, | }, | ||||
"network": { | "network": { | ||||
# Orphan became mature | # Orphan became mature | ||||
"proof_count": N + 1, | "proof_count": N + 1, | ||||
"connected_proof_count": N - D, | "connected_proof_count": N - D, | ||||
"dangling_proof_count": D + 1, | |||||
"finalized_proof_count": 0, | "finalized_proof_count": 0, | ||||
"conflicting_proof_count": N, | "conflicting_proof_count": N, | ||||
"orphan_proof_count": 0, | "orphan_proof_count": 0, | ||||
"total_stake_amount": coinbase_amount * (N + 1), | "total_stake_amount": coinbase_amount * (N + 1), | ||||
"connected_stake_amount": coinbase_amount * (N - D), | "connected_stake_amount": coinbase_amount * (N - D), | ||||
"dangling_stake_amount": coinbase_amount * (D + 1), | |||||
"node_count": N - D + P, | "node_count": N - D + P, | ||||
"connected_node_count": N - D, | "connected_node_count": N - D, | ||||
"pending_node_count": P, | "pending_node_count": P, | ||||
} | } | ||||
}) | }) | ||||
self.log.info("Finalize the proofs for some peers") | self.log.info("Finalize the proofs for some peers") | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
"proofid": f"{proof.proofid:0{64}x}", | "proofid": f"{proof.proofid:0{64}x}", | ||||
"limited_proofid": f"{proof.limited_proofid:0{64}x}", | "limited_proofid": f"{proof.limited_proofid:0{64}x}", | ||||
"master": privkey.get_pubkey().get_bytes().hex(), | "master": privkey.get_pubkey().get_bytes().hex(), | ||||
"stake_amount": coinbase_amount, | "stake_amount": coinbase_amount, | ||||
}, | }, | ||||
"network": { | "network": { | ||||
"proof_count": N + 1, | "proof_count": N + 1, | ||||
"connected_proof_count": 0, | "connected_proof_count": 0, | ||||
"dangling_proof_count": N + 1, | |||||
"finalized_proof_count": N + 1, | "finalized_proof_count": N + 1, | ||||
"conflicting_proof_count": 0, | "conflicting_proof_count": 0, | ||||
"orphan_proof_count": 0, | "orphan_proof_count": 0, | ||||
"total_stake_amount": coinbase_amount * (N + 1), | "total_stake_amount": coinbase_amount * (N + 1), | ||||
"connected_stake_amount": 0, | "connected_stake_amount": 0, | ||||
"dangling_stake_amount": coinbase_amount * (N + 1), | |||||
"node_count": 0, | "node_count": 0, | ||||
"connected_node_count": 0, | "connected_node_count": 0, | ||||
"pending_node_count": 0, | "pending_node_count": 0, | ||||
} | } | ||||
}) | }) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
GetAvalancheInfoTest().main() | GetAvalancheInfoTest().main() |