From 64da258345d14e9f1b5de5c488a59cd40a5f06df Mon Sep 17 00:00:00 2001 From: Reeshav Acharya Date: Wed, 4 Sep 2024 13:21:24 +0545 Subject: [PATCH] Generate valid hardfork action --- gov-action-loader/backend/app/transaction.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gov-action-loader/backend/app/transaction.py b/gov-action-loader/backend/app/transaction.py index e0cb2736f..0d9027960 100644 --- a/gov-action-loader/backend/app/transaction.py +++ b/gov-action-loader/backend/app/transaction.py @@ -91,12 +91,16 @@ def generate_quorom(): return {"numerator": numerator, "denominator": denomintor} -def generate_hardfork(): - majorProtocolNum = random.randint(1, 9) - minorProtocolNum = random.randint(1, 9) +def generate_hardfork(current_pParams): + protocol_version = [current_pParams["protocolVersion"]["major"], + current_pParams["protocolVersion"]["minor"]] + + # Randomly select an index (0 for major, 1 for minor) and increment it + protocol_version[random.randint(0, 1)] += 1 + return { "hardfork": { - "protocolVersion": {"major": majorProtocolNum, "minor": minorProtocolNum} + "protocolVersion": {"major": protocol_version[0], "minor": protocol_version[1]} } } @@ -149,7 +153,7 @@ def get_proposal_data_from_type(proposal_type, current_pParams): } } case "hardfork": - return generate_hardfork() + return generate_hardfork(current_pParams) case "update-parameters": # read current protocol parameters from json # get one of the keys of the pp