-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from multiversx/tests-for-pr-6114
Scenarios for PR 6114
- Loading branch information
Showing
15 changed files
with
479 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import requests | ||
from config import DEFAULT_PROXY | ||
from chain_commander import add_blocks | ||
import time | ||
|
||
|
||
def force_reset_validator_statistics(): | ||
route = f"{DEFAULT_PROXY}/simulator/force-reset-validator-statistics" | ||
response = requests.post(route) | ||
response.raise_for_status() | ||
|
||
# add an extra block | ||
add_blocks(1) | ||
|
||
# wait 1 sec | ||
time.sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
testing-suite/staking-v4/network_provider/get_delegation_info.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import requests | ||
from config import DEFAULT_PROXY | ||
from helpers import base64_to_hex | ||
from multiversx_sdk_core import Address | ||
|
||
|
||
def get_delegation_contract_address_from_tx(tx_hash): | ||
response = requests.get(f"{DEFAULT_PROXY}/transaction/{tx_hash}?withResults=True") | ||
response.raise_for_status() | ||
parsed = response.json() | ||
|
||
general_data = parsed.get("data") | ||
transaction_data = general_data.get("transaction") | ||
logs_data = transaction_data.get("logs") | ||
events_data = logs_data.get("events") | ||
first_set_of_events = events_data[0] | ||
topics = first_set_of_events.get("topics") | ||
delegation_contract_address = topics[1] | ||
|
||
delegation_contract_address = base64_to_hex(delegation_contract_address) | ||
delegation_contract_address = Address.from_hex(delegation_contract_address, "erd").to_bech32() | ||
|
||
return delegation_contract_address |
28 changes: 28 additions & 0 deletions
28
testing-suite/staking-v4/network_provider/get_staking_info.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import requests | ||
import json | ||
from multiversx_sdk_core import Address | ||
from constants import VALIDATOR_CONTRACT | ||
from config import DEFAULT_PROXY | ||
from helpers import base64_to_string | ||
|
||
|
||
def get_total_staked(owner: str): | ||
address_in_hex = Address.from_bech32(owner).to_hex() | ||
post_body = { | ||
"scAddress": VALIDATOR_CONTRACT, | ||
"funcName": "getTotalStaked", | ||
"args": [address_in_hex] | ||
} | ||
|
||
json_structure = json.dumps(post_body) | ||
response = requests.post(f"{DEFAULT_PROXY}/vm-values/query", data=json_structure) | ||
response.raise_for_status() | ||
parsed = response.json() | ||
|
||
general_data = parsed.get("data") | ||
tx_response_data = general_data.get("data") | ||
total_staked_list = tx_response_data.get("returnData") | ||
total_staked = total_staked_list[0] | ||
|
||
total_staked = base64_to_string(total_staked) | ||
return total_staked |
33 changes: 33 additions & 0 deletions
33
testing-suite/staking-v4/network_provider/get_transaction_info.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
import requests | ||
from config import DEFAULT_PROXY | ||
from helpers import string_to_base64 | ||
|
||
|
||
def get_status_of_tx(tx_hash: str) -> str: | ||
response = requests.get(f"{DEFAULT_PROXY}/transaction/{tx_hash}/process-status") | ||
response.raise_for_status() | ||
parsed = response.json() | ||
|
||
if "transaction not found" in response.text: | ||
return "expired" | ||
|
||
general_data = parsed.get("data") | ||
status = general_data.get("status") | ||
return status | ||
|
||
|
||
def check_if_error_is_present_in_tx(error, tx_hash) -> bool: | ||
flag = False | ||
error_bytes = string_to_base64(error) | ||
|
||
response = requests.get(f"{DEFAULT_PROXY}/transaction/{tx_hash}?withResults=True") | ||
response.raise_for_status() | ||
|
||
if error_bytes.decode() in response.text: | ||
flag = True | ||
|
||
if error in response.text: | ||
flag = True | ||
|
||
return error_bytes.decode() in response.text or error in response.text |
Oops, something went wrong.