Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14864927
D17997.id53715.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D17997.id53715.diff
View Options
diff --git a/test/functional/abc_p2p_avalanche_contender_voting.py b/test/functional/abc_p2p_avalanche_contender_voting.py
--- a/test/functional/abc_p2p_avalanche_contender_voting.py
+++ b/test/functional/abc_p2p_avalanche_contender_voting.py
@@ -5,6 +5,7 @@
import math
import time
+from test_framework.authproxy import JSONRPCException
from test_framework.avatools import (
assert_response,
avalanche_proof_from_hex,
@@ -521,13 +522,26 @@
avakey = ECPubKey()
avakey.set(bytes.fromhex(node.getavalanchekey()))
+ # It is possible staking rewards are not ready depending if they were computed before or
+ # after proofs were finalized.
+ def expected_contender_poll_response(tip):
+ try:
+ if len(node.getstakingreward(tip)) > 0:
+ return AvalancheContenderVoteError.ACCEPTED
+ except JSONRPCException:
+ # An exception is thrown if staking rewards cannot be computed
+ pass
+ return AvalancheContenderVoteError.PENDING
+
+ expected_response = expected_contender_poll_response(tip)
+
# Sanity check that new quorum contenders can be polled even though we have not mined a block yet
for contender_id in get_all_contender_ids(tip):
poll_node.send_poll([contender_id], inv_type=MSG_AVA_STAKE_CONTENDER)
assert_response(
poll_node,
avakey,
- [AvalancheVote(AvalancheContenderVoteError.PENDING, contender_id)],
+ [AvalancheVote(expected_response, contender_id)],
)
# Proofs from the prior quorum that were persisted were loaded back into the contender cache
@@ -538,7 +552,7 @@
assert_response(
poll_node,
avakey,
- [AvalancheVote(AvalancheContenderVoteError.PENDING, contender_id)],
+ [AvalancheVote(expected_response, contender_id)],
)
# Set last proof as remote
@@ -554,6 +568,7 @@
# Trigger contenders promotion
tip = self.generate(node, 1)[0]
+ expected_response = expected_contender_poll_response(tip)
# Sanity check
for contender_id in get_all_contender_ids(tip):
@@ -561,7 +576,7 @@
assert_response(
poll_node,
avakey,
- [AvalancheVote(AvalancheContenderVoteError.PENDING, contender_id)],
+ [AvalancheVote(expected_response, contender_id)],
)
# All proofs from the prior quorum were promoted
@@ -572,7 +587,7 @@
assert_response(
poll_node,
avakey,
- [AvalancheVote(AvalancheContenderVoteError.PENDING, contender_id)],
+ [AvalancheVote(expected_response, contender_id)],
)
self.log.info("Check votes when immature proof matures")
@@ -629,6 +644,7 @@
# Trigger contenders promotion and mature the proof
tip = self.generate(node, 1)[0]
+ expected_response = expected_contender_poll_response(tip)
self.wait_until(lambda: check_immature_proofs([]))
# The proof is now mature so it has been added to the contender cache.
@@ -638,7 +654,7 @@
assert_response(
poll_node,
avakey,
- [AvalancheVote(AvalancheContenderVoteError.PENDING, contender_id)],
+ [AvalancheVote(expected_response, contender_id)],
)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, May 20, 23:19 (3 m, 16 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5863433
Default Alt Text
D17997.id53715.diff (3 KB)
Attached To
D17997: [avalanche] Fix staking reward flakiness after node restart in contenders test
Event Timeline
Log In to Comment