Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
test-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
test-tools
Commits
d4e8dfcd
Commit
d4e8dfcd
authored
1 year ago
by
Radosław Masłowski
Browse files
Options
Downloads
Patches
Plain Diff
Add simply functional tests
parent
4e54ba4f
No related branches found
No related tags found
1 merge request
!188
Implement block log utils tools
Pipeline
#86202
passed
1 year ago
Stage: static_code_analysis
Stage: tests
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/functional_tests/block_log_tests/test_block_log_util_tools.py
+84
-0
84 additions, 0 deletions
...tional_tests/block_log_tests/test_block_log_util_tools.py
with
84 additions
and
0 deletions
tests/functional_tests/block_log_tests/test_block_log_util_tools.py
0 → 100644
+
84
−
0
View file @
d4e8dfcd
from
__future__
import
annotations
import
pytest
import
test_tools
as
tt
from
test_tools.__private.exceptions
import
BlockLogUtilError
from
schemas.apis.block_api.response_schemas
import
GetBlockBase
@pytest.fixture
()
def
node
()
->
tt
.
InitNode
:
node
=
tt
.
InitNode
()
node
.
run
(
time_offset
=
"
+0h x10
"
)
node
.
wait_for_block_with_number
(
30
)
time_offset
=
node
.
get_head_block_time
()
node
.
restart
(
time_offset
=
tt
.
Time
.
serialize
(
time_offset
,
format_
=
tt
.
TimeFormats
.
TIME_OFFSET_FORMAT
))
return
node
def
test_get_head_block_number
(
node
:
tt
.
InitNode
)
->
None
:
block_log
=
node
.
block_log
head_block_number_from_node
=
node
.
get_last_block_number
()
node
.
close
()
assert
(
block_log
.
get_head_block_number
()
==
head_block_number_from_node
),
"
Head_block_number from block_log is other than head_block_number from node
"
def
test_get_block
(
node
:
tt
.
InitNode
)
->
None
:
block_log
=
node
.
block_log
block_from_node
=
node
.
api
.
block
.
get_block
(
block_num
=
10
)
node
.
close
()
block_from_block_log
=
block_log
.
get_block
(
block_number
=
10
)
assert
isinstance
(
block_from_node
,
GetBlockBase
)
assert
(
block_from_node
.
block
.
previous
==
block_from_block_log
.
previous
),
"
Get_block from block_log getting other block than get_block from node
"
def
test_get_head_block_time
(
node
:
tt
.
InitNode
)
->
None
:
block_log
=
node
.
block_log
head_block_time_from_node
=
node
.
get_head_block_time
()
node
.
close
()
head_block_time_from_block_log
=
block_log
.
get_head_block_time
()
head_block_time_from_block_log_serialized
=
block_log
.
get_head_block_time
(
serialize
=
True
,
serialize_format
=
tt
.
TimeFormats
.
TIME_OFFSET_FORMAT
)
assert
(
head_block_time_from_node
==
head_block_time_from_block_log
),
"
Head_block_time from block_log is other than head_block_time from node
"
assert
(
tt
.
Time
.
serialize
(
time
=
head_block_time_from_node
,
format_
=
tt
.
TimeFormats
.
TIME_OFFSET_FORMAT
)
==
head_block_time_from_block_log_serialized
),
"
Serialized head_block_time from block_log is other than serialized head_block_time from node
"
def
test_generate_artifacts
(
node
:
tt
.
InitNode
)
->
None
:
block_log
=
node
.
block_log
node
.
close
()
if
block_log
.
artifacts_path
.
exists
():
block_log
.
artifacts_path
.
unlink
()
assert
not
block_log
.
artifacts_path
.
exists
()
block_log
.
generate_artifacts
()
assert
block_log
.
artifacts_path
.
exists
(),
"
Block_log.artifacts was not generated
"
def
test_exception_handling
(
node
:
tt
.
InitNode
)
->
None
:
block_log
=
node
.
block_log
node
.
close
()
with
pytest
.
raises
(
BlockLogUtilError
)
as
error
:
block_log
.
get_block
(
"
incorrect_block_num
"
)
# type: ignore
assert
"
the argument (
'
incorrect_block_num
'
) for option
'
--block-number
'
is invalid
"
in
str
(
error
.
value
),
"
Incorrect error message
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment