Merge pull request #35 from MaxMustermann2/validator-sigs
add `hex_to_one`, fix `bech32` installation, bug fixpull/36/head
commit
d12bde7328
@ -0,0 +1,404 @@ |
|||||||
|
[style] |
||||||
|
# Align closing bracket with visual indentation. |
||||||
|
align_closing_bracket_with_visual_indent=True |
||||||
|
|
||||||
|
# Allow dictionary keys to exist on multiple lines. For example: |
||||||
|
# |
||||||
|
# x = { |
||||||
|
# ('this is the first element of a tuple', |
||||||
|
# 'this is the second element of a tuple'): |
||||||
|
# value, |
||||||
|
# } |
||||||
|
allow_multiline_dictionary_keys=False |
||||||
|
|
||||||
|
# Allow lambdas to be formatted on more than one line. |
||||||
|
allow_multiline_lambdas=False |
||||||
|
|
||||||
|
# Allow splitting before a default / named assignment in an argument list. |
||||||
|
allow_split_before_default_or_named_assigns=True |
||||||
|
|
||||||
|
# Allow splits before the dictionary value. |
||||||
|
allow_split_before_dict_value=False |
||||||
|
|
||||||
|
# Let spacing indicate operator precedence. For example: |
||||||
|
# |
||||||
|
# a = 1 * 2 + 3 / 4 |
||||||
|
# b = 1 / 2 - 3 * 4 |
||||||
|
# c = (1 + 2) * (3 - 4) |
||||||
|
# d = (1 - 2) / (3 + 4) |
||||||
|
# e = 1 * 2 - 3 |
||||||
|
# f = 1 + 2 + 3 + 4 |
||||||
|
# |
||||||
|
# will be formatted as follows to indicate precedence: |
||||||
|
# |
||||||
|
# a = 1*2 + 3/4 |
||||||
|
# b = 1/2 - 3*4 |
||||||
|
# c = (1+2) * (3-4) |
||||||
|
# d = (1-2) / (3+4) |
||||||
|
# e = 1*2 - 3 |
||||||
|
# f = 1 + 2 + 3 + 4 |
||||||
|
# |
||||||
|
arithmetic_precedence_indication=False |
||||||
|
|
||||||
|
# Number of blank lines surrounding top-level function and class |
||||||
|
# definitions. |
||||||
|
blank_lines_around_top_level_definition=2 |
||||||
|
|
||||||
|
# Number of blank lines between top-level imports and variable |
||||||
|
# definitions. |
||||||
|
blank_lines_between_top_level_imports_and_variables=1 |
||||||
|
|
||||||
|
# Insert a blank line before a class-level docstring. |
||||||
|
blank_line_before_class_docstring=False |
||||||
|
|
||||||
|
# Insert a blank line before a module docstring. |
||||||
|
blank_line_before_module_docstring=False |
||||||
|
|
||||||
|
# Insert a blank line before a 'def' or 'class' immediately nested |
||||||
|
# within another 'def' or 'class'. For example: |
||||||
|
# |
||||||
|
# class Foo: |
||||||
|
# # <------ this blank line |
||||||
|
# def method(): |
||||||
|
# ... |
||||||
|
blank_line_before_nested_class_or_def=False |
||||||
|
|
||||||
|
# Do not split consecutive brackets. Only relevant when |
||||||
|
# dedent_closing_brackets is set. For example: |
||||||
|
# |
||||||
|
# call_func_that_takes_a_dict( |
||||||
|
# { |
||||||
|
# 'key1': 'value1', |
||||||
|
# 'key2': 'value2', |
||||||
|
# } |
||||||
|
# ) |
||||||
|
# |
||||||
|
# would reformat to: |
||||||
|
# |
||||||
|
# call_func_that_takes_a_dict({ |
||||||
|
# 'key1': 'value1', |
||||||
|
# 'key2': 'value2', |
||||||
|
# }) |
||||||
|
coalesce_brackets=False |
||||||
|
|
||||||
|
# The column limit. |
||||||
|
column_limit=80 |
||||||
|
|
||||||
|
# The style for continuation alignment. Possible values are: |
||||||
|
# |
||||||
|
# - SPACE: Use spaces for continuation alignment. This is default behavior. |
||||||
|
# - FIXED: Use fixed number (CONTINUATION_INDENT_WIDTH) of columns |
||||||
|
# (ie: CONTINUATION_INDENT_WIDTH/INDENT_WIDTH tabs or |
||||||
|
# CONTINUATION_INDENT_WIDTH spaces) for continuation alignment. |
||||||
|
# - VALIGN-RIGHT: Vertically align continuation lines to multiple of |
||||||
|
# INDENT_WIDTH columns. Slightly right (one tab or a few spaces) if |
||||||
|
# cannot vertically align continuation lines with indent characters. |
||||||
|
continuation_align_style=SPACE |
||||||
|
|
||||||
|
# Indent width used for line continuations. |
||||||
|
continuation_indent_width=4 |
||||||
|
|
||||||
|
# Put closing brackets on a separate line, dedented, if the bracketed |
||||||
|
# expression can't fit in a single line. Applies to all kinds of brackets, |
||||||
|
# including function definitions and calls. For example: |
||||||
|
# |
||||||
|
# config = { |
||||||
|
# 'key1': 'value1', |
||||||
|
# 'key2': 'value2', |
||||||
|
# } # <--- this bracket is dedented and on a separate line |
||||||
|
# |
||||||
|
# time_series = self.remote_client.query_entity_counters( |
||||||
|
# entity='dev3246.region1', |
||||||
|
# key='dns.query_latency_tcp', |
||||||
|
# transform=Transformation.AVERAGE(window=timedelta(seconds=60)), |
||||||
|
# start_ts=now()-timedelta(days=3), |
||||||
|
# end_ts=now(), |
||||||
|
# ) # <--- this bracket is dedented and on a separate line |
||||||
|
dedent_closing_brackets=True |
||||||
|
|
||||||
|
# Disable the heuristic which places each list element on a separate line |
||||||
|
# if the list is comma-terminated. |
||||||
|
disable_ending_comma_heuristic=True |
||||||
|
|
||||||
|
# Place each dictionary entry onto its own line. |
||||||
|
each_dict_entry_on_separate_line=True |
||||||
|
|
||||||
|
# Require multiline dictionary even if it would normally fit on one line. |
||||||
|
# For example: |
||||||
|
# |
||||||
|
# config = { |
||||||
|
# 'key1': 'value1' |
||||||
|
# } |
||||||
|
force_multiline_dict=True |
||||||
|
|
||||||
|
# The regex for an i18n comment. The presence of this comment stops |
||||||
|
# reformatting of that line, because the comments are required to be |
||||||
|
# next to the string they translate. |
||||||
|
i18n_comment=#\..* |
||||||
|
|
||||||
|
# The i18n function call names. The presence of this function stops |
||||||
|
# reformattting on that line, because the string it has cannot be moved |
||||||
|
# away from the i18n comment. |
||||||
|
i18n_function_call=N_, _ |
||||||
|
|
||||||
|
# Indent blank lines. |
||||||
|
indent_blank_lines=False |
||||||
|
|
||||||
|
# Put closing brackets on a separate line, indented, if the bracketed |
||||||
|
# expression can't fit in a single line. Applies to all kinds of brackets, |
||||||
|
# including function definitions and calls. For example: |
||||||
|
# |
||||||
|
# config = { |
||||||
|
# 'key1': 'value1', |
||||||
|
# 'key2': 'value2', |
||||||
|
# } # <--- this bracket is indented and on a separate line |
||||||
|
# |
||||||
|
# time_series = self.remote_client.query_entity_counters( |
||||||
|
# entity='dev3246.region1', |
||||||
|
# key='dns.query_latency_tcp', |
||||||
|
# transform=Transformation.AVERAGE(window=timedelta(seconds=60)), |
||||||
|
# start_ts=now()-timedelta(days=3), |
||||||
|
# end_ts=now(), |
||||||
|
# ) # <--- this bracket is indented and on a separate line |
||||||
|
indent_closing_brackets=False |
||||||
|
|
||||||
|
# Indent the dictionary value if it cannot fit on the same line as the |
||||||
|
# dictionary key. For example: |
||||||
|
# |
||||||
|
# config = { |
||||||
|
# 'key1': |
||||||
|
# 'value1', |
||||||
|
# 'key2': value1 + |
||||||
|
# value2, |
||||||
|
# } |
||||||
|
indent_dictionary_value=False |
||||||
|
|
||||||
|
# The number of columns to use for indentation. |
||||||
|
indent_width=4 |
||||||
|
|
||||||
|
# Join short lines into one line. E.g., single line 'if' statements. |
||||||
|
join_multiple_lines=False |
||||||
|
|
||||||
|
# Do not include spaces around selected binary operators. For example: |
||||||
|
# |
||||||
|
# 1 + 2 * 3 - 4 / 5 |
||||||
|
# |
||||||
|
# will be formatted as follows when configured with "*,/": |
||||||
|
# |
||||||
|
# 1 + 2*3 - 4/5 |
||||||
|
no_spaces_around_selected_binary_operators= |
||||||
|
|
||||||
|
# Use spaces around default or named assigns. |
||||||
|
spaces_around_default_or_named_assign=True |
||||||
|
|
||||||
|
# Adds a space after the opening '{' and before the ending '}' dict |
||||||
|
# delimiters. |
||||||
|
# |
||||||
|
# {1: 2} |
||||||
|
# |
||||||
|
# will be formatted as: |
||||||
|
# |
||||||
|
# { 1: 2 } |
||||||
|
spaces_around_dict_delimiters=True |
||||||
|
|
||||||
|
# Adds a space after the opening '[' and before the ending ']' list |
||||||
|
# delimiters. |
||||||
|
# |
||||||
|
# [1, 2] |
||||||
|
# |
||||||
|
# will be formatted as: |
||||||
|
# |
||||||
|
# [ 1, 2 ] |
||||||
|
spaces_around_list_delimiters=True |
||||||
|
|
||||||
|
# Use spaces around the power operator. |
||||||
|
spaces_around_power_operator=False |
||||||
|
|
||||||
|
# Use spaces around the subscript / slice operator. For example: |
||||||
|
# |
||||||
|
# my_list[1 : 10 : 2] |
||||||
|
spaces_around_subscript_colon=True |
||||||
|
|
||||||
|
# Adds a space after the opening '(' and before the ending ')' tuple |
||||||
|
# delimiters. |
||||||
|
# |
||||||
|
# (1, 2, 3) |
||||||
|
# |
||||||
|
# will be formatted as: |
||||||
|
# |
||||||
|
# ( 1, 2, 3 ) |
||||||
|
spaces_around_tuple_delimiters=True |
||||||
|
|
||||||
|
# The number of spaces required before a trailing comment. |
||||||
|
# This can be a single value (representing the number of spaces |
||||||
|
# before each trailing comment) or list of values (representing |
||||||
|
# alignment column values; trailing comments within a block will |
||||||
|
# be aligned to the first column value that is greater than the maximum |
||||||
|
# line length within the block). For example: |
||||||
|
# |
||||||
|
# With spaces_before_comment=5: |
||||||
|
# |
||||||
|
# 1 + 1 # Adding values |
||||||
|
# |
||||||
|
# will be formatted as: |
||||||
|
# |
||||||
|
# 1 + 1 # Adding values <-- 5 spaces between the end of the |
||||||
|
# # statement and comment |
||||||
|
# |
||||||
|
# With spaces_before_comment=15, 20: |
||||||
|
# |
||||||
|
# 1 + 1 # Adding values |
||||||
|
# two + two # More adding |
||||||
|
# |
||||||
|
# longer_statement # This is a longer statement |
||||||
|
# short # This is a shorter statement |
||||||
|
# |
||||||
|
# a_very_long_statement_that_extends_beyond_the_final_column # Comment |
||||||
|
# short # This is a shorter statement |
||||||
|
# |
||||||
|
# will be formatted as: |
||||||
|
# |
||||||
|
# 1 + 1 # Adding values <-- end of line comments in block |
||||||
|
# # aligned to col 15 |
||||||
|
# two + two # More adding |
||||||
|
# |
||||||
|
# longer_statement # This is a longer statement <-- end of line |
||||||
|
# # comments in block aligned to col 20 |
||||||
|
# short # This is a shorter statement |
||||||
|
# |
||||||
|
# a_very_long_statement_that_extends_beyond_the_final_column # Comment <-- the end of line comments are aligned based on the line length |
||||||
|
# short # This is a shorter statement |
||||||
|
# |
||||||
|
spaces_before_comment=2 |
||||||
|
|
||||||
|
# Insert a space between the ending comma and closing bracket of a list, |
||||||
|
# etc. |
||||||
|
space_between_ending_comma_and_closing_bracket=True |
||||||
|
|
||||||
|
# Use spaces inside brackets, braces, and parentheses. For example: |
||||||
|
# |
||||||
|
# method_call( 1 ) |
||||||
|
# my_dict[ 3 ][ 1 ][ get_index( *args, **kwargs ) ] |
||||||
|
# my_set = { 1, 2, 3 } |
||||||
|
space_inside_brackets=True |
||||||
|
|
||||||
|
# Split before arguments |
||||||
|
split_all_comma_separated_values=True |
||||||
|
|
||||||
|
# Split before arguments, but do not split all subexpressions recursively |
||||||
|
# (unless needed). |
||||||
|
split_all_top_level_comma_separated_values=False |
||||||
|
|
||||||
|
# Split before arguments if the argument list is terminated by a |
||||||
|
# comma. |
||||||
|
split_arguments_when_comma_terminated=True |
||||||
|
|
||||||
|
# Set to True to prefer splitting before '+', '-', '*', '/', '//', or '@' |
||||||
|
# rather than after. |
||||||
|
split_before_arithmetic_operator=False |
||||||
|
|
||||||
|
# Set to True to prefer splitting before '&', '|' or '^' rather than |
||||||
|
# after. |
||||||
|
split_before_bitwise_operator=False |
||||||
|
|
||||||
|
# Split before the closing bracket if a list or dict literal doesn't fit on |
||||||
|
# a single line. |
||||||
|
split_before_closing_bracket=True |
||||||
|
|
||||||
|
# Split before a dictionary or set generator (comp_for). For example, note |
||||||
|
# the split before the 'for': |
||||||
|
# |
||||||
|
# foo = { |
||||||
|
# variable: 'Hello world, have a nice day!' |
||||||
|
# for variable in bar if variable != 42 |
||||||
|
# } |
||||||
|
split_before_dict_set_generator=True |
||||||
|
|
||||||
|
# Split before the '.' if we need to split a longer expression: |
||||||
|
# |
||||||
|
# foo = ('This is a really long string: {}, {}, {}, {}'.format(a, b, c, d)) |
||||||
|
# |
||||||
|
# would reformat to something like: |
||||||
|
# |
||||||
|
# foo = ('This is a really long string: {}, {}, {}, {}' |
||||||
|
# .format(a, b, c, d)) |
||||||
|
split_before_dot=True |
||||||
|
|
||||||
|
# Split after the opening paren which surrounds an expression if it doesn't |
||||||
|
# fit on a single line. |
||||||
|
split_before_expression_after_opening_paren=False |
||||||
|
|
||||||
|
# If an argument / parameter list is going to be split, then split before |
||||||
|
# the first argument. |
||||||
|
split_before_first_argument=False |
||||||
|
|
||||||
|
# Set to True to prefer splitting before 'and' or 'or' rather than |
||||||
|
# after. |
||||||
|
split_before_logical_operator=False |
||||||
|
|
||||||
|
# Split named assignments onto individual lines. |
||||||
|
split_before_named_assigns=True |
||||||
|
|
||||||
|
# Set to True to split list comprehensions and generators that have |
||||||
|
# non-trivial expressions and multiple clauses before each of these |
||||||
|
# clauses. For example: |
||||||
|
# |
||||||
|
# result = [ |
||||||
|
# a_long_var + 100 for a_long_var in xrange(1000) |
||||||
|
# if a_long_var % 10] |
||||||
|
# |
||||||
|
# would reformat to something like: |
||||||
|
# |
||||||
|
# result = [ |
||||||
|
# a_long_var + 100 |
||||||
|
# for a_long_var in xrange(1000) |
||||||
|
# if a_long_var % 10] |
||||||
|
split_complex_comprehension=True |
||||||
|
|
||||||
|
# The penalty for splitting right after the opening bracket. |
||||||
|
split_penalty_after_opening_bracket=300 |
||||||
|
|
||||||
|
# The penalty for splitting the line after a unary operator. |
||||||
|
split_penalty_after_unary_operator=10000 |
||||||
|
|
||||||
|
# The penalty of splitting the line around the '+', '-', '*', '/', '//', |
||||||
|
# ``%``, and '@' operators. |
||||||
|
split_penalty_arithmetic_operator=300 |
||||||
|
|
||||||
|
# The penalty for splitting right before an if expression. |
||||||
|
split_penalty_before_if_expr=0 |
||||||
|
|
||||||
|
# The penalty of splitting the line around the '&', '|', and '^' |
||||||
|
# operators. |
||||||
|
split_penalty_bitwise_operator=300 |
||||||
|
|
||||||
|
# The penalty for splitting a list comprehension or generator |
||||||
|
# expression. |
||||||
|
split_penalty_comprehension=2100 |
||||||
|
|
||||||
|
# The penalty for characters over the column limit. |
||||||
|
split_penalty_excess_character=7000 |
||||||
|
|
||||||
|
# The penalty incurred by adding a line split to the logical line. The |
||||||
|
# more line splits added the higher the penalty. |
||||||
|
split_penalty_for_added_line_split=30 |
||||||
|
|
||||||
|
# The penalty of splitting a list of "import as" names. For example: |
||||||
|
# |
||||||
|
# from a_very_long_or_indented_module_name_yada_yad import (long_argument_1, |
||||||
|
# long_argument_2, |
||||||
|
# long_argument_3) |
||||||
|
# |
||||||
|
# would reformat to something like: |
||||||
|
# |
||||||
|
# from a_very_long_or_indented_module_name_yada_yad import ( |
||||||
|
# long_argument_1, long_argument_2, long_argument_3) |
||||||
|
split_penalty_import_names=0 |
||||||
|
|
||||||
|
# The penalty of splitting the line around the 'and' and 'or' |
||||||
|
# operators. |
||||||
|
split_penalty_logical_operator=300 |
||||||
|
|
||||||
|
# Use the Tab character for indentation. |
||||||
|
use_tabs=False |
||||||
|
|
@ -1,11 +1,9 @@ |
|||||||
""" |
"""Provides pyhmy version information.""" |
||||||
Provides pyhmy version information. |
|
||||||
""" |
|
||||||
|
|
||||||
# This file is auto-generated! Do not edit! |
# This file is auto-generated! Do not edit! |
||||||
# Use `python -m incremental.update pyhmy` to change this file. |
# Use `python -m incremental.update pyhmy` to change this file. |
||||||
|
|
||||||
from incremental import Version |
from incremental import Version |
||||||
|
|
||||||
__version__ = Version('pyhmy', 20, 5, 20) |
__version__ = Version( "pyhmy", 20, 5, 20 ) |
||||||
__all__ = ["__version__"] |
__all__ = [ "__version__" ] |
||||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,18 @@ |
|||||||
|
""" |
||||||
|
Constants |
||||||
|
""" |
||||||
|
|
||||||
|
# localnet constants |
||||||
|
DEFAULT_ENDPOINT = 'http://localhost:9500' |
||||||
|
DEFAULT_TIMEOUT = 30 |
||||||
|
|
||||||
|
# staking percentage constants |
||||||
|
PRECISION = 18 |
||||||
|
MAX_DECIMAL = 1000000000000000000 |
||||||
|
|
||||||
|
NAME_CHAR_LIMIT = 140 |
||||||
|
IDENTITY_CHAR_LIMIT = 140 |
||||||
|
WEBSITE_CHAR_LIMIT = 140 |
||||||
|
SECURITY_CONTACT_CHAR_LIMIT = 140 |
||||||
|
DETAILS_CHAR_LIMIT = 280 |
||||||
|
MIN_REQUIRED_DELEGATION = int( 10000 * 1e18 ) |
@ -1,44 +1,38 @@ |
|||||||
from .rpc.exceptions import ( |
""" |
||||||
RPCError, |
Exceptions used by pyhmy |
||||||
RequestsError, |
""" |
||||||
RequestsTimeoutError |
|
||||||
) |
|
||||||
|
class InvalidRPCReplyError( RuntimeError ): |
||||||
class InvalidRPCReplyError(RuntimeError): |
"""Exception raised when RPC call returns unexpected result Generally |
||||||
""" |
indicates Harmony API has been updated & pyhmy library needs to be updated |
||||||
Exception raised when RPC call returns unexpected result |
as well.""" |
||||||
Generally indicates Harmony API has been updated & pyhmy library needs to be updated as well |
def __init__( self, method, endpoint ): |
||||||
""" |
super().__init__( f"Unexpected reply for {method} from {endpoint}" ) |
||||||
|
|
||||||
def __init__(self, method, endpoint): |
|
||||||
super().__init__(f'Unexpected reply for {method} from {endpoint}') |
class InvalidValidatorError( ValueError ): |
||||||
|
"""Exception raised Validator does not pass sanity checks.""" |
||||||
class InvalidValidatorError(ValueError): |
|
||||||
""" |
|
||||||
Exception raised Validator does not pass sanity checks |
|
||||||
""" |
|
||||||
|
|
||||||
errors = { |
errors = { |
||||||
1: 'Invalid ONE address', |
1: "Invalid ONE address", |
||||||
2: 'Field not initialized', |
2: "Field not initialized", |
||||||
3: 'Invalid field input', |
3: "Invalid field input", |
||||||
4: 'Error checking blockchain', |
4: "Error checking blockchain", |
||||||
5: 'Unable to import validator information from blockchain' |
5: "Unable to import validator information from blockchain", |
||||||
} |
} |
||||||
|
|
||||||
def __init__(self, err_code, msg): |
def __init__( self, err_code, msg ): |
||||||
self.code = err_code |
self.code = err_code |
||||||
self.msg = msg |
self.msg = msg |
||||||
super().__init__(msg) |
super().__init__( msg ) |
||||||
|
|
||||||
def __str__(self): |
def __str__( self ): |
||||||
return f'[Errno {self.code}] {self.errors[self.code]}: {self.msg}' |
return f"[Errno {self.code}] {self.errors[self.code]}: {self.msg}" |
||||||
|
|
||||||
class TxConfirmationTimedoutError(AssertionError): |
|
||||||
""" |
|
||||||
Exception raised when a transaction is sent to the chain |
|
||||||
But not confirmed during the timeout period specified |
|
||||||
""" |
|
||||||
|
|
||||||
def __init__(self, msg): |
class TxConfirmationTimedoutError( AssertionError ): |
||||||
super().__init__(f'{msg}') |
"""Exception raised when a transaction is sent to the chain But not |
||||||
|
confirmed during the timeout period specified.""" |
||||||
|
def __init__( self, msg ): |
||||||
|
super().__init__( f"{msg}" ) |
||||||
|
@ -1,27 +1,26 @@ |
|||||||
import requests |
""" |
||||||
|
RPC Specific Exceptions |
||||||
|
""" |
||||||
|
|
||||||
|
import requests |
||||||
|
|
||||||
class RPCError(RuntimeError): |
|
||||||
""" |
|
||||||
Exception raised when RPC call returns an error |
|
||||||
""" |
|
||||||
|
|
||||||
def __init__(self, method, endpoint, error): |
class RPCError( RuntimeError ): |
||||||
|
"""Exception raised when RPC call returns an error.""" |
||||||
|
def __init__( self, method, endpoint, error ): |
||||||
self.error = error |
self.error = error |
||||||
super().__init__(f'Error in reply from {endpoint}: {method} returned {error}') |
super().__init__( |
||||||
|
f"Error in reply from {endpoint}: {method} returned {error}" |
||||||
|
) |
||||||
|
|
||||||
class RequestsError(requests.exceptions.RequestException): |
|
||||||
""" |
|
||||||
Wrapper for requests lib exceptions |
|
||||||
""" |
|
||||||
|
|
||||||
def __init__(self, endpoint): |
class RequestsError( requests.exceptions.RequestException ): |
||||||
super().__init__(f'Error connecting to {endpoint}') |
"""Wrapper for requests lib exceptions.""" |
||||||
|
def __init__( self, endpoint ): |
||||||
|
super().__init__( f"Error connecting to {endpoint}" ) |
||||||
|
|
||||||
class RequestsTimeoutError(requests.exceptions.Timeout): |
|
||||||
""" |
|
||||||
Wrapper for requests lib Timeout exceptions |
|
||||||
""" |
|
||||||
|
|
||||||
def __init__(self, endpoint): |
class RequestsTimeoutError( requests.exceptions.Timeout ): |
||||||
super().__init__(f'Error connecting to {endpoint}') |
"""Wrapper for requests lib Timeout exceptions.""" |
||||||
|
def __init__( self, endpoint ): |
||||||
|
super().__init__( f"Error connecting to {endpoint}" ) |
||||||
|
@ -1,218 +1,325 @@ |
|||||||
from enum import ( |
""" |
||||||
Enum, |
Helper module for signing Harmony staking transactions |
||||||
auto |
""" |
||||||
) |
# disable most of the Lint here |
||||||
|
# pylint: disable=protected-access,no-member,invalid-name,missing-class-docstring,missing-function-docstring |
||||||
|
|
||||||
from rlp.sedes import ( |
from enum import Enum, auto |
||||||
big_endian_int, |
|
||||||
Binary, |
from rlp.sedes import big_endian_int, Binary, CountableList, List, Text |
||||||
CountableList, |
|
||||||
List, |
from eth_rlp import HashableRLP |
||||||
Text |
|
||||||
) |
from eth_utils.curried import ( to_int, hexstr_if_str, ) |
||||||
|
|
||||||
from eth_rlp import ( |
|
||||||
HashableRLP |
# https://github.com/harmony-one/sdk/blob/99a827782fabcd5f91f025af0d8de228956d42b4/packages/harmony-staking/src/stakingTransaction.ts#L120 |
||||||
) |
class Directive( Enum ): |
||||||
|
def _generate_next_value_( name, start, count, last_values ): # pylint: disable=no-self-argument |
||||||
from eth_utils.curried import ( |
|
||||||
to_int, |
|
||||||
hexstr_if_str, |
|
||||||
) |
|
||||||
|
|
||||||
class StakingSettings: |
|
||||||
PRECISION = 18 |
|
||||||
MAX_DECIMAL = 1000000000000000000 |
|
||||||
|
|
||||||
class Directive(Enum): # https://github.com/harmony-one/sdk/blob/99a827782fabcd5f91f025af0d8de228956d42b4/packages/harmony-staking/src/stakingTransaction.ts#L120 |
|
||||||
def _generate_next_value_(name, start, count, last_values): |
|
||||||
return count |
return count |
||||||
|
|
||||||
CreateValidator = auto() |
CreateValidator = auto() |
||||||
EditValidator = auto() |
EditValidator = auto() |
||||||
Delegate = auto() |
Delegate = auto() |
||||||
Undelegate = auto() |
Undelegate = auto() |
||||||
CollectRewards = auto() |
CollectRewards = auto() |
||||||
|
|
||||||
|
|
||||||
FORMATTERS = { |
FORMATTERS = { |
||||||
'directive': hexstr_if_str(to_int), # delegatorAddress is already formatted before the call |
"directive": hexstr_if_str( |
||||||
'nonce': hexstr_if_str(to_int), |
to_int |
||||||
'gasPrice': hexstr_if_str(to_int), |
), # delegatorAddress is already formatted before the call |
||||||
'gasLimit': hexstr_if_str(to_int), |
"nonce": hexstr_if_str(to_int), |
||||||
'chainId': hexstr_if_str(to_int), |
"gasPrice": hexstr_if_str(to_int), |
||||||
|
"gasLimit": hexstr_if_str(to_int), |
||||||
|
"chainId": hexstr_if_str(to_int), |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
class CollectRewards: |
class CollectRewards: |
||||||
@staticmethod |
@staticmethod |
||||||
def UnsignedChainId(): |
def UnsignedChainId(): |
||||||
class UnsignedChainId(HashableRLP): |
class UnsignedChainId( HashableRLP ): |
||||||
fields = ( |
fields = ( |
||||||
('directive', big_endian_int), |
( "directive", |
||||||
('stakeMsg', CountableList(Binary.fixed_length(20, allow_empty=True))), |
big_endian_int ), |
||||||
('nonce', big_endian_int), |
( |
||||||
('gasPrice', big_endian_int), |
"stakeMsg", |
||||||
('gasLimit', big_endian_int), |
CountableList( |
||||||
('chainId', big_endian_int), |
Binary.fixed_length( 20, |
||||||
|
allow_empty = True ) |
||||||
|
) |
||||||
|
), |
||||||
|
( "nonce", |
||||||
|
big_endian_int ), |
||||||
|
( "gasPrice", |
||||||
|
big_endian_int ), |
||||||
|
( "gasLimit", |
||||||
|
big_endian_int ), |
||||||
|
( "chainId", |
||||||
|
big_endian_int ), |
||||||
) |
) |
||||||
|
|
||||||
return UnsignedChainId |
return UnsignedChainId |
||||||
|
|
||||||
@staticmethod |
@staticmethod |
||||||
def SignedChainId(): |
def SignedChainId(): |
||||||
class SignedChainId(HashableRLP): |
class SignedChainId( HashableRLP ): |
||||||
fields = CollectRewards.UnsignedChainId()._meta.fields[:-1] + ( # drop chainId |
fields = CollectRewards.UnsignedChainId()._meta.fields[ |
||||||
|
:-1 |
||||||
|
] + ( # drop chainId |
||||||
("v", big_endian_int), |
("v", big_endian_int), |
||||||
("r", big_endian_int), |
("r", big_endian_int), |
||||||
("s", big_endian_int), |
("s", big_endian_int), |
||||||
) |
) |
||||||
|
|
||||||
return SignedChainId |
return SignedChainId |
||||||
|
|
||||||
@staticmethod |
@staticmethod |
||||||
def Unsigned(): |
def Unsigned(): |
||||||
class Unsigned(HashableRLP): |
class Unsigned( HashableRLP ): |
||||||
fields = CollectRewards.UnsignedChainId()._meta.fields[:-1] # drop chainId |
fields = CollectRewards.UnsignedChainId( |
||||||
|
)._meta.fields[ :-1 ] # drop chainId |
||||||
|
|
||||||
return Unsigned |
return Unsigned |
||||||
|
|
||||||
@staticmethod |
@staticmethod |
||||||
def Signed(): |
def Signed(): |
||||||
class Signed(HashableRLP): |
class Signed( HashableRLP ): |
||||||
fields = CollectRewards.Unsigned()._meta.fields[:-3] + ( # drop last 3 for raw.pop() |
fields = CollectRewards.Unsigned()._meta.fields[ |
||||||
|
:-3 |
||||||
|
] + ( # drop last 3 for raw.pop() |
||||||
("v", big_endian_int), |
("v", big_endian_int), |
||||||
("r", big_endian_int), |
("r", big_endian_int), |
||||||
("s", big_endian_int), |
("s", big_endian_int), |
||||||
) |
) |
||||||
|
|
||||||
return Signed |
return Signed |
||||||
|
|
||||||
|
|
||||||
class DelegateOrUndelegate: |
class DelegateOrUndelegate: |
||||||
@staticmethod |
@staticmethod |
||||||
def UnsignedChainId(): |
def UnsignedChainId(): |
||||||
class UnsignedChainId(HashableRLP): |
class UnsignedChainId( HashableRLP ): |
||||||
fields = ( |
fields = ( |
||||||
('directive', big_endian_int), |
( "directive", |
||||||
('stakeMsg', List([Binary.fixed_length(20, allow_empty=True),Binary.fixed_length(20, allow_empty=True),big_endian_int],True)), |
big_endian_int ), |
||||||
('nonce', big_endian_int), |
( |
||||||
('gasPrice', big_endian_int), |
"stakeMsg", |
||||||
('gasLimit', big_endian_int), |
List( |
||||||
('chainId', big_endian_int), |
[ |
||||||
|
Binary.fixed_length( 20, |
||||||
|
allow_empty = True ), |
||||||
|
Binary.fixed_length( 20, |
||||||
|
allow_empty = True ), |
||||||
|
big_endian_int, |
||||||
|
], |
||||||
|
True, |
||||||
|
), |
||||||
|
), |
||||||
|
( "nonce", |
||||||
|
big_endian_int ), |
||||||
|
( "gasPrice", |
||||||
|
big_endian_int ), |
||||||
|
( "gasLimit", |
||||||
|
big_endian_int ), |
||||||
|
( "chainId", |
||||||
|
big_endian_int ), |
||||||
) |
) |
||||||
|
|
||||||
return UnsignedChainId |
return UnsignedChainId |
||||||
|
|
||||||
@staticmethod |
@staticmethod |
||||||
def SignedChainId(): |
def SignedChainId(): |
||||||
class SignedChainId(HashableRLP): |
class SignedChainId( HashableRLP ): |
||||||
fields = DelegateOrUndelegate.UnsignedChainId()._meta.fields[:-1] + ( # drop chainId |
fields = DelegateOrUndelegate.UnsignedChainId()._meta.fields[ |
||||||
|
:-1 |
||||||
|
] + ( # drop chainId |
||||||
("v", big_endian_int), |
("v", big_endian_int), |
||||||
("r", big_endian_int), |
("r", big_endian_int), |
||||||
("s", big_endian_int), |
("s", big_endian_int), |
||||||
) |
) |
||||||
|
|
||||||
return SignedChainId |
return SignedChainId |
||||||
|
|
||||||
@staticmethod |
@staticmethod |
||||||
def Unsigned(): |
def Unsigned(): |
||||||
class Unsigned(HashableRLP): |
class Unsigned( HashableRLP ): |
||||||
fields = DelegateOrUndelegate.UnsignedChainId()._meta.fields[:-1] # drop chainId |
fields = DelegateOrUndelegate.UnsignedChainId( |
||||||
|
)._meta.fields[ :-1 ] # drop chainId |
||||||
|
|
||||||
return Unsigned |
return Unsigned |
||||||
|
|
||||||
@staticmethod |
@staticmethod |
||||||
def Signed(): |
def Signed(): |
||||||
class Signed(HashableRLP): |
class Signed( HashableRLP ): |
||||||
fields = DelegateOrUndelegate.Unsigned()._meta.fields[:-3] + ( # drop last 3 for raw.pop() |
fields = DelegateOrUndelegate.Unsigned()._meta.fields[ |
||||||
|
:-3 |
||||||
|
] + ( # drop last 3 for raw.pop() |
||||||
("v", big_endian_int), |
("v", big_endian_int), |
||||||
("r", big_endian_int), |
("r", big_endian_int), |
||||||
("s", big_endian_int), |
("s", big_endian_int), |
||||||
) |
) |
||||||
|
|
||||||
return Signed |
return Signed |
||||||
|
|
||||||
|
|
||||||
class CreateValidator: |
class CreateValidator: |
||||||
@staticmethod |
@staticmethod |
||||||
def UnsignedChainId(): |
def UnsignedChainId(): |
||||||
class UnsignedChainId(HashableRLP): |
class UnsignedChainId( HashableRLP ): |
||||||
fields = ( |
fields = ( |
||||||
('directive', big_endian_int), |
("directive", big_endian_int), |
||||||
('stakeMsg', List([ # list with the following members |
( |
||||||
Binary.fixed_length(20, allow_empty=True), # validatorAddress |
"stakeMsg", |
||||||
List([Text()]*5,True), # description is Text of 5 elements |
List( |
||||||
List([List([big_endian_int],True)]*3,True), # commission rate is made up of 3 integers in an array [ [int1], [int2], [int3] ] |
[ # list with the following members |
||||||
|
# validatorAddress |
||||||
|
Binary.fixed_length( |
||||||
|
20, allow_empty=True |
||||||
|
), |
||||||
|
# description is Text of 5 elements |
||||||
|
List( |
||||||
|
[Text()] * 5, True |
||||||
|
), |
||||||
|
# commission rate is made up of 3 integers in an array |
||||||
|
List( |
||||||
|
[List([big_endian_int], True)] * 3, True |
||||||
|
), |
||||||
big_endian_int, # min self delegation |
big_endian_int, # min self delegation |
||||||
big_endian_int, # max total delegation |
big_endian_int, # max total delegation |
||||||
CountableList(Binary.fixed_length(48, allow_empty=True)), # bls-public-keys array of unspecified length, each key of 48 |
# bls-public-keys array of unspecified length, each key of 48 |
||||||
|
CountableList( |
||||||
|
Binary.fixed_length(48, allow_empty=True) |
||||||
|
), |
||||||
|
# bls-key-sigs array of unspecified length, each sig of 96 |
||||||
|
CountableList( |
||||||
|
Binary.fixed_length(96, allow_empty=True) |
||||||
|
), |
||||||
big_endian_int, # amount |
big_endian_int, # amount |
||||||
], True)), # strictly these number of elements |
], |
||||||
('nonce', big_endian_int), |
True, |
||||||
('gasPrice', big_endian_int), |
), |
||||||
('gasLimit', big_endian_int), |
), # strictly these number of elements |
||||||
('chainId', big_endian_int), |
("nonce", big_endian_int), |
||||||
|
("gasPrice", big_endian_int), |
||||||
|
("gasLimit", big_endian_int), |
||||||
|
("chainId", big_endian_int), |
||||||
) |
) |
||||||
|
|
||||||
return UnsignedChainId |
return UnsignedChainId |
||||||
|
|
||||||
@staticmethod |
@staticmethod |
||||||
def SignedChainId(): |
def SignedChainId(): |
||||||
class SignedChainId(HashableRLP): |
class SignedChainId( HashableRLP ): |
||||||
fields = CreateValidator.UnsignedChainId()._meta.fields[:-1] + ( # drop chainId |
fields = CreateValidator.UnsignedChainId()._meta.fields[ |
||||||
|
:-1 |
||||||
|
] + ( # drop chainId |
||||||
("v", big_endian_int), |
("v", big_endian_int), |
||||||
("r", big_endian_int), |
("r", big_endian_int), |
||||||
("s", big_endian_int), |
("s", big_endian_int), |
||||||
) |
) |
||||||
|
|
||||||
return SignedChainId |
return SignedChainId |
||||||
|
|
||||||
@staticmethod |
@staticmethod |
||||||
def Unsigned(): |
def Unsigned(): |
||||||
class Unsigned(HashableRLP): |
class Unsigned( HashableRLP ): |
||||||
fields = CreateValidator.UnsignedChainId()._meta.fields[:-1] # drop chainId |
fields = CreateValidator.UnsignedChainId( |
||||||
|
)._meta.fields[ :-1 ] # drop chainId |
||||||
|
|
||||||
return Unsigned |
return Unsigned |
||||||
|
|
||||||
@staticmethod |
@staticmethod |
||||||
def Signed(): |
def Signed(): |
||||||
class Signed(HashableRLP): |
class Signed( HashableRLP ): |
||||||
fields = CreateValidator.Unsigned()._meta.fields[:-3] + ( # drop last 3 for raw.pop() |
fields = CreateValidator.Unsigned()._meta.fields[ |
||||||
|
:-3 |
||||||
|
] + ( # drop last 3 for raw.pop() |
||||||
("v", big_endian_int), |
("v", big_endian_int), |
||||||
("r", big_endian_int), |
("r", big_endian_int), |
||||||
("s", big_endian_int), |
("s", big_endian_int), |
||||||
) |
) |
||||||
|
|
||||||
return Signed |
return Signed |
||||||
|
|
||||||
|
|
||||||
class EditValidator: |
class EditValidator: |
||||||
@staticmethod |
@staticmethod |
||||||
def UnsignedChainId(): |
def UnsignedChainId(): |
||||||
class UnsignedChainId(HashableRLP): |
class UnsignedChainId( HashableRLP ): |
||||||
fields = ( |
fields = ( |
||||||
('directive', big_endian_int), |
("directive", big_endian_int), |
||||||
('stakeMsg', List([ # list with the following members |
( |
||||||
Binary.fixed_length(20, allow_empty=True), # validatorAddress |
"stakeMsg", |
||||||
List([Text()]*5,True), # description is Text of 5 elements |
List( |
||||||
List([big_endian_int],True), # new rate is in a list |
[ # list with the following members |
||||||
|
# validatorAddress |
||||||
|
Binary.fixed_length( |
||||||
|
20, allow_empty=True |
||||||
|
), |
||||||
|
# description is Text of 5 elements |
||||||
|
List( |
||||||
|
[Text()] * 5, True |
||||||
|
), |
||||||
|
# new rate is in a list |
||||||
|
List([big_endian_int], True), |
||||||
big_endian_int, # min self delegation |
big_endian_int, # min self delegation |
||||||
big_endian_int, # max total delegation |
big_endian_int, # max total delegation |
||||||
Binary.fixed_length(48, allow_empty=True), # slot key to remove |
# slot key to remove |
||||||
Binary.fixed_length(48, allow_empty=True), # slot key to add |
Binary.fixed_length( |
||||||
], True)), # strictly these number of elements |
48, allow_empty=True |
||||||
('nonce', big_endian_int), |
), |
||||||
('gasPrice', big_endian_int), |
# slot key to add |
||||||
('gasLimit', big_endian_int), |
Binary.fixed_length( |
||||||
('chainId', big_endian_int), |
48, allow_empty=True |
||||||
|
), |
||||||
|
# slot key to add sig |
||||||
|
Binary.fixed_length( |
||||||
|
96, allow_empty=True |
||||||
|
), |
||||||
|
], |
||||||
|
True, |
||||||
|
), |
||||||
|
), # strictly these number of elements |
||||||
|
("nonce", big_endian_int), |
||||||
|
("gasPrice", big_endian_int), |
||||||
|
("gasLimit", big_endian_int), |
||||||
|
("chainId", big_endian_int), |
||||||
) |
) |
||||||
|
|
||||||
return UnsignedChainId |
return UnsignedChainId |
||||||
|
|
||||||
@staticmethod |
@staticmethod |
||||||
def SignedChainId(): |
def SignedChainId(): |
||||||
class SignedChainId(HashableRLP): |
class SignedChainId( HashableRLP ): |
||||||
fields = EditValidator.UnsignedChainId()._meta.fields[:-1] + ( # drop chainId |
fields = EditValidator.UnsignedChainId()._meta.fields[ |
||||||
|
:-1 |
||||||
|
] + ( # drop chainId |
||||||
("v", big_endian_int), |
("v", big_endian_int), |
||||||
("r", big_endian_int), |
("r", big_endian_int), |
||||||
("s", big_endian_int), |
("s", big_endian_int), |
||||||
) |
) |
||||||
|
|
||||||
return SignedChainId |
return SignedChainId |
||||||
|
|
||||||
@staticmethod |
@staticmethod |
||||||
def Unsigned(): |
def Unsigned(): |
||||||
class Unsigned(HashableRLP): |
class Unsigned( HashableRLP ): |
||||||
fields = EditValidator.UnsignedChainId()._meta.fields[:-1] # drop chainId |
fields = EditValidator.UnsignedChainId( |
||||||
|
)._meta.fields[ :-1 ] # drop chainId |
||||||
|
|
||||||
return Unsigned |
return Unsigned |
||||||
|
|
||||||
@staticmethod |
@staticmethod |
||||||
def Signed(): |
def Signed(): |
||||||
class Signed(HashableRLP): |
class Signed( HashableRLP ): |
||||||
fields = EditValidator.Unsigned()._meta.fields[:-3] + ( # drop last 3 for raw.pop() |
fields = EditValidator.Unsigned()._meta.fields[ |
||||||
|
:-3 |
||||||
|
] + ( # drop last 3 for raw.pop() |
||||||
("v", big_endian_int), |
("v", big_endian_int), |
||||||
("r", big_endian_int), |
("r", big_endian_int), |
||||||
("s", big_endian_int), |
("s", big_endian_int), |
||||||
) |
) |
||||||
|
|
||||||
return Signed |
return Signed |
||||||
|
@ -0,0 +1,578 @@ |
|||||||
|
{ |
||||||
|
"cells": [ |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 105, |
||||||
|
"id": "feee22ef", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [], |
||||||
|
"source": [ |
||||||
|
"from pyhmy import signing, staking_signing, numbers, transaction, account, validator as validator_module, staking_structures, contract\n", |
||||||
|
"from web3 import Web3" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 3, |
||||||
|
"id": "55b8db60", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [], |
||||||
|
"source": [ |
||||||
|
"# we need five transactions in conftest\n", |
||||||
|
"# simple transfer (from localnet address)\n", |
||||||
|
"# contract creation (from second address)\n", |
||||||
|
"# cross shard transfer (from second address)\n", |
||||||
|
"# validator creation (from localnet address)\n", |
||||||
|
"# delegation (from second address)" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "markdown", |
||||||
|
"id": "e104724c", |
||||||
|
"metadata": {}, |
||||||
|
"source": [ |
||||||
|
"### Simple Transfer" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 144, |
||||||
|
"id": "d7fa35f8", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [], |
||||||
|
"source": [ |
||||||
|
"pk = \"1f84c95ac16e6a50f08d44c7bde7aff8742212fda6e4321fde48bf83bef266dc\"\n", |
||||||
|
"tx = {\n", |
||||||
|
" 'from': 'one155jp2y76nazx8uw5sa94fr0m4s5aj8e5xm6fu3',\n", |
||||||
|
" # 3c86ac59f6b038f584be1c08fced78d7c71bb55d5655f81714f3cddc82144c65\n", |
||||||
|
" 'to': 'one1ru3p8ff0wsyl7ncsx3vwd5szuze64qz60upg37',\n", |
||||||
|
" 'gasPrice': Web3.toWei( 100, 'gwei' ),\n", |
||||||
|
" 'gas': 21000,\n", |
||||||
|
" 'chainId': 2, # localnet\n", |
||||||
|
" 'value': int( numbers.convert_one_to_atto( 503 ) ),\n", |
||||||
|
" 'nonce': 0,\n", |
||||||
|
" 'shardID': 0,\n", |
||||||
|
" 'toShardID': 0,\n", |
||||||
|
"}\n", |
||||||
|
"raw_tx = signing.sign_transaction(tx, pk).rawTransaction.hex()\n", |
||||||
|
"tx_hash = transaction.send_raw_transaction(raw_tx)" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 145, |
||||||
|
"id": "ed907d4b", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"name": "stdout", |
||||||
|
"output_type": "stream", |
||||||
|
"text": [ |
||||||
|
"0xf86f8085174876e8008252088080941f2213a52f7409ff4f103458e6d202e0b3aa805a891b4486fafde57c00008027a0d7c0b20207dcc9dde376822dc3f5625eac6f59a7526111695cdba3e29553ca17a05d4ca9a421ae16f89cbf6848186eaea7a800da732446dff9952e7c1e91d414e3\n", |
||||||
|
"0xc26be5776aa57438bccf196671a2d34f3f22c9c983c0f844c62b2fb90403aa43\n" |
||||||
|
] |
||||||
|
} |
||||||
|
], |
||||||
|
"source": [ |
||||||
|
"print( raw_tx )\n", |
||||||
|
"print( tx_hash )" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "markdown", |
||||||
|
"id": "1bbee37b", |
||||||
|
"metadata": {}, |
||||||
|
"source": [ |
||||||
|
"### Contract Creation" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 147, |
||||||
|
"id": "b143507b", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [], |
||||||
|
"source": [ |
||||||
|
"pk = '3c86ac59f6b038f584be1c08fced78d7c71bb55d5655f81714f3cddc82144c65'\n", |
||||||
|
"data = \"0x6080604052348015600f57600080fd5b50607780601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80634936cd3614602d575b600080fd5b604080516001815290519081900360200190f3fea2646970667358221220fa3fa0e8d0267831a59f4dd5edf39a513d07e98461cb06660ad28d4beda744cd64736f6c634300080f0033\"\n", |
||||||
|
"tx = {\n", |
||||||
|
" 'gasPrice': Web3.toWei( 100, 'gwei' ),\n", |
||||||
|
" 'gas': 100000,\n", |
||||||
|
" 'chainId': 2,\n", |
||||||
|
" 'nonce': 0,\n", |
||||||
|
" 'shardID': 0,\n", |
||||||
|
" 'toShardID': 0,\n", |
||||||
|
" 'data': data,\n", |
||||||
|
"}\n", |
||||||
|
"raw_tx = signing.sign_transaction(tx, pk).rawTransaction.hex()\n", |
||||||
|
"tx_hash = transaction.send_raw_transaction(raw_tx)" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 148, |
||||||
|
"id": "53dbcbff", |
||||||
|
"metadata": { |
||||||
|
"scrolled": true |
||||||
|
}, |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"name": "stdout", |
||||||
|
"output_type": "stream", |
||||||
|
"text": [ |
||||||
|
"0xf8e88085174876e800830186a080808080b8946080604052348015600f57600080fd5b50607780601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80634936cd3614602d575b600080fd5b604080516001815290519081900360200190f3fea2646970667358221220fa3fa0e8d0267831a59f4dd5edf39a513d07e98461cb06660ad28d4beda744cd64736f6c634300080f003327a08bf26ee0120c296b17af507f62606abdb5c5f09a65642c3d30b349b8bfbb3d69a03ec7be51c615bcbf2f1d63f6eaa56cf8d7be81671717f90239619830a81ebc9f\n", |
||||||
|
"0xa605852dd2fa39ed42e101c17aaca9d344d352ba9b24b14b9af94ec9cb58b31f\n" |
||||||
|
] |
||||||
|
} |
||||||
|
], |
||||||
|
"source": [ |
||||||
|
"print( raw_tx )\n", |
||||||
|
"print( tx_hash )" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 130, |
||||||
|
"id": "6e66392b", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [], |
||||||
|
"source": [ |
||||||
|
"contract_address = transaction.get_transaction_receipt( tx_hash ).get( 'contractAddress' )\n", |
||||||
|
"deployed = contract.get_code( contract_address, 'latest' )" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 131, |
||||||
|
"id": "ead2f9d4", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"name": "stdout", |
||||||
|
"output_type": "stream", |
||||||
|
"text": [ |
||||||
|
"0x6080604052348015600f57600080fd5b506004361060285760003560e01c80634936cd3614602d575b600080fd5b604080516001815290519081900360200190f3fea2646970667358221220fa3fa0e8d0267831a59f4dd5edf39a513d07e98461cb06660ad28d4beda744cd64736f6c634300080f0033\n", |
||||||
|
"0x6080604052348015600f57600080fd5b50607780601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80634936cd3614602d575b600080fd5b604080516001815290519081900360200190f3fea2646970667358221220fa3fa0e8d0267831a59f4dd5edf39a513d07e98461cb06660ad28d4beda744cd64736f6c634300080f0033\n" |
||||||
|
] |
||||||
|
} |
||||||
|
], |
||||||
|
"source": [ |
||||||
|
"print( deployed )\n", |
||||||
|
"print( data )" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 132, |
||||||
|
"id": "453a34d6", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"name": "stdout", |
||||||
|
"output_type": "stream", |
||||||
|
"text": [ |
||||||
|
"3300f080003436c6f63746dc447adeb4d82da06660bc16489e70d315a93fde5dd4f95a1387620d8e0af3af0221228537660796462aef3f091002063009180915092518100615080406b5df080006b575d2064163dc63943608c10e065300067582060163400605b5df08000675f0065108432504060806x0\n", |
||||||
|
"3300f080003436c6f63746dc447adeb4d82da06660bc16489e70d315a93fde5dd4f95a1387620d8e0af3af0221228537660796462aef3f091002063009180915092518100615080406b5df080006b575d2064163dc63943608c10e065300067582060163400605b5df08000675f0065108432504060806ef3f0006930006d10608770605b5df08000675f0065108432504060806x0\n" |
||||||
|
] |
||||||
|
} |
||||||
|
], |
||||||
|
"source": [ |
||||||
|
"print( \"\".join( [ deployed[ len( deployed ) - ( i + 1 ) ] for i in range( len( deployed ) ) ] ) )\n", |
||||||
|
"print( \"\".join( [ data[ len( data ) - ( i + 1 ) ] for i in range( len( data ) ) ] ) )" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 133, |
||||||
|
"id": "d251d1bf", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"data": { |
||||||
|
"text/plain": [ |
||||||
|
"True" |
||||||
|
] |
||||||
|
}, |
||||||
|
"execution_count": 133, |
||||||
|
"metadata": {}, |
||||||
|
"output_type": "execute_result" |
||||||
|
} |
||||||
|
], |
||||||
|
"source": [ |
||||||
|
"\"0x6080604052348015600f57600080fd5b506004361060285760003560e01c80634936cd3614602d575b600080fd5b604080516001815290519081900360200190f3fea2646970667358221220fa3fa0e8d0267831a59f4dd5edf39a513d07e98461cb06660ad28d4beda744cd64736f6c634300080f0033\" == deployed" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "markdown", |
||||||
|
"id": "812e033c", |
||||||
|
"metadata": {}, |
||||||
|
"source": [ |
||||||
|
"### Cross Shard Transfer" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 149, |
||||||
|
"id": "d7c70614", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [], |
||||||
|
"source": [ |
||||||
|
"pk = '3c86ac59f6b038f584be1c08fced78d7c71bb55d5655f81714f3cddc82144c65'\n", |
||||||
|
"tx = {\n", |
||||||
|
" 'from': 'one1ru3p8ff0wsyl7ncsx3vwd5szuze64qz60upg37',\n", |
||||||
|
" 'gasPrice': Web3.toWei( 100, 'gwei' ),\n", |
||||||
|
" 'gas': 21000,\n", |
||||||
|
" 'chainId': 2,\n", |
||||||
|
" 'nonce': 1,\n", |
||||||
|
" 'shardID': 0,\n", |
||||||
|
" 'toShardID': 1,\n", |
||||||
|
" 'to': 'one1e8rdglh97t37prtnv7k35ymnh2wazujpzsmzes',\n", |
||||||
|
" 'value': Web3.toWei( 100, 'gwei' ),\n", |
||||||
|
"}\n", |
||||||
|
"raw_tx = signing.sign_transaction(tx, pk).rawTransaction.hex()\n", |
||||||
|
"tx_hash = transaction.send_raw_transaction(raw_tx)" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 150, |
||||||
|
"id": "f20990f1", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"name": "stdout", |
||||||
|
"output_type": "stream", |
||||||
|
"text": [ |
||||||
|
"0xf86b0185174876e800825208800194c9c6d47ee5f2e3e08d7367ad1a1373ba9dd1724185174876e8008027a02501c517220e9499f14e97c20b0a88cd3b7ba80637bba43ed295422e69a3f300a079b8e1213c9506184aed6ac2eb0b2cb00594c3f9fcdd6c088937ce17fe47107c\n", |
||||||
|
"0xf73ba634cb96fc0e3e2c9d3b4c91379e223741be4a5aa56e6d6caf49c1ae75cf\n" |
||||||
|
] |
||||||
|
} |
||||||
|
], |
||||||
|
"source": [ |
||||||
|
"print( raw_tx )\n", |
||||||
|
"print( tx_hash )" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 153, |
||||||
|
"id": "66f024b9", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"data": { |
||||||
|
"text/plain": [ |
||||||
|
"0" |
||||||
|
] |
||||||
|
}, |
||||||
|
"execution_count": 153, |
||||||
|
"metadata": {}, |
||||||
|
"output_type": "execute_result" |
||||||
|
} |
||||||
|
], |
||||||
|
"source": [ |
||||||
|
"account.get_balance( 'one1e8rdglh97t37prtnv7k35ymnh2wazujpzsmzes', 'http://localhost:9502' )" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "markdown", |
||||||
|
"id": "2b2446df", |
||||||
|
"metadata": {}, |
||||||
|
"source": [ |
||||||
|
"### Validator Creation" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 154, |
||||||
|
"id": "c3513c37", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [], |
||||||
|
"source": [ |
||||||
|
"pk = \"1f84c95ac16e6a50f08d44c7bde7aff8742212fda6e4321fde48bf83bef266dc\"\n", |
||||||
|
"address = \"one155jp2y76nazx8uw5sa94fr0m4s5aj8e5xm6fu3\"\n", |
||||||
|
"info = {\n", |
||||||
|
" \"name\": \"Alice\",\n", |
||||||
|
" \"identity\": \"alice\",\n", |
||||||
|
" \"website\": \"alice.harmony.one\",\n", |
||||||
|
" \"security-contact\": \"Bob\",\n", |
||||||
|
" \"details\": \"Are you even reading this?\",\n", |
||||||
|
" \"min-self-delegation\": int( numbers.convert_one_to_atto( 10000 ) ),\n", |
||||||
|
" \"max-total-delegation\": int( numbers.convert_one_to_atto( 100000 ) ),\n", |
||||||
|
" \"rate\": \"0.1\",\n", |
||||||
|
" \"max-rate\": \"0.9\",\n", |
||||||
|
" \"max-change-rate\": \"0.05\",\n", |
||||||
|
" \"bls-public-keys\": [\n", |
||||||
|
" # private key is b1f2a5029f5f43c8c933a61ce936ced030b2c9379f8e2478fc888fa670cdbc89b8cd1ebc29b5b00a81d3152bb3aaa3a337404f50bee5e434430ca3693a94a1c102a765cf3b0887b8b0bcf5317d33f4bec60a97feae2498a39ab7a1c2\n", |
||||||
|
" # blspass.txt is empty\n", |
||||||
|
" \"0xa20e70089664a874b00251c5e85d35a73871531306f3af43e02138339d294e6bb9c4eb82162199c6a852afeaa8d68712\",\n", |
||||||
|
" ],\n", |
||||||
|
" \"amount\": int( numbers.convert_one_to_atto( 10000 ) ),\n", |
||||||
|
" \"bls-key-sigs\": [\n", |
||||||
|
" \"0xef2c49a2f31fbbd23c21bc176eaf05cd0bebe6832033075d81fea7cff6f9bc1ab42f3b6895c5493fe645d8379d2eaa1413de55a9d3ce412a4f747cb57d52cc4da4754bfb2583ec9a41fe5dd48287f964f276336699959a5fcef3391dc24df00d\",\n", |
||||||
|
" ]\n", |
||||||
|
"}\n", |
||||||
|
"validator = validator_module.Validator( address )\n", |
||||||
|
"validator.load( info )\n", |
||||||
|
"raw_tx = validator.sign_create_validator_transaction(\n", |
||||||
|
" 1,\n", |
||||||
|
" Web3.toWei( 100, 'gwei' ),\n", |
||||||
|
" 55000000, # gas limit\n", |
||||||
|
" pk,\n", |
||||||
|
" 2 # chain id\n", |
||||||
|
").rawTransaction.hex()\n", |
||||||
|
"tx_hash = transaction.send_raw_staking_transaction(\n", |
||||||
|
" raw_tx,\n", |
||||||
|
")" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 155, |
||||||
|
"id": "9b12f75f", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"name": "stdout", |
||||||
|
"output_type": "stream", |
||||||
|
"text": [ |
||||||
|
"0xf9017c80f9012994a5241513da9f4463f1d4874b548dfbac29d91f34f83d85416c69636585616c69636591616c6963652e6861726d6f6e792e6f6e6583426f629a41726520796f75206576656e2072656164696e6720746869733fddc988016345785d8a0000c9880c7d713b49da0000c887b1a2bc2ec500008a021e19e0c9bab24000008a152d02c7e14af6800000f1b0a20e70089664a874b00251c5e85d35a73871531306f3af43e02138339d294e6bb9c4eb82162199c6a852afeaa8d68712f862b860ef2c49a2f31fbbd23c21bc176eaf05cd0bebe6832033075d81fea7cff6f9bc1ab42f3b6895c5493fe645d8379d2eaa1413de55a9d3ce412a4f747cb57d52cc4da4754bfb2583ec9a41fe5dd48287f964f276336699959a5fcef3391dc24df00d8a021e19e0c9bab24000000185174876e8008403473bc028a08c1146305eaef981aa24c2f17c8519664d10c99ee42acedbc258749930d31a7ca031dadf114ee6ab9bd09933208094c65037b66c796bcfc57a70158106b37357b0\n", |
||||||
|
"0x400e9831d358f5daccd153cad5bf53650a0d413bd8682ec0ffad55367d162968\n" |
||||||
|
] |
||||||
|
} |
||||||
|
], |
||||||
|
"source": [ |
||||||
|
"print( raw_tx )\n", |
||||||
|
"print( tx_hash )" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "markdown", |
||||||
|
"id": "4c2ff645", |
||||||
|
"metadata": {}, |
||||||
|
"source": [ |
||||||
|
"### Delegation" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 156, |
||||||
|
"id": "458d81b8", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"name": "stdout", |
||||||
|
"output_type": "stream", |
||||||
|
"text": [ |
||||||
|
"0xf88302f4941f2213a52f7409ff4f103458e6d202e0b3aa805a94a5241513da9f4463f1d4874b548dfbac29d91f3489056bc75e2d631000000285174876e80082c35028a02c5e953062dcdfa2de9723639b63bab45705eb6dfbfe7f44536ed266c3c7ca20a0742964e646338e7431874f70715565d99c01c762324355c69db34a9ed9de81d7\n", |
||||||
|
"0xc8177ace2049d9f4eb4a45fd6bd6b16f693573d036322c36774cc00d05a3e24f\n" |
||||||
|
] |
||||||
|
} |
||||||
|
], |
||||||
|
"source": [ |
||||||
|
"pk = \"3c86ac59f6b038f584be1c08fced78d7c71bb55d5655f81714f3cddc82144c65\"\n", |
||||||
|
"tx = {\n", |
||||||
|
" 'directive': staking_structures.Directive.Delegate,\n", |
||||||
|
" 'delegatorAddress': 'one1ru3p8ff0wsyl7ncsx3vwd5szuze64qz60upg37',\n", |
||||||
|
" 'validatorAddress': 'one155jp2y76nazx8uw5sa94fr0m4s5aj8e5xm6fu3',\n", |
||||||
|
" 'amount': Web3.toWei( 100, 'ether' ),\n", |
||||||
|
" 'nonce': 2,\n", |
||||||
|
" 'gasPrice': Web3.toWei( 100, 'gwei' ),\n", |
||||||
|
" 'gasLimit': 50000,\n", |
||||||
|
" 'chainId': 2,\n", |
||||||
|
"}\n", |
||||||
|
"raw_tx = staking_signing.sign_staking_transaction(\n", |
||||||
|
" tx,\n", |
||||||
|
" pk,\n", |
||||||
|
").rawTransaction.hex()\n", |
||||||
|
"tx_hash = transaction.send_raw_staking_transaction(\n", |
||||||
|
" raw_tx,\n", |
||||||
|
")\n", |
||||||
|
"print( raw_tx )\n", |
||||||
|
"print( tx_hash )" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "markdown", |
||||||
|
"id": "8efa5536", |
||||||
|
"metadata": {}, |
||||||
|
"source": [ |
||||||
|
"### test_transaction.py - transfer 105 ONE to another address" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 157, |
||||||
|
"id": "c3295fee", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [], |
||||||
|
"source": [ |
||||||
|
"pk = '3c86ac59f6b038f584be1c08fced78d7c71bb55d5655f81714f3cddc82144c65'\n", |
||||||
|
"tx = {\n", |
||||||
|
" 'from': 'one1ru3p8ff0wsyl7ncsx3vwd5szuze64qz60upg37',\n", |
||||||
|
" 'gasPrice': Web3.toWei( 100, 'gwei' ),\n", |
||||||
|
" 'gas': 21000,\n", |
||||||
|
" 'chainId': 2,\n", |
||||||
|
" 'nonce': 3,\n", |
||||||
|
" 'shardID': 0,\n", |
||||||
|
" 'toShardID': 0,\n", |
||||||
|
" 'to': 'one1e8rdglh97t37prtnv7k35ymnh2wazujpzsmzes',\n", |
||||||
|
" 'value': Web3.toWei( 105, 'ether' ),\n", |
||||||
|
"}\n", |
||||||
|
"raw_tx = signing.sign_transaction(tx, pk).rawTransaction.hex()\n", |
||||||
|
"tx_hash = transaction.send_raw_transaction(raw_tx)" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 158, |
||||||
|
"id": "af515c7e", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"name": "stdout", |
||||||
|
"output_type": "stream", |
||||||
|
"text": [ |
||||||
|
"0xf86f0385174876e800825208808094c9c6d47ee5f2e3e08d7367ad1a1373ba9dd172418905b12aefafa80400008027a07a4952b90bf38723a9197179a8e6d2e9b3a86fd6da4e66a9cf09fdc59783f757a053910798b311245525bd77d6119332458c2855102e4fb9e564f6a3b710d18bb0\n", |
||||||
|
"0x7ccd80f8513f76ec58b357c7a82a12a95e025d88f1444e953f90e3d86e222571\n" |
||||||
|
] |
||||||
|
} |
||||||
|
], |
||||||
|
"source": [ |
||||||
|
"print( raw_tx )\n", |
||||||
|
"print( tx_hash )" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "markdown", |
||||||
|
"id": "bb546b3e", |
||||||
|
"metadata": {}, |
||||||
|
"source": [ |
||||||
|
"### test_transaction.py - staking transaction" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 168, |
||||||
|
"id": "c14e2d6d", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"name": "stdout", |
||||||
|
"output_type": "stream", |
||||||
|
"text": [ |
||||||
|
"0xf88302f494c9c6d47ee5f2e3e08d7367ad1a1373ba9dd1724194a5241513da9f4463f1d4874b548dfbac29d91f3489056bc75e2d631000008085174876e80082c35027a0808ea7d27adf3b1f561e8da4676814084bb75ac541b616bece87c6446e6cc54ea02f19f0b14240354bd42ad60b0c7189873c0be87044e13072b0981a837ca76f64\n", |
||||||
|
"0xe7d07ef6d9fca595a14ceb0ca917bece7bedb15efe662300e9334a32ac1da629\n" |
||||||
|
] |
||||||
|
} |
||||||
|
], |
||||||
|
"source": [ |
||||||
|
"pk = \"ff9ef6b00a61672b4b7bedd5ac653439b56ac8ee808c99a1bd871cf51b7d60eb\"\n", |
||||||
|
"tx = {\n", |
||||||
|
" 'directive': staking_structures.Directive.Delegate,\n", |
||||||
|
" 'delegatorAddress': 'one1e8rdglh97t37prtnv7k35ymnh2wazujpzsmzes',\n", |
||||||
|
" 'validatorAddress': 'one155jp2y76nazx8uw5sa94fr0m4s5aj8e5xm6fu3',\n", |
||||||
|
" 'amount': Web3.toWei( 100, 'ether' ),\n", |
||||||
|
" 'nonce': 0,\n", |
||||||
|
" 'gasPrice': Web3.toWei( 100, 'gwei' ),\n", |
||||||
|
" 'gasLimit': 50000,\n", |
||||||
|
" 'chainId': 2,\n", |
||||||
|
"}\n", |
||||||
|
"raw_tx = staking_signing.sign_staking_transaction(\n", |
||||||
|
" tx,\n", |
||||||
|
" pk,\n", |
||||||
|
").rawTransaction.hex()\n", |
||||||
|
"tx_hash = transaction.send_raw_staking_transaction(\n", |
||||||
|
" raw_tx,\n", |
||||||
|
")\n", |
||||||
|
"print( raw_tx )\n", |
||||||
|
"print( tx_hash )" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 162, |
||||||
|
"id": "ebf296aa", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"data": { |
||||||
|
"text/plain": [ |
||||||
|
"{'blockHash': '0xf55f1fb3c9be76fb74370e8a7d8580327797d2d6082040074783207a171e2de6',\n", |
||||||
|
" 'blockNumber': 34,\n", |
||||||
|
" 'from': 'one1ru3p8ff0wsyl7ncsx3vwd5szuze64qz60upg37',\n", |
||||||
|
" 'hash': '0xf73ba634cb96fc0e3e2c9d3b4c91379e223741be4a5aa56e6d6caf49c1ae75cf',\n", |
||||||
|
" 'shardID': 0,\n", |
||||||
|
" 'to': 'one1e8rdglh97t37prtnv7k35ymnh2wazujpzsmzes',\n", |
||||||
|
" 'toShardID': 1,\n", |
||||||
|
" 'value': 100000000000}" |
||||||
|
] |
||||||
|
}, |
||||||
|
"execution_count": 162, |
||||||
|
"metadata": {}, |
||||||
|
"output_type": "execute_result" |
||||||
|
} |
||||||
|
], |
||||||
|
"source": [ |
||||||
|
"transaction.get_cx_receipt_by_hash( '0xf73ba634cb96fc0e3e2c9d3b4c91379e223741be4a5aa56e6d6caf49c1ae75cf', 'http://localhost:9502' )" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"execution_count": 166, |
||||||
|
"id": "ff0229ce", |
||||||
|
"metadata": {}, |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"data": { |
||||||
|
"text/plain": [ |
||||||
|
"{'blockHash': '0x0000000000000000000000000000000000000000000000000000000000000000',\n", |
||||||
|
" 'blockNumber': None,\n", |
||||||
|
" 'from': 'one1e8rdglh97t37prtnv7k35ymnh2wazujpzsmzes',\n", |
||||||
|
" 'gas': 50000,\n", |
||||||
|
" 'gasPrice': 100000000000,\n", |
||||||
|
" 'hash': '0x279935278d20d778cbe4fdfa5d51be9eb1eb184053dc9a7cb88ad3365df73060',\n", |
||||||
|
" 'msg': {'amount': 100000000000000000000,\n", |
||||||
|
" 'delegatorAddress': 'one1e8rdglh97t37prtnv7k35ymnh2wazujpzsmzes',\n", |
||||||
|
" 'validatorAddress': 'one155jp2y76nazx8uw5sa94fr0m4s5aj8e5xm6fu3'},\n", |
||||||
|
" 'nonce': 2,\n", |
||||||
|
" 'r': '0x8660a63c10af06f2fb3f24b92cf61d4f319044a1f1931c4f4e54ce986ff563c',\n", |
||||||
|
" 's': '0x597785559c4283d3ece2df37cbf37077966487a2a2dc0f4cdbbf75a8f20bc1a8',\n", |
||||||
|
" 'timestamp': 0,\n", |
||||||
|
" 'transactionIndex': 0,\n", |
||||||
|
" 'type': 'Delegate',\n", |
||||||
|
" 'v': '0x27'}" |
||||||
|
] |
||||||
|
}, |
||||||
|
"execution_count": 166, |
||||||
|
"metadata": {}, |
||||||
|
"output_type": "execute_result" |
||||||
|
} |
||||||
|
], |
||||||
|
"source": [ |
||||||
|
"transaction.get_staking_transaction_by_hash( \"0x279935278d20d778cbe4fdfa5d51be9eb1eb184053dc9a7cb88ad3365df73060\" )" |
||||||
|
] |
||||||
|
} |
||||||
|
], |
||||||
|
"metadata": { |
||||||
|
"kernelspec": { |
||||||
|
"display_name": "Python 3 (ipykernel)", |
||||||
|
"language": "python", |
||||||
|
"name": "python3" |
||||||
|
}, |
||||||
|
"language_info": { |
||||||
|
"codemirror_mode": { |
||||||
|
"name": "ipython", |
||||||
|
"version": 3 |
||||||
|
}, |
||||||
|
"file_extension": ".py", |
||||||
|
"mimetype": "text/x-python", |
||||||
|
"name": "python", |
||||||
|
"nbconvert_exporter": "python", |
||||||
|
"pygments_lexer": "ipython3", |
||||||
|
"version": "3.10.5" |
||||||
|
} |
||||||
|
}, |
||||||
|
"nbformat": 4, |
||||||
|
"nbformat_minor": 5 |
||||||
|
} |
@ -1,9 +1,9 @@ |
|||||||
from pyhmy.bech32 import ( |
from pyhmy.bech32 import bech32 |
||||||
bech32 |
|
||||||
) |
|
||||||
|
|
||||||
def test_encode(): |
def test_encode(): |
||||||
bech32.encode('one', 5, [121, 161]) |
bech32.encode( "one", 5, [ 121, 161 ] ) |
||||||
|
|
||||||
|
|
||||||
def test_decode(): |
def test_decode(): |
||||||
bech32.decode('one', 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9') |
bech32.decode( "one", "one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9" ) |
||||||
|
@ -1,36 +1,31 @@ |
|||||||
from decimal import Decimal |
from decimal import Decimal |
||||||
|
|
||||||
import pytest |
from pyhmy import numbers |
||||||
|
|
||||||
from pyhmy import ( |
|
||||||
numbers |
|
||||||
) |
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.run(order=1) |
|
||||||
def test_convert_atto_to_one(): |
def test_convert_atto_to_one(): |
||||||
a = numbers.convert_atto_to_one(1e18) |
a = numbers.convert_atto_to_one( 1e18 ) |
||||||
assert Decimal(1) == a |
assert Decimal( 1 ) == a |
||||||
|
|
||||||
|
b = numbers.convert_atto_to_one( 1e18 + 0.6 ) |
||||||
|
assert Decimal( 1 ) == b |
||||||
|
|
||||||
b = numbers.convert_atto_to_one(1e18 + 0.6) |
c = numbers.convert_atto_to_one( "1" + ( "0" * 18 ) ) |
||||||
assert Decimal(1) == b |
assert Decimal( 1 ) == c |
||||||
|
|
||||||
c = numbers.convert_atto_to_one('1' + ('0' * 18)) |
d = numbers.convert_atto_to_one( Decimal( 1e18 ) ) |
||||||
assert Decimal(1) == c |
assert Decimal( 1 ) == d |
||||||
|
|
||||||
d = numbers.convert_atto_to_one(Decimal(1e18)) |
|
||||||
assert Decimal(1) == d |
|
||||||
|
|
||||||
@pytest.mark.run(order=2) |
|
||||||
def test_convert_one_to_atto(): |
def test_convert_one_to_atto(): |
||||||
a = numbers.convert_one_to_atto(1e-18) |
a = numbers.convert_one_to_atto( 1e-18 ) |
||||||
assert Decimal(1) == a |
assert Decimal( 1 ) == a |
||||||
|
|
||||||
b = numbers.convert_one_to_atto(1.5) |
b = numbers.convert_one_to_atto( 1.5 ) |
||||||
assert Decimal(1.5e18) == b |
assert Decimal( 1.5e18 ) == b |
||||||
|
|
||||||
c = numbers.convert_one_to_atto('1') |
c = numbers.convert_one_to_atto( "1" ) |
||||||
assert Decimal(1e18) == c |
assert Decimal( 1e18 ) == c |
||||||
|
|
||||||
d = numbers.convert_one_to_atto(Decimal(1)) |
d = numbers.convert_one_to_atto( Decimal( 1 ) ) |
||||||
assert Decimal(1e18) == d |
assert Decimal( 1e18 ) == d |
||||||
|
@ -1,116 +1,155 @@ |
|||||||
import pytest |
import pytest |
||||||
import requests |
import requests |
||||||
|
|
||||||
from pyhmy import ( |
from pyhmy import account |
||||||
account |
|
||||||
) |
|
||||||
|
|
||||||
from pyhmy.rpc import ( |
from pyhmy.rpc import exceptions |
||||||
exceptions |
|
||||||
) |
|
||||||
|
|
||||||
|
explorer_endpoint = "http://localhost:9700" |
||||||
explorer_endpoint = 'http://localhost:9599' |
endpoint_shard_one = "http://localhost:9502" |
||||||
endpoint_shard_one = 'http://localhost:9501' |
local_test_address = "one155jp2y76nazx8uw5sa94fr0m4s5aj8e5xm6fu3" |
||||||
local_test_address = 'one1zksj3evekayy90xt4psrz8h6j2v3hla4qwz4ur' |
test_validator_address = local_test_address |
||||||
test_validator_address = 'one18tvf56zqjkjnak686lwutcp5mqfnvee35xjnhc' |
|
||||||
genesis_block_number = 0 |
genesis_block_number = 0 |
||||||
test_block_number = 1 |
test_block_number = 1 |
||||||
fake_shard = 'http://example.com' |
fake_shard = "http://example.com" |
||||||
|
|
||||||
|
|
||||||
def _test_account_rpc(fn, *args, **kwargs): |
def _test_account_rpc( fn, *args, **kwargs ): |
||||||
if not callable(fn): |
if not callable( fn ): |
||||||
pytest.fail(f'Invalid function: {fn}') |
pytest.fail( f"Invalid function: {fn}" ) |
||||||
|
|
||||||
try: |
try: |
||||||
response = fn(*args, **kwargs) |
response = fn( *args, **kwargs ) |
||||||
except Exception as e: |
except Exception as e: |
||||||
if isinstance(e, exceptions.RPCError) and 'does not exist/is not available' in str(e): |
if isinstance( e, |
||||||
pytest.skip(f'{str(e)}') |
exceptions.RPCError |
||||||
pytest.fail(f'Unexpected error: {e.__class__} {e}') |
) and "does not exist/is not available" in str( e ): |
||||||
|
pytest.skip( f"{str(e)}" ) |
||||||
|
pytest.fail( f"Unexpected error: {e.__class__} {e}" ) |
||||||
return response |
return response |
||||||
|
|
||||||
|
|
||||||
@pytest.mark.run(order=1) |
def test_get_balance( setup_blockchain ): |
||||||
def test_get_balance(setup_blockchain): |
balance = _test_account_rpc( account.get_balance, local_test_address ) |
||||||
balance = _test_account_rpc(account.get_balance, local_test_address) |
assert isinstance( balance, int ) |
||||||
assert isinstance(balance, int) |
|
||||||
assert balance > 0 |
assert balance > 0 |
||||||
|
|
||||||
@pytest.mark.run(order=2) |
|
||||||
def test_get_balance_by_block(setup_blockchain): |
def test_get_balance_by_block( setup_blockchain ): |
||||||
balance = _test_account_rpc(account.get_balance_by_block, local_test_address, genesis_block_number) |
balance = _test_account_rpc( |
||||||
assert isinstance(balance, int) |
account.get_balance_by_block, |
||||||
|
local_test_address, |
||||||
|
genesis_block_number |
||||||
|
) |
||||||
|
assert isinstance( balance, int ) |
||||||
assert balance > 0 |
assert balance > 0 |
||||||
|
|
||||||
@pytest.mark.run(order=3) |
|
||||||
def test_get_account_nonce(setup_blockchain): |
def test_get_account_nonce( setup_blockchain ): |
||||||
true_nonce = _test_account_rpc(account.get_account_nonce, local_test_address, test_block_number, endpoint=endpoint_shard_one) |
true_nonce = _test_account_rpc( |
||||||
assert isinstance(true_nonce, int) |
account.get_account_nonce, |
||||||
|
local_test_address, |
||||||
@pytest.mark.run(order=4) |
test_block_number, |
||||||
def test_get_transaction_history(setup_blockchain): |
endpoint = endpoint_shard_one, |
||||||
tx_history = _test_account_rpc(account.get_transaction_history, local_test_address, endpoint=explorer_endpoint) |
) |
||||||
assert isinstance(tx_history, list) |
assert isinstance( true_nonce, int ) |
||||||
assert len(tx_history) >= 0 |
|
||||||
|
|
||||||
@pytest.mark.run(order=5) |
def test_get_transaction_history( setup_blockchain ): |
||||||
def test_get_staking_transaction_history(setup_blockchain): |
tx_history = _test_account_rpc( |
||||||
staking_tx_history = _test_account_rpc(account.get_staking_transaction_history, test_validator_address, endpoint=explorer_endpoint) |
account.get_transaction_history, |
||||||
assert isinstance(staking_tx_history, list) |
local_test_address, |
||||||
assert len(staking_tx_history) > 0 |
endpoint = explorer_endpoint |
||||||
|
) |
||||||
@pytest.mark.run(order=6) |
assert isinstance( tx_history, list ) |
||||||
def test_get_balance_on_all_shards(setup_blockchain): |
assert len( tx_history ) >= 0 |
||||||
balances = _test_account_rpc(account.get_balance_on_all_shards, local_test_address) |
|
||||||
assert isinstance(balances, list) |
|
||||||
assert len(balances) == 2 |
def test_get_staking_transaction_history( setup_blockchain ): |
||||||
|
staking_tx_history = _test_account_rpc( |
||||||
@pytest.mark.run(order=7) |
account.get_staking_transaction_history, |
||||||
def test_get_total_balance(setup_blockchain): |
test_validator_address, |
||||||
total_balance = _test_account_rpc(account.get_total_balance, local_test_address) |
endpoint = explorer_endpoint, |
||||||
assert isinstance(total_balance, int) |
) |
||||||
|
assert isinstance( staking_tx_history, list ) |
||||||
|
assert len( staking_tx_history ) > 0 |
||||||
|
|
||||||
|
|
||||||
|
def test_get_balance_on_all_shards( setup_blockchain ): |
||||||
|
balances = _test_account_rpc( |
||||||
|
account.get_balance_on_all_shards, |
||||||
|
local_test_address |
||||||
|
) |
||||||
|
assert isinstance( balances, list ) |
||||||
|
assert len( balances ) == 2 |
||||||
|
|
||||||
|
|
||||||
|
def test_get_total_balance( setup_blockchain ): |
||||||
|
total_balance = _test_account_rpc( |
||||||
|
account.get_total_balance, |
||||||
|
local_test_address |
||||||
|
) |
||||||
|
assert isinstance( total_balance, int ) |
||||||
assert total_balance > 0 |
assert total_balance > 0 |
||||||
|
|
||||||
@pytest.mark.run(order=0) |
|
||||||
def test_is_valid_address(): |
|
||||||
assert account.is_valid_address('one1zksj3evekayy90xt4psrz8h6j2v3hla4qwz4ur') |
|
||||||
assert not account.is_valid_address('one1wje75aedczmj4dwjs0812xcg7vx0dy231cajk0') |
|
||||||
|
|
||||||
@pytest.mark.run(order=8) |
def test_is_valid_address(): |
||||||
def test_get_transaction_count(setup_blockchain): |
assert account.is_valid_address( |
||||||
tx_count = _test_account_rpc(account.get_transaction_count, local_test_address, 'latest') |
"one1zksj3evekayy90xt4psrz8h6j2v3hla4qwz4ur" |
||||||
assert isinstance(tx_count, int) |
) |
||||||
|
assert not account.is_valid_address( |
||||||
|
"one1wje75aedczmj4dwjs0812xcg7vx0dy231cajk0" |
||||||
|
) |
||||||
|
|
||||||
|
|
||||||
|
def test_get_transaction_count( setup_blockchain ): |
||||||
|
tx_count = _test_account_rpc( |
||||||
|
account.get_transaction_count, |
||||||
|
local_test_address, |
||||||
|
"latest", |
||||||
|
explorer_endpoint |
||||||
|
) |
||||||
|
assert isinstance( tx_count, int ) |
||||||
assert tx_count > 0 |
assert tx_count > 0 |
||||||
|
|
||||||
@pytest.mark.run(order=9) |
|
||||||
def test_get_transactions_count(setup_blockchain): |
|
||||||
tx_count = _test_account_rpc(account.get_transactions_count, local_test_address, 'ALL') |
|
||||||
|
|
||||||
@pytest.mark.run(order=10) |
def test_get_transactions_count( setup_blockchain ): |
||||||
def test_get_staking_transactions_count(setup_blockchain): |
tx_count = _test_account_rpc( |
||||||
tx_count = _test_account_rpc(account.get_staking_transactions_count, local_test_address, 'ALL') |
account.get_transactions_count, |
||||||
assert isinstance(tx_count, int) |
local_test_address, |
||||||
|
"ALL", |
||||||
|
explorer_endpoint |
||||||
|
) |
||||||
|
|
||||||
|
|
||||||
|
def test_get_staking_transactions_count( setup_blockchain ): |
||||||
|
tx_count = _test_account_rpc( |
||||||
|
account.get_staking_transactions_count, |
||||||
|
local_test_address, |
||||||
|
"ALL", |
||||||
|
explorer_endpoint, |
||||||
|
) |
||||||
|
assert isinstance( tx_count, int ) |
||||||
|
|
||||||
|
|
||||||
@pytest.mark.run(order=10) |
|
||||||
def test_errors(): |
def test_errors(): |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
account.get_balance('', fake_shard) |
account.get_balance( "", fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
account.get_balance_by_block('', 1, fake_shard) |
account.get_balance_by_block( "", 1, fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
account.get_account_nonce('', 1, fake_shard) |
account.get_account_nonce( "", 1, fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
account.get_transaction_count('', 1, fake_shard) |
account.get_transaction_count( "", 1, fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
account.get_transactions_count('', 1, fake_shard) |
account.get_transactions_count( "", 1, fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
account.get_transactions_count('', 'ALL', fake_shard) |
account.get_transactions_count( "", "ALL", fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
account.get_transaction_history('', endpoint=fake_shard) |
account.get_transaction_history( "", endpoint = fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
account.get_staking_transaction_history('', endpoint=fake_shard) |
account.get_staking_transaction_history( "", endpoint = fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
account.get_balance_on_all_shards('', endpoint=fake_shard) |
account.get_balance_on_all_shards( "", endpoint = fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
account.get_total_balance('', endpoint=fake_shard) |
account.get_total_balance( "", endpoint = fake_shard ) |
||||||
|
@ -1,321 +1,369 @@ |
|||||||
import pytest |
import pytest |
||||||
import requests |
import requests |
||||||
|
|
||||||
from pyhmy import ( |
from pyhmy import blockchain |
||||||
blockchain |
|
||||||
) |
|
||||||
|
|
||||||
from pyhmy.rpc import ( |
|
||||||
exceptions |
|
||||||
) |
|
||||||
|
|
||||||
|
from pyhmy.rpc import exceptions |
||||||
|
|
||||||
test_epoch_number = 0 |
test_epoch_number = 0 |
||||||
genesis_block_number = 0 |
genesis_block_number = 0 |
||||||
test_block_number = 1 |
test_block_number = 1 |
||||||
test_block_hash = None |
test_block_hash = None |
||||||
fake_shard = 'http://example.com' |
fake_shard = "http://example.com" |
||||||
|
address = "one155jp2y76nazx8uw5sa94fr0m4s5aj8e5xm6fu3" |
||||||
|
|
||||||
|
|
||||||
def _test_blockchain_rpc(fn, *args, **kwargs): |
def _test_blockchain_rpc( fn, *args, **kwargs ): |
||||||
if not callable(fn): |
if not callable( fn ): |
||||||
pytest.fail(f'Invalid function: {fn}') |
pytest.fail( f"Invalid function: {fn}" ) |
||||||
|
|
||||||
try: |
try: |
||||||
response = fn(*args, **kwargs) |
response = fn( *args, **kwargs ) |
||||||
except Exception as e: |
except Exception as e: |
||||||
if isinstance(e, exceptions.RPCError) and 'does not exist/is not available' in str(e): |
if isinstance( e, |
||||||
pytest.skip(f'{str(e)}') |
exceptions.RPCError |
||||||
pytest.fail(f'Unexpected error: {e.__class__} {e}') |
) and "does not exist/is not available" in str( e ): |
||||||
|
pytest.skip( f"{str(e)}" ) |
||||||
|
pytest.fail( f"Unexpected error: {e.__class__} {e}" ) |
||||||
return response |
return response |
||||||
|
|
||||||
@pytest.mark.run(order=1) |
|
||||||
def test_get_node_metadata(setup_blockchain): |
def test_get_node_metadata( setup_blockchain ): |
||||||
metadata = _test_blockchain_rpc(blockchain.get_node_metadata) |
metadata = _test_blockchain_rpc( blockchain.get_node_metadata ) |
||||||
assert isinstance(metadata, dict) |
assert isinstance( metadata, dict ) |
||||||
|
|
||||||
@pytest.mark.run(order=2) |
|
||||||
def test_get_sharding_structure(setup_blockchain): |
def test_get_sharding_structure( setup_blockchain ): |
||||||
sharding_structure = _test_blockchain_rpc(blockchain.get_sharding_structure) |
sharding_structure = _test_blockchain_rpc( |
||||||
assert isinstance(sharding_structure, list) |
blockchain.get_sharding_structure |
||||||
assert len(sharding_structure) > 0 |
) |
||||||
|
assert isinstance( sharding_structure, list ) |
||||||
@pytest.mark.run(order=3) |
assert len( sharding_structure ) > 0 |
||||||
def test_get_leader_address(setup_blockchain): |
|
||||||
leader = _test_blockchain_rpc(blockchain.get_leader_address) |
|
||||||
assert isinstance(leader, str) |
def test_get_leader_address( setup_blockchain ): |
||||||
assert 'one1' in leader |
leader = _test_blockchain_rpc( blockchain.get_leader_address ) |
||||||
|
assert isinstance( leader, str ) |
||||||
@pytest.mark.run(order=4) |
assert "one1" in leader |
||||||
def test_get_block_number(setup_blockchain): |
|
||||||
current_block_number = _test_blockchain_rpc(blockchain.get_block_number) |
|
||||||
assert isinstance(current_block_number, int) |
def test_get_block_number( setup_blockchain ): |
||||||
|
current_block_number = _test_blockchain_rpc( blockchain.get_block_number ) |
||||||
@pytest.mark.run(order=5) |
assert isinstance( current_block_number, int ) |
||||||
def test_get_current_epoch(setup_blockchain): |
|
||||||
current_epoch = _test_blockchain_rpc(blockchain.get_current_epoch) |
|
||||||
assert isinstance(current_epoch, int) |
def test_get_current_epoch( setup_blockchain ): |
||||||
|
current_epoch = _test_blockchain_rpc( blockchain.get_current_epoch ) |
||||||
@pytest.mark.run(order=6) |
assert isinstance( current_epoch, int ) |
||||||
def tset_get_gas_price(setup_blockchain): |
|
||||||
gas = _test_blockchain_rpc(blockchain.get_gas_price) |
|
||||||
assert isinstance(gas, int) |
def tset_get_gas_price( setup_blockchain ): |
||||||
|
gas = _test_blockchain_rpc( blockchain.get_gas_price ) |
||||||
@pytest.mark.run(order=7) |
assert isinstance( gas, int ) |
||||||
def test_get_num_peers(setup_blockchain): |
|
||||||
peers = _test_blockchain_rpc(blockchain.get_num_peers) |
|
||||||
assert isinstance(peers, int) |
def test_get_num_peers( setup_blockchain ): |
||||||
|
peers = _test_blockchain_rpc( blockchain.get_num_peers ) |
||||||
@pytest.mark.run(order=8) |
assert isinstance( peers, int ) |
||||||
def test_get_latest_header(setup_blockchain): |
|
||||||
header = _test_blockchain_rpc(blockchain.get_latest_header) |
|
||||||
assert isinstance(header, dict) |
def test_get_latest_header( setup_blockchain ): |
||||||
|
header = _test_blockchain_rpc( blockchain.get_latest_header ) |
||||||
@pytest.mark.run(order=9) |
assert isinstance( header, dict ) |
||||||
def test_get_latest_chain_headers(setup_blockchain): |
|
||||||
header_pair = _test_blockchain_rpc(blockchain.get_latest_chain_headers) |
|
||||||
assert isinstance(header_pair, dict) |
def test_get_latest_chain_headers( setup_blockchain ): |
||||||
|
header_pair = _test_blockchain_rpc( blockchain.get_latest_chain_headers ) |
||||||
@pytest.mark.run(order=10) |
assert isinstance( header_pair, dict ) |
||||||
def test_get_block_by_number(setup_blockchain): |
|
||||||
|
|
||||||
|
def test_get_block_by_number( setup_blockchain ): |
||||||
global test_block_hash |
global test_block_hash |
||||||
block = _test_blockchain_rpc(blockchain.get_block_by_number, test_block_number) |
block = _test_blockchain_rpc( |
||||||
assert isinstance(block, dict) |
blockchain.get_block_by_number, |
||||||
assert 'hash' in block.keys() |
test_block_number |
||||||
test_block_hash = block['hash'] |
) |
||||||
|
assert isinstance( block, dict ) |
||||||
|
assert "hash" in block.keys() |
||||||
|
test_block_hash = block[ "hash" ] |
||||||
|
|
||||||
@pytest.mark.run(order=11) |
|
||||||
def test_get_block_by_hash(setup_blockchain): |
def test_get_block_by_hash( setup_blockchain ): |
||||||
if not test_block_hash: |
if not test_block_hash: |
||||||
pytest.skip('Failed to get reference block hash') |
pytest.skip( "Failed to get reference block hash" ) |
||||||
block = _test_blockchain_rpc(blockchain.get_block_by_hash, test_block_hash) |
block = _test_blockchain_rpc( |
||||||
assert isinstance(block, dict) |
blockchain.get_block_by_hash, |
||||||
|
test_block_hash |
||||||
|
) |
||||||
|
assert isinstance( block, dict ) |
||||||
|
|
||||||
|
|
||||||
@pytest.mark.run(order=12) |
def test_get_block_transaction_count_by_number( setup_blockchain ): |
||||||
def test_get_block_transaction_count_by_number(setup_blockchain): |
tx_count = _test_blockchain_rpc( |
||||||
tx_count = _test_blockchain_rpc(blockchain.get_block_transaction_count_by_number, test_block_number) |
blockchain.get_block_transaction_count_by_number, |
||||||
assert isinstance(tx_count, int) |
test_block_number |
||||||
|
) |
||||||
|
assert isinstance( tx_count, int ) |
||||||
|
|
||||||
@pytest.mark.run(order=13) |
|
||||||
def test_get_block_transaction_count_by_hash(setup_blockchain): |
def test_get_block_transaction_count_by_hash( setup_blockchain ): |
||||||
if not test_block_hash: |
if not test_block_hash: |
||||||
pytest.skip('Failed to get reference block hash') |
pytest.skip( "Failed to get reference block hash" ) |
||||||
tx_count = _test_blockchain_rpc(blockchain.get_block_transaction_count_by_hash, test_block_hash) |
tx_count = _test_blockchain_rpc( |
||||||
assert isinstance(tx_count, int) |
blockchain.get_block_transaction_count_by_hash, |
||||||
|
test_block_hash |
||||||
@pytest.mark.run(order=14) |
) |
||||||
def test_get_blocks(setup_blockchain): |
assert isinstance( tx_count, int ) |
||||||
blocks = _test_blockchain_rpc(blockchain.get_blocks, genesis_block_number, test_block_number) |
|
||||||
assert isinstance(blocks, list) |
|
||||||
assert len(blocks) == (test_block_number - genesis_block_number + 1) |
def test_get_blocks( setup_blockchain ): |
||||||
|
blocks = _test_blockchain_rpc( |
||||||
@pytest.mark.run(order=15) |
blockchain.get_blocks, |
||||||
def test_get_block_signers(setup_blockchain): |
genesis_block_number, |
||||||
block_signers = _test_blockchain_rpc(blockchain.get_block_signers, test_block_number) |
test_block_number |
||||||
assert isinstance(block_signers, list) |
) |
||||||
assert len(block_signers) > 0 |
assert isinstance( blocks, list ) |
||||||
|
assert len( blocks ) == ( test_block_number - genesis_block_number + 1 ) |
||||||
@pytest.mark.run(order=16) |
|
||||||
def test_get_validators(setup_blockchain): |
|
||||||
validators = _test_blockchain_rpc(blockchain.get_validators, test_epoch_number) |
def test_get_block_signers( setup_blockchain ): |
||||||
assert isinstance(validators, dict) |
block_signers = _test_blockchain_rpc( |
||||||
assert 'validators' in validators.keys() |
blockchain.get_block_signers, |
||||||
assert len(validators['validators']) > 0 |
test_block_number |
||||||
|
) |
||||||
@pytest.mark.run(order=17) |
assert isinstance( block_signers, list ) |
||||||
def test_get_shard(setup_blockchain): |
assert len( block_signers ) > 0 |
||||||
shard = _test_blockchain_rpc(blockchain.get_shard) |
|
||||||
assert isinstance(shard, int) |
|
||||||
|
def test_get_validators( setup_blockchain ): |
||||||
|
validators = _test_blockchain_rpc( |
||||||
|
blockchain.get_validators, |
||||||
|
test_epoch_number |
||||||
|
) |
||||||
|
assert isinstance( validators, dict ) |
||||||
|
assert "validators" in validators.keys() |
||||||
|
assert len( validators[ "validators" ] ) > 0 |
||||||
|
|
||||||
|
|
||||||
|
def test_get_shard( setup_blockchain ): |
||||||
|
shard = _test_blockchain_rpc( blockchain.get_shard ) |
||||||
|
assert isinstance( shard, int ) |
||||||
assert shard == 0 |
assert shard == 0 |
||||||
|
|
||||||
@pytest.mark.run(order=18) |
|
||||||
def test_get_staking_epoch(setup_blockchain): |
|
||||||
staking_epoch = _test_blockchain_rpc(blockchain.get_staking_epoch) |
|
||||||
assert isinstance(staking_epoch, int) |
|
||||||
|
|
||||||
@pytest.mark.run(order=19) |
def test_get_staking_epoch( setup_blockchain ): |
||||||
def test_get_prestaking_epoch(setup_blockchain): |
staking_epoch = _test_blockchain_rpc( blockchain.get_staking_epoch ) |
||||||
prestaking_epoch = _test_blockchain_rpc(blockchain.get_prestaking_epoch) |
assert isinstance( staking_epoch, int ) |
||||||
assert isinstance(prestaking_epoch, int) |
|
||||||
|
|
||||||
@pytest.mark.run(order=20) |
def test_get_prestaking_epoch( setup_blockchain ): |
||||||
def test_get_bad_blocks(setup_blockchain): |
prestaking_epoch = _test_blockchain_rpc( blockchain.get_prestaking_epoch ) |
||||||
|
assert isinstance( prestaking_epoch, int ) |
||||||
|
|
||||||
|
|
||||||
|
def test_get_bad_blocks( setup_blockchain ): |
||||||
# TODO: Remove skip when RPC is fixed |
# TODO: Remove skip when RPC is fixed |
||||||
pytest.skip("Known error with hmyv2_getCurrentBadBlocks") |
pytest.skip( "Known error with hmyv2_getCurrentBadBlocks" ) |
||||||
bad_blocks = _test_blockchain_rpc(blockchain.get_bad_blocks) |
bad_blocks = _test_blockchain_rpc( blockchain.get_bad_blocks ) |
||||||
assert isinstance(bad_blocks, list) |
assert isinstance( bad_blocks, list ) |
||||||
|
|
||||||
@pytest.mark.run(order=21) |
|
||||||
def test_get_validator_keys(setup_blockchain): |
def test_get_validator_keys( setup_blockchain ): |
||||||
keys = _test_blockchain_rpc(blockchain.get_validator_keys, test_epoch_number) |
keys = _test_blockchain_rpc( |
||||||
assert isinstance(keys, list) |
blockchain.get_validator_keys, |
||||||
assert len(keys) > 0 |
test_epoch_number |
||||||
|
) |
||||||
@pytest.mark.run(order=22) |
assert isinstance( keys, list ) |
||||||
def test_get_block_signers_keys(setup_blockchain): |
assert len( keys ) > 0 |
||||||
keys = _test_blockchain_rpc(blockchain.get_block_signers_keys, test_block_number) |
|
||||||
assert isinstance(keys, list) |
|
||||||
assert len(keys) > 0 |
def test_get_block_signers_keys( setup_blockchain ): |
||||||
|
keys = _test_blockchain_rpc( |
||||||
@pytest.mark.run(order=23) |
blockchain.get_block_signers_keys, |
||||||
def test_chain_id(setup_blockchain): |
test_block_number |
||||||
chain_id = _test_blockchain_rpc(blockchain.chain_id) |
) |
||||||
assert isinstance(chain_id, int) |
assert isinstance( keys, list ) |
||||||
|
assert len( keys ) > 0 |
||||||
@pytest.mark.run(order=24) |
|
||||||
def test_get_peer_info(setup_blockchain): |
|
||||||
peer_info = _test_blockchain_rpc(blockchain.get_peer_info) |
def test_chain_id( setup_blockchain ): |
||||||
assert isinstance(peer_info, dict) |
chain_id = _test_blockchain_rpc( blockchain.chain_id ) |
||||||
|
assert isinstance( chain_id, int ) |
||||||
@pytest.mark.run(order=25) |
|
||||||
def test_protocol_version(setup_blockchain): |
|
||||||
protocol_version = _test_blockchain_rpc(blockchain.protocol_version) |
def test_get_peer_info( setup_blockchain ): |
||||||
assert isinstance(protocol_version, int) |
peer_info = _test_blockchain_rpc( blockchain.get_peer_info ) |
||||||
|
assert isinstance( peer_info, dict ) |
||||||
@pytest.mark.run(order=26) |
|
||||||
def test_is_last_block(setup_blockchain): |
|
||||||
is_last_block = _test_blockchain_rpc(blockchain.is_last_block, 0) |
def test_protocol_version( setup_blockchain ): |
||||||
assert isinstance(is_last_block, bool) |
protocol_version = _test_blockchain_rpc( blockchain.protocol_version ) |
||||||
|
assert isinstance( protocol_version, int ) |
||||||
|
|
||||||
|
|
||||||
|
def test_is_last_block( setup_blockchain ): |
||||||
|
is_last_block = _test_blockchain_rpc( blockchain.is_last_block, 0 ) |
||||||
|
assert isinstance( is_last_block, bool ) |
||||||
assert not is_last_block |
assert not is_last_block |
||||||
|
|
||||||
@pytest.mark.run(order=27) |
|
||||||
def test_epoch_last_block(setup_blockchain): |
def test_epoch_last_block( setup_blockchain ): |
||||||
epoch_last_block = _test_blockchain_rpc(blockchain.epoch_last_block, 0) |
epoch_last_block = _test_blockchain_rpc( blockchain.epoch_last_block, 0 ) |
||||||
assert isinstance(epoch_last_block, int) |
assert isinstance( epoch_last_block, int ) |
||||||
|
|
||||||
@pytest.mark.run(order=28) |
|
||||||
def test_get_circulating_supply(setup_blockchain): |
def test_get_circulating_supply( setup_blockchain ): |
||||||
circulating_supply = _test_blockchain_rpc(blockchain.get_circulating_supply) |
circulating_supply = _test_blockchain_rpc( |
||||||
assert isinstance(circulating_supply, str) |
blockchain.get_circulating_supply |
||||||
|
) |
||||||
@pytest.mark.run(order=29) |
assert isinstance( circulating_supply, str ) |
||||||
def test_get_total_supply(setup_blockchain): |
|
||||||
total_supply = _test_blockchain_rpc(blockchain.get_total_supply) |
|
||||||
assert isinstance(total_supply, str) or total_supply == None |
def test_get_total_supply( setup_blockchain ): |
||||||
|
total_supply = _test_blockchain_rpc( blockchain.get_total_supply ) |
||||||
@pytest.mark.run(order=30) |
assert isinstance( total_supply, str ) or total_supply == None |
||||||
def test_get_last_cross_links(setup_blockchain): |
|
||||||
last_cross_links = _test_blockchain_rpc(blockchain.get_last_cross_links) |
|
||||||
assert isinstance(last_cross_links, list) |
def test_get_last_cross_links( setup_blockchain ): |
||||||
|
last_cross_links = _test_blockchain_rpc( blockchain.get_last_cross_links ) |
||||||
@pytest.mark.run(order=31) |
assert isinstance( last_cross_links, list ) |
||||||
def test_get_gas_price(setup_blockchain): |
|
||||||
gas_price = _test_blockchain_rpc(blockchain.get_gas_price) |
|
||||||
assert isinstance(gas_price, int) |
def test_get_gas_price( setup_blockchain ): |
||||||
|
gas_price = _test_blockchain_rpc( blockchain.get_gas_price ) |
||||||
@pytest.mark.run(order=32) |
assert isinstance( gas_price, int ) |
||||||
def test_get_version(setup_blockchain): |
|
||||||
version = _test_blockchain_rpc(blockchain.get_version) |
|
||||||
assert isinstance(version, int) |
def test_get_version( setup_blockchain ): |
||||||
|
version = _test_blockchain_rpc( blockchain.get_version ) |
||||||
@pytest.mark.run(order=33) |
assert isinstance( version, int ) |
||||||
def test_get_header_by_number(setup_blockchain): |
|
||||||
header_pair = _test_blockchain_rpc(blockchain.get_header_by_number, 0) |
|
||||||
assert isinstance(header_pair, dict) |
def test_get_header_by_number( setup_blockchain ): |
||||||
|
header_pair = _test_blockchain_rpc( blockchain.get_header_by_number, 0 ) |
||||||
@pytest.mark.run(order=34) |
assert isinstance( header_pair, dict ) |
||||||
def test_get_block_staking_transaction_count_by_number(setup_blockchain): |
|
||||||
tx_count = _test_blockchain_rpc(blockchain.get_block_staking_transaction_count_by_number, test_block_number) |
|
||||||
assert isinstance(tx_count, int) |
def test_get_block_staking_transaction_count_by_number( setup_blockchain ): |
||||||
|
tx_count = _test_blockchain_rpc( |
||||||
@pytest.mark.run(order=35) |
blockchain.get_block_staking_transaction_count_by_number, |
||||||
def test_get_block_staking_transaction_count_by_hash(setup_blockchain): |
test_block_number |
||||||
|
) |
||||||
|
assert isinstance( tx_count, int ) |
||||||
|
|
||||||
|
|
||||||
|
def test_get_block_staking_transaction_count_by_hash( setup_blockchain ): |
||||||
if not test_block_hash: |
if not test_block_hash: |
||||||
pytest.skip('Failed to get reference block hash') |
pytest.skip( "Failed to get reference block hash" ) |
||||||
tx_count = _test_blockchain_rpc(blockchain.get_block_staking_transaction_count_by_hash, test_block_hash) |
tx_count = _test_blockchain_rpc( |
||||||
assert isinstance(tx_count, int) |
blockchain.get_block_staking_transaction_count_by_hash, |
||||||
|
test_block_hash |
||||||
@pytest.mark.run(order=36) |
) |
||||||
def test_is_block_signer(setup_blockchain): |
assert isinstance( tx_count, int ) |
||||||
is_signer = _test_blockchain_rpc(blockchain.is_block_signer, test_block_number, '0x0') |
|
||||||
assert isinstance(is_signer, bool) |
|
||||||
|
def test_is_block_signer( setup_blockchain ): |
||||||
@pytest.mark.run(order=37) |
is_signer = _test_blockchain_rpc( |
||||||
def test_get_signed_blocks(setup_blockchain): |
blockchain.is_block_signer, |
||||||
signed_blocks = _test_blockchain_rpc(blockchain.get_signed_blocks, '0x0') |
test_block_number, |
||||||
assert isinstance(signed_blocks, int) |
address |
||||||
|
) |
||||||
@pytest.mark.run(order=38) |
assert isinstance( is_signer, bool ) |
||||||
def test_in_sync(setup_blockchain): |
|
||||||
in_sync = _test_blockchain_rpc(blockchain.in_sync) |
|
||||||
assert isinstance(in_sync, bool) |
def test_get_signed_blocks( setup_blockchain ): |
||||||
|
signed_blocks = _test_blockchain_rpc( |
||||||
@pytest.mark.run(order=38) |
blockchain.get_signed_blocks, |
||||||
def test_beacon_in_sync(setup_blockchain): |
address |
||||||
beacon_in_sync = _test_blockchain_rpc(blockchain.beacon_in_sync) |
) |
||||||
assert isinstance(beacon_in_sync, bool) |
assert isinstance( signed_blocks, int ) |
||||||
|
|
||||||
|
|
||||||
|
def test_in_sync( setup_blockchain ): |
||||||
|
in_sync = _test_blockchain_rpc( blockchain.in_sync ) |
||||||
|
assert isinstance( in_sync, bool ) |
||||||
|
|
||||||
|
|
||||||
|
def test_beacon_in_sync( setup_blockchain ): |
||||||
|
beacon_in_sync = _test_blockchain_rpc( blockchain.beacon_in_sync ) |
||||||
|
assert isinstance( beacon_in_sync, bool ) |
||||||
|
|
||||||
|
|
||||||
def test_errors(): |
def test_errors(): |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.chain_id(fake_shard) |
blockchain.chain_id( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_node_metadata(fake_shard) |
blockchain.get_node_metadata( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_peer_info(fake_shard) |
blockchain.get_peer_info( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.protocol_version(fake_shard) |
blockchain.protocol_version( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_shard(fake_shard) |
blockchain.get_shard( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_staking_epoch(fake_shard) |
blockchain.get_staking_epoch( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_prestaking_epoch(fake_shard) |
blockchain.get_prestaking_epoch( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_sharding_structure(fake_shard) |
blockchain.get_sharding_structure( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_leader_address(fake_shard) |
blockchain.get_leader_address( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.is_last_block(0, fake_shard) |
blockchain.is_last_block( 0, fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.epoch_last_block(0, fake_shard) |
blockchain.epoch_last_block( 0, fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_circulating_supply(fake_shard) |
blockchain.get_circulating_supply( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_total_supply(fake_shard) |
blockchain.get_total_supply( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_block_number(fake_shard) |
blockchain.get_block_number( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_current_epoch(fake_shard) |
blockchain.get_current_epoch( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_last_cross_links(fake_shard) |
blockchain.get_last_cross_links( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_gas_price(fake_shard) |
blockchain.get_gas_price( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_num_peers(fake_shard) |
blockchain.get_num_peers( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_version(fake_shard) |
blockchain.get_version( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_latest_header(fake_shard) |
blockchain.get_latest_header( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_header_by_number(0, fake_shard) |
blockchain.get_header_by_number( 0, fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_latest_chain_headers(fake_shard) |
blockchain.get_latest_chain_headers( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_block_by_number(0, endpoint=fake_shard) |
blockchain.get_block_by_number( 0, endpoint = fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_block_by_hash('', endpoint=fake_shard) |
blockchain.get_block_by_hash( "", endpoint = fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_block_transaction_count_by_number(0, fake_shard) |
blockchain.get_block_transaction_count_by_number( 0, fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_block_transaction_count_by_hash('', fake_shard) |
blockchain.get_block_transaction_count_by_hash( "", fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
blockchain.get_block_staking_transaction_count_by_number(0, fake_shard) |
blockchain.get_block_staking_transaction_count_by_number( |
||||||
with pytest.raises(exceptions.RPCError): |
0, |
||||||
blockchain.get_block_staking_transaction_count_by_hash('', fake_shard) |
fake_shard |
||||||
with pytest.raises(exceptions.RPCError): |
) |
||||||
blockchain.get_blocks(0, 1, endpoint=fake_shard) |
with pytest.raises( exceptions.RPCError ): |
||||||
with pytest.raises(exceptions.RPCError): |
blockchain.get_block_staking_transaction_count_by_hash( "", fake_shard ) |
||||||
blockchain.get_block_signers(0, fake_shard) |
with pytest.raises( exceptions.RPCError ): |
||||||
with pytest.raises(exceptions.RPCError): |
blockchain.get_blocks( 0, 1, endpoint = fake_shard ) |
||||||
blockchain.get_block_signers_keys(0, fake_shard) |
with pytest.raises( exceptions.RPCError ): |
||||||
with pytest.raises(exceptions.RPCError): |
blockchain.get_block_signers( 0, fake_shard ) |
||||||
blockchain.is_block_signer(0, '', fake_shard) |
with pytest.raises( exceptions.RPCError ): |
||||||
with pytest.raises(exceptions.RPCError): |
blockchain.get_block_signers_keys( 0, fake_shard ) |
||||||
blockchain.get_signed_blocks('', fake_shard) |
with pytest.raises( exceptions.RPCError ): |
||||||
with pytest.raises(exceptions.RPCError): |
blockchain.is_block_signer( 0, "", fake_shard ) |
||||||
blockchain.get_validators(1, fake_shard) |
with pytest.raises( exceptions.RPCError ): |
||||||
with pytest.raises(exceptions.RPCError): |
blockchain.get_signed_blocks( "", fake_shard ) |
||||||
blockchain.get_validator_keys(0, fake_shard) |
with pytest.raises( exceptions.RPCError ): |
||||||
with pytest.raises(exceptions.RPCError): |
blockchain.get_validators( 1, fake_shard ) |
||||||
blockchain.in_sync(fake_shard) |
with pytest.raises( exceptions.RPCError ): |
||||||
with pytest.raises(exceptions.RPCError): |
blockchain.get_validator_keys( 0, fake_shard ) |
||||||
blockchain.beacon_in_sync(fake_shard) |
with pytest.raises( exceptions.RPCError ): |
||||||
|
blockchain.in_sync( fake_shard ) |
||||||
|
with pytest.raises( exceptions.RPCError ): |
||||||
|
blockchain.beacon_in_sync( fake_shard ) |
||||||
|
@ -1,74 +1,86 @@ |
|||||||
import pytest |
import pytest |
||||||
|
|
||||||
from pyhmy import ( |
from pyhmy import contract |
||||||
contract |
|
||||||
) |
|
||||||
|
|
||||||
from pyhmy.rpc import ( |
from pyhmy.rpc import exceptions |
||||||
exceptions |
|
||||||
) |
|
||||||
|
|
||||||
explorer_endpoint = 'http://localhost:9599' |
explorer_endpoint = "http://localhost:9599" |
||||||
contract_tx_hash = '0xa13414dd152173395c69a11e79dea31bf029660f747a42a53744181d05571e70' |
contract_tx_hash = "0xa605852dd2fa39ed42e101c17aaca9d344d352ba9b24b14b9af94ec9cb58b31f" |
||||||
|
# deployedBytecode from json file |
||||||
|
contract_code = "0x6080604052348015600f57600080fd5b506004361060285760003560e01c80634936cd3614602d575b600080fd5b604080516001815290519081900360200190f3fea2646970667358221220fa3fa0e8d0267831a59f4dd5edf39a513d07e98461cb06660ad28d4beda744cd64736f6c634300080f0033" |
||||||
contract_address = None |
contract_address = None |
||||||
fake_shard = 'http://example.com' |
fake_shard = "http://example.com" |
||||||
|
|
||||||
def _test_contract_rpc(fn, *args, **kwargs): |
|
||||||
if not callable(fn): |
def _test_contract_rpc( fn, *args, **kwargs ): |
||||||
pytest.fail(f'Invalid function: {fn}') |
if not callable( fn ): |
||||||
|
pytest.fail( f"Invalid function: {fn}" ) |
||||||
|
|
||||||
try: |
try: |
||||||
response = fn(*args, **kwargs) |
response = fn( *args, **kwargs ) |
||||||
except Exception as e: |
except Exception as e: |
||||||
if isinstance(e, exceptions.RPCError) and 'does not exist/is not available' in str(e): |
if isinstance( e, |
||||||
pytest.skip(f'{str(e)}') |
exceptions.RPCError |
||||||
elif isinstance(e, exceptions.RPCError) and 'estimateGas returned' in str(e): |
) and "does not exist/is not available" in str( e ): |
||||||
pytest.skip(f'{str(e)}') |
pytest.skip( f"{str(e)}" ) |
||||||
pytest.fail(f'Unexpected error: {e.__class__} {e}') |
elif isinstance( e, |
||||||
|
exceptions.RPCError |
||||||
|
) and "estimateGas returned" in str( e ): |
||||||
|
pytest.skip( f"{str(e)}" ) |
||||||
|
pytest.fail( f"Unexpected error: {e.__class__} {e}" ) |
||||||
return response |
return response |
||||||
|
|
||||||
@pytest.mark.run(order=1) |
|
||||||
def test_get_contract_address_from_hash(setup_blockchain): |
def test_get_contract_address_from_hash( setup_blockchain ): |
||||||
global contract_address |
global contract_address |
||||||
contract_address = _test_contract_rpc(contract.get_contract_address_from_hash, contract_tx_hash) |
contract_address = _test_contract_rpc( |
||||||
assert isinstance(contract_address, str) |
contract.get_contract_address_from_hash, |
||||||
|
contract_tx_hash |
||||||
|
) |
||||||
|
assert isinstance( contract_address, str ) |
||||||
|
|
||||||
@pytest.mark.run(order=2) |
|
||||||
def test_call(setup_blockchain): |
def test_call( setup_blockchain ): |
||||||
if not contract_address: |
if not contract_address: |
||||||
pytest.skip('Contract address not loaded yet') |
pytest.skip( "Contract address not loaded yet" ) |
||||||
called = _test_contract_rpc(contract.call, contract_address, 'latest') |
called = _test_contract_rpc( contract.call, contract_address, "latest" ) |
||||||
assert isinstance(called, str) and called.startswith('0x') |
assert isinstance( called, str ) and called.startswith( "0x" ) |
||||||
|
|
||||||
|
|
||||||
@pytest.mark.run(order=3) |
def test_estimate_gas( setup_blockchain ): |
||||||
def test_estimate_gas(setup_blockchain): |
|
||||||
if not contract_address: |
if not contract_address: |
||||||
pytest.skip('Contract address not loaded yet') |
pytest.skip( "Contract address not loaded yet" ) |
||||||
gas = _test_contract_rpc(contract.estimate_gas, contract_address) |
gas = _test_contract_rpc( contract.estimate_gas, contract_address ) |
||||||
assert isinstance(gas, int) |
assert isinstance( gas, int ) |
||||||
|
|
||||||
@pytest.mark.run(order=4) |
|
||||||
def test_get_code(setup_blockchain): |
def test_get_code( setup_blockchain ): |
||||||
if not contract_address: |
if not contract_address: |
||||||
pytest.skip('Contract address not loaded yet') |
pytest.skip( "Contract address not loaded yet" ) |
||||||
code = _test_contract_rpc(contract.get_code, contract_address, 'latest') |
code = _test_contract_rpc( contract.get_code, contract_address, "latest" ) |
||||||
assert code == '0x608060405234801561001057600080fd5b50600436106100415760003560e01c8063445df0ac146100465780638da5cb5b14610064578063fdacd576146100ae575b600080fd5b61004e6100dc565b6040518082815260200191505060405180910390f35b61006c6100e2565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100da600480360360208110156100c457600080fd5b8101908080359060200190929190505050610107565b005b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561016457806001819055505b5056fea265627a7a723158209b80813a158b44af65aee232b44c0ac06472c48f4abbe298852a39f0ff34a9f264736f6c63430005100032' |
assert code == contract_code |
||||||
|
|
||||||
|
|
||||||
@pytest.mark.run(order=5) |
def test_get_storage_at( setup_blockchain ): |
||||||
def test_get_storage_at(setup_blockchain): |
|
||||||
if not contract_address: |
if not contract_address: |
||||||
pytest.skip('Contract address not loaded yet') |
pytest.skip( "Contract address not loaded yet" ) |
||||||
storage = _test_contract_rpc(contract.get_storage_at, contract_address, '0x0', 'latest') |
storage = _test_contract_rpc( |
||||||
assert isinstance(storage, str) and storage.startswith('0x') |
contract.get_storage_at, |
||||||
|
contract_address, |
||||||
|
"0x0", |
||||||
|
"latest" |
||||||
|
) |
||||||
|
assert isinstance( storage, str ) and storage.startswith( "0x" ) |
||||||
|
|
||||||
|
|
||||||
def test_errors(): |
def test_errors(): |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
contract.get_contract_address_from_hash('', fake_shard) |
contract.get_contract_address_from_hash( "", fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
contract.call('', '', endpoint=fake_shard) |
contract.call( "", "", endpoint = fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
contract.estimate_gas('', endpoint=fake_shard) |
contract.estimate_gas( "", endpoint = fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
contract.get_code('', 'latest', endpoint=fake_shard) |
contract.get_code( "", "latest", endpoint = fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
contract.get_storage_at('', 1, 'latest', endpoint=fake_shard) |
contract.get_storage_at( "", 1, "latest", endpoint = fake_shard ) |
||||||
|
@ -1,191 +1,248 @@ |
|||||||
import pytest |
import pytest |
||||||
import requests |
import requests |
||||||
|
|
||||||
from pyhmy import ( |
from pyhmy import staking |
||||||
staking |
|
||||||
) |
|
||||||
|
|
||||||
from pyhmy.rpc import ( |
from pyhmy.rpc import exceptions |
||||||
exceptions |
|
||||||
) |
|
||||||
|
|
||||||
|
explorer_endpoint = "http://localhost:9700" |
||||||
|
test_validator_address = "one155jp2y76nazx8uw5sa94fr0m4s5aj8e5xm6fu3" |
||||||
|
fake_shard = "http://example.com" |
||||||
|
|
||||||
explorer_endpoint = 'http://localhost:9599' |
|
||||||
test_validator_address = 'one18tvf56zqjkjnak686lwutcp5mqfnvee35xjnhc' |
|
||||||
fake_shard = 'http://example.com' |
|
||||||
|
|
||||||
def _test_staking_rpc(fn, *args, **kwargs): |
def _test_staking_rpc( fn, *args, **kwargs ): |
||||||
if not callable(fn): |
if not callable( fn ): |
||||||
pytest.fail(f'Invalid function: {fn}') |
pytest.fail( f"Invalid function: {fn}" ) |
||||||
|
|
||||||
try: |
try: |
||||||
response = fn(*args, **kwargs) |
response = fn( *args, **kwargs ) |
||||||
except Exception as e: |
except Exception as e: |
||||||
if isinstance(e, exceptions.RPCError) and 'does not exist/is not available' in str(e): |
if isinstance( e, |
||||||
pytest.skip(f'{str(e)}') |
exceptions.RPCError |
||||||
pytest.fail(f'Unexpected error: {e.__class__} {e}') |
) and "does not exist/is not available" in str( e ): |
||||||
|
pytest.skip( f"{str(e)}" ) |
||||||
|
pytest.fail( f"Unexpected error: {e.__class__} {e}" ) |
||||||
return response |
return response |
||||||
|
|
||||||
@pytest.mark.run(order=1) |
|
||||||
def test_get_all_validator_addresses(setup_blockchain): |
def test_get_all_validator_addresses( setup_blockchain ): |
||||||
validator_addresses = _test_staking_rpc(staking.get_all_validator_addresses) |
validator_addresses = _test_staking_rpc( |
||||||
assert isinstance(validator_addresses, list) |
staking.get_all_validator_addresses |
||||||
assert len(validator_addresses) > 0 |
) |
||||||
|
assert isinstance( validator_addresses, list ) |
||||||
|
assert len( validator_addresses ) > 0 |
||||||
assert test_validator_address in validator_addresses |
assert test_validator_address in validator_addresses |
||||||
|
|
||||||
@pytest.mark.run(order=2) |
|
||||||
def test_get_validator_information(setup_blockchain): |
def test_get_validator_information( setup_blockchain ): |
||||||
info = _test_staking_rpc(staking.get_validator_information, test_validator_address) |
info = _test_staking_rpc( |
||||||
assert isinstance(info, dict) |
staking.get_validator_information, |
||||||
|
test_validator_address |
||||||
@pytest.mark.run(order=3) |
) |
||||||
def test_get_all_validator_information(setup_blockchain): |
assert isinstance( info, dict ) |
||||||
all_validator_information = _test_staking_rpc(staking.get_all_validator_information) |
|
||||||
assert isinstance(all_validator_information, list) |
|
||||||
assert len(all_validator_information) > 0 |
def test_get_all_validator_information( setup_blockchain ): |
||||||
|
all_validator_information = _test_staking_rpc( |
||||||
@pytest.mark.run(order=4) |
staking.get_all_validator_information |
||||||
def test_get_delegations_by_delegator(setup_blockchain): |
) |
||||||
delegations = _test_staking_rpc(staking.get_delegations_by_delegator, test_validator_address) |
assert isinstance( all_validator_information, list ) |
||||||
assert isinstance(delegations, list) |
assert len( all_validator_information ) > 0 |
||||||
assert len(delegations) > 0 |
|
||||||
|
|
||||||
@pytest.mark.run(order=5) |
def test_get_delegations_by_delegator( setup_blockchain ): |
||||||
def test_get_delegations_by_validator(setup_blockchain): |
delegations = _test_staking_rpc( |
||||||
delegations = _test_staking_rpc(staking.get_delegations_by_validator, test_validator_address) |
staking.get_delegations_by_delegator, |
||||||
assert isinstance(delegations, list) |
test_validator_address |
||||||
assert len(delegations) > 0 |
) |
||||||
|
assert isinstance( delegations, list ) |
||||||
@pytest.mark.run(order=6) |
assert len( delegations ) > 0 |
||||||
def test_get_current_utility_metrics(setup_blockchain): |
|
||||||
metrics = _test_staking_rpc(staking.get_current_utility_metrics) |
|
||||||
assert isinstance(metrics, dict) |
def test_get_delegations_by_validator( setup_blockchain ): |
||||||
|
delegations = _test_staking_rpc( |
||||||
@pytest.mark.run(order=7) |
staking.get_delegations_by_validator, |
||||||
def test_get_staking_network_info(setup_blockchain): |
test_validator_address |
||||||
info = _test_staking_rpc(staking.get_staking_network_info) |
) |
||||||
assert isinstance(info, dict) |
assert isinstance( delegations, list ) |
||||||
|
assert len( delegations ) > 0 |
||||||
@pytest.mark.run(order=8) |
|
||||||
def test_get_super_committees(setup_blockchain): |
|
||||||
committee = _test_staking_rpc(staking.get_super_committees) |
def test_get_current_utility_metrics( setup_blockchain ): |
||||||
assert isinstance(committee, dict) |
metrics = _test_staking_rpc( staking.get_current_utility_metrics ) |
||||||
|
assert isinstance( metrics, dict ) |
||||||
@pytest.mark.run(order=9) |
|
||||||
def test_get_raw_median_stake_snapshot(setup_blockchain): |
|
||||||
median_stake = _test_staking_rpc(staking.get_raw_median_stake_snapshot) |
def test_get_staking_network_info( setup_blockchain ): |
||||||
assert isinstance(median_stake, dict) |
info = _test_staking_rpc( staking.get_staking_network_info ) |
||||||
|
assert isinstance( info, dict ) |
||||||
@pytest.mark.run(order=10) |
|
||||||
def test_get_validator_information_by_block(setup_blockchain): |
|
||||||
|
def test_get_super_committees( setup_blockchain ): |
||||||
|
committee = _test_staking_rpc( staking.get_super_committees ) |
||||||
|
assert isinstance( committee, dict ) |
||||||
|
|
||||||
|
|
||||||
|
def test_get_raw_median_stake_snapshot( setup_blockchain ): |
||||||
|
median_stake = _test_staking_rpc( staking.get_raw_median_stake_snapshot ) |
||||||
|
assert isinstance( median_stake, dict ) |
||||||
|
|
||||||
|
|
||||||
|
def test_get_validator_information_by_block( setup_blockchain ): |
||||||
# Apparently validator information not created until block after create-validator transaction is accepted, so +1 block |
# Apparently validator information not created until block after create-validator transaction is accepted, so +1 block |
||||||
info = _test_staking_rpc(staking.get_validator_information_by_block_number, test_validator_address, setup_blockchain + 1, endpoint=explorer_endpoint) |
info = _test_staking_rpc( |
||||||
assert isinstance(info, dict) |
staking.get_validator_information_by_block_number, |
||||||
|
test_validator_address, |
||||||
|
"latest", |
||||||
|
endpoint = explorer_endpoint, |
||||||
|
) |
||||||
|
assert isinstance( info, dict ) |
||||||
|
|
||||||
|
|
||||||
@pytest.mark.run(order=11) |
def test_get_validator_information_by_block( setup_blockchain ): |
||||||
def test_get_validator_information_by_block(setup_blockchain): |
|
||||||
# Apparently validator information not created until block after create-validator transaction is accepted, so +1 block |
# Apparently validator information not created until block after create-validator transaction is accepted, so +1 block |
||||||
info = _test_staking_rpc(staking.get_all_validator_information_by_block_number, setup_blockchain + 1, endpoint=explorer_endpoint) |
info = _test_staking_rpc( |
||||||
assert isinstance(info, list) |
staking.get_all_validator_information_by_block_number, |
||||||
|
"latest", |
||||||
@pytest.mark.run(order=12) |
endpoint = explorer_endpoint, |
||||||
def test_get_delegations_by_delegator_by_block(setup_blockchain): |
) |
||||||
delegations = _test_staking_rpc(staking.get_delegations_by_delegator_by_block_number, test_validator_address, setup_blockchain + 1, endpoint=explorer_endpoint) |
assert isinstance( info, list ) |
||||||
assert isinstance(delegations, list) |
|
||||||
|
|
||||||
@pytest.mark.run(order=13) |
def test_get_delegations_by_delegator_by_block( setup_blockchain ): |
||||||
def test_get_elected_validator_addresses(setup_blockchain): |
delegations = _test_staking_rpc( |
||||||
validator_addresses = _test_staking_rpc(staking.get_elected_validator_addresses) |
staking.get_delegations_by_delegator_by_block_number, |
||||||
assert isinstance(validator_addresses, list) |
test_validator_address, |
||||||
assert len(validator_addresses) > 0 |
"latest", |
||||||
|
endpoint = explorer_endpoint, |
||||||
@pytest.mark.run(order=14) |
) |
||||||
def test_get_validators(setup_blockchain): |
assert isinstance( delegations, list ) |
||||||
validators = _test_staking_rpc(staking.get_validators, 2) |
|
||||||
assert isinstance(validators, dict) |
|
||||||
assert len(validators['validators']) > 0 |
def test_get_elected_validator_addresses( setup_blockchain ): |
||||||
|
validator_addresses = _test_staking_rpc( |
||||||
@pytest.mark.run(order=15) |
staking.get_elected_validator_addresses |
||||||
def test_get_validator_keys(setup_blockchain): |
) |
||||||
validators = _test_staking_rpc(staking.get_validator_keys, 2) |
assert isinstance( validator_addresses, list ) |
||||||
assert isinstance(validators, list) |
assert len( validator_addresses ) > 0 |
||||||
|
|
||||||
@pytest.mark.run(order=16) |
|
||||||
def test_get_validator_self_delegation(setup_blockchain): |
def test_get_validators( setup_blockchain ): |
||||||
self_delegation = _test_staking_rpc(staking.get_validator_self_delegation, test_validator_address) |
validators = _test_staking_rpc( staking.get_validators, 2 ) |
||||||
assert isinstance(self_delegation, int) |
assert isinstance( validators, dict ) |
||||||
|
assert len( validators[ "validators" ] ) > 0 |
||||||
|
|
||||||
|
|
||||||
|
def test_get_validator_keys( setup_blockchain ): |
||||||
|
validators = _test_staking_rpc( staking.get_validator_keys, 2 ) |
||||||
|
assert isinstance( validators, list ) |
||||||
|
|
||||||
|
|
||||||
|
def test_get_validator_self_delegation( setup_blockchain ): |
||||||
|
self_delegation = _test_staking_rpc( |
||||||
|
staking.get_validator_self_delegation, |
||||||
|
test_validator_address |
||||||
|
) |
||||||
|
assert isinstance( self_delegation, int ) |
||||||
assert self_delegation > 0 |
assert self_delegation > 0 |
||||||
|
|
||||||
@pytest.mark.run(order=17) |
|
||||||
def test_get_validator_total_delegation(setup_blockchain): |
def test_get_validator_total_delegation( setup_blockchain ): |
||||||
total_delegation = _test_staking_rpc(staking.get_validator_total_delegation, test_validator_address) |
total_delegation = _test_staking_rpc( |
||||||
assert isinstance(total_delegation, int) |
staking.get_validator_total_delegation, |
||||||
|
test_validator_address |
||||||
|
) |
||||||
|
assert isinstance( total_delegation, int ) |
||||||
assert total_delegation > 0 |
assert total_delegation > 0 |
||||||
|
|
||||||
@pytest.mark.run(order=18) |
|
||||||
def test_get_all_delegation_information(setup_blockchain): |
def test_get_all_delegation_information( setup_blockchain ): |
||||||
delegation_information = _test_staking_rpc(staking.get_all_delegation_information, 0) |
delegation_information = _test_staking_rpc( |
||||||
assert isinstance(delegation_information, list) |
staking.get_all_delegation_information, |
||||||
assert len(delegation_information) > 0 |
0 |
||||||
|
) |
||||||
@pytest.mark.run(order=19) |
assert isinstance( delegation_information, list ) |
||||||
def test_get_delegation_by_delegator_and_validator(setup_blockchain): |
assert len( delegation_information ) > 0 |
||||||
delegation_information = _test_staking_rpc(staking.get_delegation_by_delegator_and_validator, test_validator_address, test_validator_address) |
|
||||||
assert isinstance(delegation_information, dict) |
|
||||||
|
def test_get_delegation_by_delegator_and_validator( setup_blockchain ): |
||||||
@pytest.mark.run(order=20) |
delegation_information = _test_staking_rpc( |
||||||
def test_get_available_redelegation_balance(setup_blockchain): |
staking.get_delegation_by_delegator_and_validator, |
||||||
redelgation_balance = _test_staking_rpc(staking.get_available_redelegation_balance, test_validator_address) |
test_validator_address, |
||||||
assert isinstance(redelgation_balance, int) |
test_validator_address, |
||||||
|
) |
||||||
|
assert isinstance( delegation_information, dict ) |
||||||
|
|
||||||
|
|
||||||
|
def test_get_available_redelegation_balance( setup_blockchain ): |
||||||
|
redelgation_balance = _test_staking_rpc( |
||||||
|
staking.get_available_redelegation_balance, |
||||||
|
test_validator_address |
||||||
|
) |
||||||
|
assert isinstance( redelgation_balance, int ) |
||||||
assert redelgation_balance == 0 |
assert redelgation_balance == 0 |
||||||
|
|
||||||
@pytest.mark.run(order=21) |
|
||||||
def test_get_total_staking(setup_blockchain): |
def test_get_total_staking( setup_blockchain ): |
||||||
total_staking = _test_staking_rpc(staking.get_total_staking) |
total_staking = _test_staking_rpc( staking.get_total_staking ) |
||||||
assert isinstance(total_staking, int) |
assert isinstance( total_staking, int ) |
||||||
|
if ( |
||||||
|
staking.get_validator_information( |
||||||
|
test_validator_address, |
||||||
|
explorer_endpoint |
||||||
|
)[ "active-status" ] == "active" |
||||||
|
): |
||||||
assert total_staking > 0 |
assert total_staking > 0 |
||||||
|
|
||||||
@pytest.mark.run(order=22) |
|
||||||
def test_errors(): |
def test_errors(): |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
staking.get_all_validator_addresses(fake_shard) |
staking.get_all_validator_addresses( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
staking.get_validator_information('', fake_shard) |
staking.get_validator_information( "", fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
staking.get_elected_validator_addresses(fake_shard) |
staking.get_elected_validator_addresses( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
staking.get_validators(1, fake_shard) |
staking.get_validators( 1, fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
staking.get_validator_keys(1, fake_shard) |
staking.get_validator_keys( 1, fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
staking.get_validator_information_by_block_number('', 1, fake_shard) |
staking.get_validator_information_by_block_number( "", 1, fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
staking.get_all_validator_information(-1, fake_shard) |
staking.get_all_validator_information( 0, fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
staking.get_validator_self_delegation('', fake_shard) |
staking.get_validator_self_delegation( "", fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
staking.get_validator_total_delegation('', fake_shard) |
staking.get_validator_total_delegation( "", fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
staking.get_all_validator_information_by_block_number(1, 1, fake_shard) |
staking.get_all_validator_information_by_block_number( |
||||||
with pytest.raises(exceptions.RPCError): |
1, |
||||||
staking.get_all_delegation_information(1, fake_shard) |
1, |
||||||
with pytest.raises(exceptions.RPCError): |
fake_shard |
||||||
staking.get_delegations_by_delegator('', fake_shard) |
) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
staking.get_delegations_by_delegator_by_block_number('', 1, fake_shard) |
staking.get_all_delegation_information( 1, fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
staking.get_delegation_by_delegator_and_validator('', '', fake_shard) |
staking.get_delegations_by_delegator( "", fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
staking.get_available_redelegation_balance('', fake_shard) |
staking.get_delegations_by_delegator_by_block_number( |
||||||
with pytest.raises(exceptions.RPCError): |
"", |
||||||
staking.get_delegations_by_validator('', fake_shard) |
1, |
||||||
with pytest.raises(exceptions.RPCError): |
fake_shard |
||||||
staking.get_current_utility_metrics(fake_shard) |
) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
staking.get_staking_network_info(fake_shard) |
staking.get_delegation_by_delegator_and_validator( "", "", fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
staking.get_super_committees(fake_shard) |
staking.get_available_redelegation_balance( "", fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
staking.get_total_staking(fake_shard) |
staking.get_delegations_by_validator( "", fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
staking.get_raw_median_stake_snapshot(fake_shard) |
staking.get_current_utility_metrics( fake_shard ) |
||||||
|
with pytest.raises( exceptions.RPCError ): |
||||||
|
staking.get_staking_network_info( fake_shard ) |
||||||
|
with pytest.raises( exceptions.RPCError ): |
||||||
|
staking.get_super_committees( fake_shard ) |
||||||
|
with pytest.raises( exceptions.RPCError ): |
||||||
|
staking.get_total_staking( fake_shard ) |
||||||
|
with pytest.raises( exceptions.RPCError ): |
||||||
|
staking.get_raw_median_stake_snapshot( fake_shard ) |
||||||
|
@ -1,218 +1,266 @@ |
|||||||
import pytest |
import pytest |
||||||
|
|
||||||
from pyhmy import ( |
from pyhmy import transaction |
||||||
transaction |
|
||||||
) |
|
||||||
|
|
||||||
from pyhmy.rpc import ( |
from pyhmy.rpc import exceptions |
||||||
exceptions |
|
||||||
) |
|
||||||
|
|
||||||
from pyhmy.exceptions import ( |
endpoint = "http://localhost:9500" |
||||||
TxConfirmationTimedoutError |
endpoint_shard_one = "http://localhost:9502" |
||||||
) |
fake_shard = "http://example.com" |
||||||
|
|
||||||
|
# previously sent txs to get and check |
||||||
localhost_shard_one = 'http://localhost:9501' |
tx_hash = "0xc26be5776aa57438bccf196671a2d34f3f22c9c983c0f844c62b2fb90403aa43" |
||||||
tx_hash = '0x1fa20537ea97f162279743139197ecf0eac863278ac1c8ada9a6be5d1e31e633' |
|
||||||
tx_block_num = None |
tx_block_num = None |
||||||
tx_block_hash = None |
tx_block_hash = None |
||||||
cx_hash = '0x1fa20537ea97f162279743139197ecf0eac863278ac1c8ada9a6be5d1e31e633' |
tx_index = None |
||||||
stx_hash = '0x57ec011aabdeb078a4816502224022f291fa8b07c82bbae8476f514a1d71c730' |
|
||||||
|
cx_hash = "0xf73ba634cb96fc0e3e2c9d3b4c91379e223741be4a5aa56e6d6caf49c1ae75cf" |
||||||
|
|
||||||
|
stx_hash = "0xc8177ace2049d9f4eb4a45fd6bd6b16f693573d036322c36774cc00d05a3e24f" |
||||||
stx_block_num = None |
stx_block_num = None |
||||||
stx_block_hash = None |
stx_block_hash = None |
||||||
test_index = 0 |
stx_index = None |
||||||
fake_shard = 'http://example.com' |
|
||||||
|
# new txs to send and check |
||||||
|
raw_tx = "0xf86f0385174876e800825208808094c9c6d47ee5f2e3e08d7367ad1a1373ba9dd172418905b12aefafa80400008027a07a4952b90bf38723a9197179a8e6d2e9b3a86fd6da4e66a9cf09fdc59783f757a053910798b311245525bd77d6119332458c2855102e4fb9e564f6a3b710d18bb0" |
||||||
|
raw_tx_hash = "0x7ccd80f8513f76ec58b357c7a82a12a95e025d88f1444e953f90e3d86e222571" |
||||||
|
|
||||||
# raw_txt generated via: |
raw_stx = "0xf88302f494c9c6d47ee5f2e3e08d7367ad1a1373ba9dd1724194a5241513da9f4463f1d4874b548dfbac29d91f3489056bc75e2d631000008085174876e80082c35027a0808ea7d27adf3b1f561e8da4676814084bb75ac541b616bece87c6446e6cc54ea02f19f0b14240354bd42ad60b0c7189873c0be87044e13072b0981a837ca76f64" |
||||||
# hmy transfer --from one12fuf7x9rgtdgqg7vgq0962c556m3p7afsxgvll --to one12fuf7x9rgtdgqg7vgq0962c556m3p7afsxgvll |
raw_stx_hash = "0xe7d07ef6d9fca595a14ceb0ca917bece7bedb15efe662300e9334a32ac1da629" |
||||||
# --from-shard 0 --to-shard 1 --amount 0.1 --dry-run |
|
||||||
raw_tx = '0xf86d01843b9aca0082520880019452789f18a342da8023cc401e5d2b14a6b710fba988016345785d8a00008028a01095f775386e0e3203446179a7a62e5ce1e765c200b5d885f6bb5b141155bd4da0651350a31e1797035cbf878e4c26069e9895845071d01308573532512cca5820' |
|
||||||
raw_tx_hash = '0x86bce2e7765937b776bdcf927339c85421b95c70ddf06ba8e4cc0441142b0f53' |
|
||||||
|
|
||||||
raw_stx = '0xf9015680f90105943ad89a684095a53edb47d7ddc5e034d813366731d984746573748474657374847465737484746573748474657374ddc988016345785d8a0000c9880c7d713b49da0000c887b1a2bc2ec500008a022385a827e8155000008b084595161401484a000000f1b0282554f2478661b4844a05a9deb1837aac83931029cb282872f0dcd7239297c499c02ea8da8746d2f08ca2b037e89891f862b86003557e18435c201ecc10b1664d1aea5b4ec59dbfe237233b953dbd9021b86bc9770e116ed3c413fe0334d89562568a10e133d828611f29fee8cdab9719919bbcc1f1bf812c73b9ccd0f89b4f0b9ca7e27e66d58bbb06fcf51c295b1d076cfc878a0228f16f86157860000080843b9aca008351220027a018385211a150ca032c3526cef0aba6a75f99a18cb73f547f67bab746be0c7a64a028be921002c6eb949b3932afd010dfe1de2459ec7fe84403b9d9d8892394a78c' |
|
||||||
|
|
||||||
def _test_transaction_rpc(fn, *args, **kwargs): |
def _test_transaction_rpc( fn, *args, **kwargs ): |
||||||
if not callable(fn): |
if not callable( fn ): |
||||||
pytest.fail(f'Invalid function: {fn}') |
pytest.fail( f"Invalid function: {fn}" ) |
||||||
|
|
||||||
try: |
try: |
||||||
response = fn(*args, **kwargs) |
response = fn( *args, **kwargs ) |
||||||
except Exception as e: |
except Exception as e: |
||||||
if isinstance(e, exceptions.RPCError) and 'does not exist/is not available' in str(e): |
if isinstance( e, |
||||||
pytest.skip(f'{str(e)}') |
exceptions.RPCError |
||||||
if isinstance(e, TxConfirmationTimedoutError): |
) and "does not exist/is not available" in str( e ): |
||||||
pytest.skip(f'{str(e)}') |
pytest.skip( f"{str(e)}" ) |
||||||
pytest.fail(f'Unexpected error: {e.__class__} {e}') |
pytest.fail( f"Unexpected error: {e.__class__} {e}" ) |
||||||
return response |
return response |
||||||
|
|
||||||
@pytest.mark.run(order=1) |
|
||||||
def test_get_pending_transactions(setup_blockchain): |
|
||||||
pool = _test_transaction_rpc(transaction.get_pending_transactions) |
|
||||||
assert isinstance(pool, list) |
|
||||||
|
|
||||||
@pytest.mark.run(order=2) |
def test_get_pending_transactions( setup_blockchain ): |
||||||
def test_get_transaction_by_hash(setup_blockchain): |
pool = _test_transaction_rpc( transaction.get_pending_transactions ) |
||||||
tx = _test_transaction_rpc(transaction.get_transaction_by_hash, tx_hash, endpoint=localhost_shard_one) |
assert isinstance( pool, list ) |
||||||
|
|
||||||
|
|
||||||
|
def test_get_transaction_by_hash( setup_blockchain ): |
||||||
|
tx = _test_transaction_rpc( |
||||||
|
transaction.get_transaction_by_hash, |
||||||
|
tx_hash, |
||||||
|
endpoint = endpoint |
||||||
|
) |
||||||
assert tx |
assert tx |
||||||
assert isinstance(tx, dict) |
assert isinstance( tx, dict ) |
||||||
assert 'blockNumber' in tx.keys() |
assert "blockNumber" in tx.keys() |
||||||
assert 'blockHash' in tx.keys() |
assert "blockHash" in tx.keys() |
||||||
global tx_block_num |
global tx_block_num |
||||||
tx_block_num = int(tx['blockNumber']) |
tx_block_num = int( tx[ "blockNumber" ] ) |
||||||
global tx_block_hash |
global tx_block_hash |
||||||
tx_block_hash = tx['blockHash'] |
tx_block_hash = tx[ "blockHash" ] |
||||||
|
global tx_index |
||||||
|
tx_index = int( tx[ "transactionIndex" ] ) |
||||||
|
|
||||||
@pytest.mark.run(order=3) |
|
||||||
def test_get_transaction_by_block_hash_and_index(setup_blockchain): |
def test_get_transaction_by_block_hash_and_index( setup_blockchain ): |
||||||
if not tx_block_hash: |
if not tx_block_hash: |
||||||
pytest.skip('Failed to get reference block hash') |
pytest.skip( "Failed to get reference block hash" ) |
||||||
tx = _test_transaction_rpc(transaction.get_transaction_by_block_hash_and_index, |
tx = _test_transaction_rpc( |
||||||
tx_block_hash, test_index, endpoint=localhost_shard_one) |
transaction.get_transaction_by_block_hash_and_index, |
||||||
|
tx_block_hash, |
||||||
|
tx_index, |
||||||
|
endpoint = endpoint, |
||||||
|
) |
||||||
assert tx |
assert tx |
||||||
assert isinstance(tx, dict) |
assert isinstance( tx, dict ) |
||||||
|
|
||||||
|
|
||||||
@pytest.mark.run(order=4) |
def test_get_transaction_by_block_number_and_index( setup_blockchain ): |
||||||
def test_get_transaction_by_block_number_and_index(setup_blockchain): |
|
||||||
if not tx_block_num: |
if not tx_block_num: |
||||||
pytest.skip('Failed to get reference block num') |
pytest.skip( "Failed to get reference block num" ) |
||||||
tx = _test_transaction_rpc(transaction.get_transaction_by_block_number_and_index, tx_block_num, test_index, |
tx = _test_transaction_rpc( |
||||||
endpoint=localhost_shard_one) |
transaction.get_transaction_by_block_number_and_index, |
||||||
|
tx_block_num, |
||||||
|
tx_index, |
||||||
|
endpoint = endpoint, |
||||||
|
) |
||||||
assert tx |
assert tx |
||||||
assert isinstance(tx, dict) |
assert isinstance( tx, dict ) |
||||||
|
|
||||||
@pytest.mark.run(order=5) |
|
||||||
def test_get_transaction_receipt(setup_blockchain): |
def test_get_transaction_receipt( setup_blockchain ): |
||||||
tx_receipt = _test_transaction_rpc(transaction.get_transaction_receipt, tx_hash, endpoint=localhost_shard_one) |
tx_receipt = _test_transaction_rpc( |
||||||
|
transaction.get_transaction_receipt, |
||||||
|
tx_hash, |
||||||
|
endpoint = endpoint |
||||||
|
) |
||||||
assert tx_receipt |
assert tx_receipt |
||||||
assert isinstance(tx_receipt, dict) |
assert isinstance( tx_receipt, dict ) |
||||||
|
|
||||||
|
|
||||||
@pytest.mark.run(order=6) |
def test_get_transaction_error_sink( setup_blockchain ): |
||||||
def test_get_transaction_error_sink(setup_blockchain): |
errors = _test_transaction_rpc( transaction.get_transaction_error_sink ) |
||||||
errors = _test_transaction_rpc(transaction.get_transaction_error_sink) |
assert isinstance( errors, list ) |
||||||
assert isinstance(errors, list) |
|
||||||
|
|
||||||
@pytest.mark.run(order=7) |
|
||||||
def test_send_and_confirm_raw_transaction(setup_blockchain): |
def test_send_and_confirm_raw_transaction( setup_blockchain ): |
||||||
# Note: this test is not yet idempotent since the localnet will reject transactions which were previously finalized. |
# Note: this test is not yet idempotent since the localnet will reject transactions which were previously finalized. |
||||||
# Secondly, this is a test that seems to return None values - for example the below curl call has the same null value |
test_tx = _test_transaction_rpc( |
||||||
# curl --location --request POST 'http://localhost:9501' \ |
transaction.send_and_confirm_raw_transaction, |
||||||
# --header 'Content-Type: application/json' \ |
raw_tx |
||||||
# --data-raw '{ |
) |
||||||
# "jsonrpc": "2.0", |
assert isinstance( test_tx, dict ) |
||||||
# "id": 1, |
assert test_tx[ "hash" ] == raw_tx_hash |
||||||
# "method": "hmyv2_getTransactionByHash", |
|
||||||
# "params": [ |
|
||||||
# "0x86bce2e7765937b776bdcf927339c85421b95c70ddf06ba8e4cc0441142b0f53" |
def test_get_pending_cx_receipts( setup_blockchain ): |
||||||
# ] |
pending = _test_transaction_rpc( transaction.get_pending_cx_receipts ) |
||||||
# }' |
assert isinstance( pending, list ) |
||||||
# {"jsonrpc":"2.0","id":1,"result":null} |
|
||||||
test_tx = _test_transaction_rpc(transaction.send_and_confirm_raw_transaction, |
|
||||||
raw_tx) # mining stops by the time this transaction is submitted |
def test_get_cx_receipt_by_hash( setup_blockchain ): |
||||||
# so it never confirms, which is why TxConfirmationTimedoutError |
cx = _test_transaction_rpc( |
||||||
# is in the set up call |
transaction.get_cx_receipt_by_hash, |
||||||
assert isinstance(test_tx, dict) |
cx_hash, |
||||||
assert test_tx[ 'hash' ] == raw_tx_hash |
endpoint_shard_one |
||||||
|
) |
||||||
@pytest.mark.run(order=8) |
|
||||||
def test_get_pending_cx_receipts(setup_blockchain): |
|
||||||
pending = _test_transaction_rpc(transaction.get_pending_cx_receipts) |
|
||||||
assert isinstance(pending, list) |
|
||||||
|
|
||||||
@pytest.mark.run(order=9) |
|
||||||
def test_get_cx_receipt_by_hash(setup_blockchain): |
|
||||||
cx = _test_transaction_rpc(transaction.get_cx_receipt_by_hash, cx_hash) |
|
||||||
assert cx |
assert cx |
||||||
assert isinstance(cx, dict) |
assert isinstance( cx, dict ) |
||||||
|
|
||||||
@pytest.mark.run(order=10) |
|
||||||
def test_resend_cx_receipt(setup_blockchain): |
|
||||||
sent = _test_transaction_rpc(transaction.resend_cx_receipt, cx_hash) |
|
||||||
assert isinstance(sent, bool) |
|
||||||
assert not sent |
|
||||||
|
|
||||||
@pytest.mark.run(order=11) |
def test_resend_cx_receipt( setup_blockchain ): |
||||||
def test_get_staking_transaction_by_hash(setup_blockchain): |
sent = _test_transaction_rpc( transaction.resend_cx_receipt, cx_hash ) |
||||||
staking_tx = _test_transaction_rpc(transaction.get_staking_transaction_by_hash, stx_hash) |
assert isinstance( sent, bool ) |
||||||
|
assert sent |
||||||
|
|
||||||
|
|
||||||
|
def test_get_staking_transaction_by_hash( setup_blockchain ): |
||||||
|
staking_tx = _test_transaction_rpc( |
||||||
|
transaction.get_staking_transaction_by_hash, |
||||||
|
stx_hash |
||||||
|
) |
||||||
assert staking_tx |
assert staking_tx |
||||||
assert isinstance(staking_tx, dict) |
assert isinstance( staking_tx, dict ) |
||||||
assert 'blockNumber' in staking_tx.keys() |
assert "blockNumber" in staking_tx.keys() |
||||||
assert 'blockHash' in staking_tx.keys() |
assert "blockHash" in staking_tx.keys() |
||||||
global stx_block_num |
global stx_block_num |
||||||
stx_block_num = int(staking_tx['blockNumber']) |
stx_block_num = int( staking_tx[ "blockNumber" ] ) |
||||||
global stx_block_hash |
global stx_block_hash |
||||||
stx_block_hash = staking_tx['blockHash'] |
stx_block_hash = staking_tx[ "blockHash" ] |
||||||
|
global stx_index |
||||||
|
stx_index = int( staking_tx[ "transactionIndex" ] ) |
||||||
|
|
||||||
@pytest.mark.run(order=12) |
|
||||||
def test_get_transaction_by_block_hash_and_index(setup_blockchain): |
def test_get_transaction_by_block_hash_and_index( setup_blockchain ): |
||||||
if not stx_block_hash: |
if not stx_block_hash: |
||||||
pytest.skip('Failed to get reference block hash') |
pytest.skip( "Failed to get reference block hash" ) |
||||||
stx = _test_transaction_rpc(transaction.get_staking_transaction_by_block_hash_and_index, stx_block_hash, test_index) |
stx = _test_transaction_rpc( |
||||||
|
transaction.get_staking_transaction_by_block_hash_and_index, |
||||||
|
stx_block_hash, |
||||||
|
stx_index, |
||||||
|
) |
||||||
assert stx |
assert stx |
||||||
assert isinstance(stx, dict) |
assert isinstance( stx, dict ) |
||||||
|
|
||||||
|
|
||||||
@pytest.mark.run(order=13) |
def test_get_transaction_by_block_number_and_index( setup_blockchain ): |
||||||
def test_get_transaction_by_block_number_and_index(setup_blockchain): |
|
||||||
if not stx_block_num: |
if not stx_block_num: |
||||||
pytest.skip('Failed to get reference block num') |
pytest.skip( "Failed to get reference block num" ) |
||||||
stx = _test_transaction_rpc(transaction.get_staking_transaction_by_block_number_and_index, stx_block_num, test_index) |
stx = _test_transaction_rpc( |
||||||
|
transaction.get_staking_transaction_by_block_number_and_index, |
||||||
|
stx_block_num, |
||||||
|
stx_index, |
||||||
|
) |
||||||
assert stx |
assert stx |
||||||
assert isinstance(stx, dict) |
assert isinstance( stx, dict ) |
||||||
|
|
||||||
@pytest.mark.run(order=14) |
|
||||||
def test_get_staking_transaction_error_sink(setup_blockchain): |
def test_get_staking_transaction_error_sink( setup_blockchain ): |
||||||
errors = _test_transaction_rpc(transaction.get_staking_transaction_error_sink) |
errors = _test_transaction_rpc( |
||||||
assert isinstance(errors, list) |
transaction.get_staking_transaction_error_sink |
||||||
|
) |
||||||
@pytest.mark.run(order=15) |
assert isinstance( errors, list ) |
||||||
def test_send_raw_staking_transaction(setup_blockchain): |
|
||||||
test_stx_hash = _test_transaction_rpc(transaction.send_raw_staking_transaction, raw_stx, endpoint=localhost_shard_one) |
|
||||||
assert isinstance(test_stx_hash, str) |
def test_send_raw_staking_transaction( setup_blockchain ): |
||||||
assert test_stx_hash == stx_hash |
test_stx = _test_transaction_rpc( |
||||||
|
transaction.send_and_confirm_raw_staking_transaction, |
||||||
@pytest.mark.run(order=16) |
raw_stx, |
||||||
def test_get_pool_stats(setup_blockchain): |
endpoint = endpoint |
||||||
test_pool_stats = _test_transaction_rpc(transaction.get_pool_stats, endpoint=localhost_shard_one) |
) |
||||||
assert isinstance(test_pool_stats, dict) |
assert isinstance( test_stx, dict ) |
||||||
|
assert test_stx[ "hash" ] == raw_stx_hash |
||||||
@pytest.mark.run(order=17) |
|
||||||
def test_get_pending_staking_transactions(setup_blockchain): |
|
||||||
pending_staking_transactions = _test_transaction_rpc(transaction.get_pending_staking_transactions, endpoint=localhost_shard_one) |
def test_get_pool_stats( setup_blockchain ): |
||||||
assert isinstance(pending_staking_transactions, list) |
test_pool_stats = _test_transaction_rpc( |
||||||
|
transaction.get_pool_stats, |
||||||
@pytest.mark.run(order=18) |
endpoint = endpoint |
||||||
|
) |
||||||
|
assert isinstance( test_pool_stats, dict ) |
||||||
|
|
||||||
|
|
||||||
|
def test_get_pending_staking_transactions( setup_blockchain ): |
||||||
|
pending_staking_transactions = _test_transaction_rpc( |
||||||
|
transaction.get_pending_staking_transactions, |
||||||
|
endpoint = endpoint |
||||||
|
) |
||||||
|
assert isinstance( pending_staking_transactions, list ) |
||||||
|
|
||||||
|
|
||||||
def test_errors(): |
def test_errors(): |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
transaction.get_pending_transactions(fake_shard) |
transaction.get_pending_transactions( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
transaction.get_transaction_error_sink(fake_shard) |
transaction.get_transaction_error_sink( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
transaction.get_pool_stats(fake_shard) |
transaction.get_pool_stats( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
transaction.get_transaction_by_hash('', endpoint=fake_shard) |
transaction.get_transaction_by_hash( "", endpoint = fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
transaction.get_transaction_by_block_hash_and_index('', 1, endpoint=fake_shard) |
transaction.get_transaction_by_block_hash_and_index( |
||||||
with pytest.raises(exceptions.RPCError): |
"", |
||||||
transaction.get_transaction_by_block_number_and_index(1, 1, endpoint=fake_shard) |
1, |
||||||
with pytest.raises(exceptions.RPCError): |
endpoint = fake_shard |
||||||
transaction.get_transaction_receipt('', endpoint=fake_shard) |
) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
transaction.send_raw_transaction('', endpoint=fake_shard) |
transaction.get_transaction_by_block_number_and_index( |
||||||
with pytest.raises(exceptions.RPCError): |
1, |
||||||
transaction.get_pending_cx_receipts(fake_shard) |
1, |
||||||
with pytest.raises(exceptions.RPCError): |
endpoint = fake_shard |
||||||
transaction.get_cx_receipt_by_hash('', endpoint=fake_shard) |
) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
transaction.resend_cx_receipt('', endpoint=fake_shard) |
transaction.get_transaction_receipt( "", endpoint = fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
transaction.get_staking_transaction_by_hash('', endpoint=fake_shard) |
transaction.send_raw_transaction( "", endpoint = fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
transaction.get_staking_transaction_by_block_hash_and_index('', 1, endpoint=fake_shard) |
transaction.get_pending_cx_receipts( fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
transaction.get_staking_transaction_by_block_number_and_index(1, 1, endpoint=fake_shard) |
transaction.get_cx_receipt_by_hash( "", endpoint = fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
transaction.get_staking_transaction_error_sink(endpoint=fake_shard) |
transaction.resend_cx_receipt( "", endpoint = fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
transaction.send_raw_staking_transaction('', endpoint=fake_shard) |
transaction.get_staking_transaction_by_hash( "", endpoint = fake_shard ) |
||||||
with pytest.raises(exceptions.RPCError): |
with pytest.raises( exceptions.RPCError ): |
||||||
transaction.get_pending_staking_transactions(endpoint=fake_shard) |
transaction.get_staking_transaction_by_block_hash_and_index( |
||||||
|
"", |
||||||
|
1, |
||||||
|
endpoint = fake_shard |
||||||
|
) |
||||||
|
with pytest.raises( exceptions.RPCError ): |
||||||
|
transaction.get_staking_transaction_by_block_number_and_index( |
||||||
|
1, |
||||||
|
1, |
||||||
|
endpoint = fake_shard |
||||||
|
) |
||||||
|
with pytest.raises( exceptions.RPCError ): |
||||||
|
transaction.get_staking_transaction_error_sink( endpoint = fake_shard ) |
||||||
|
with pytest.raises( exceptions.RPCError ): |
||||||
|
transaction.send_raw_staking_transaction( "", endpoint = fake_shard ) |
||||||
|
with pytest.raises( exceptions.RPCError ): |
||||||
|
transaction.get_pending_staking_transactions( endpoint = fake_shard ) |
||||||
|
Loading…
Reference in new issue