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
a91ca3f3
Commit
a91ca3f3
authored
1 year ago
by
Krzysztof Mochocki
Browse files
Options
Downloads
Patches
Plain Diff
Add AlternateChainSpecs class
parent
7b6cca18
No related branches found
No related tags found
1 merge request
!197
Summary MR for !194 and !192
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
package/test_tools/__init__.py
+4
-0
4 additions, 0 deletions
package/test_tools/__init__.py
package/test_tools/__private/alternate_chain_specs.py
+60
-0
60 additions, 0 deletions
package/test_tools/__private/alternate_chain_specs.py
with
64 additions
and
0 deletions
package/test_tools/__init__.py
+
4
−
0
View file @
a91ca3f3
...
...
@@ -13,6 +13,7 @@ from test_tools.__private import (
paths_to_executables
,
)
from
test_tools.__private.account
import
Account
,
PrivateKey
,
PublicKey
from
test_tools.__private.alternate_chain_specs
import
AlternateChainSpecs
,
HardforkSchedule
,
InitialVesting
from
test_tools.__private.block_log
import
BlockLog
# User handles
...
...
@@ -48,6 +49,9 @@ __all__ = [
"
Asset
"
,
"
Time
"
,
"
TimeFormats
"
,
"
AlternateChainSpecs
"
,
"
HardforkSchedule
"
,
"
InitialVesting
"
,
]
if
TYPE_CHECKING
:
...
...
This diff is collapsed.
Click to expand it.
package/test_tools/__private/alternate_chain_specs.py
0 → 100644
+
60
−
0
View file @
a91ca3f3
from
__future__
import
annotations
from
pathlib
import
Path
from
typing
import
ClassVar
from
pydantic
import
BaseModel
,
Protocol
from
test_tools.__private.user_handles
import
context
class
InitialVesting
(
BaseModel
):
vests_per_hive
:
int
hive_amount
:
int
class
HardforkSchedule
(
BaseModel
):
hardfork
:
int
block_num
:
int
class
AlternateChainSpecs
(
BaseModel
):
FILENAME
:
ClassVar
[
str
]
=
"
alternate-chain-spec.json
"
genesis_time
:
int
hardfork_schedule
:
list
[
HardforkSchedule
]
init_supply
:
int
|
None
=
None
hbd_init_supply
:
int
|
None
=
None
initial_vesting
:
InitialVesting
|
None
=
None
init_witnesses
:
list
[
str
]
|
None
=
None
hive_owner_update_limit
:
int
|
None
=
None
def
export_to_file
(
self
,
output_dir
:
Path
|
None
=
None
)
->
Path
:
if
output_dir
is
None
:
output_dir
=
context
.
get_current_directory
()
output_dir
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
destination
=
output_dir
/
AlternateChainSpecs
.
FILENAME
with
destination
.
open
(
"
w
"
)
as
json_file
:
json_file
.
write
(
self
.
json
(
exclude_none
=
True
))
return
destination
@classmethod
def
parse_file
(
cls
:
type
[
AlternateChainSpecs
],
path
:
str
|
Path
,
*
,
content_type
:
str
|
None
=
None
,
encoding
:
str
=
"
utf8
"
,
proto
:
Protocol
|
None
=
None
,
allow_pickle
:
bool
=
False
,
)
->
AlternateChainSpecs
:
if
isinstance
(
path
,
str
):
path
=
Path
(
path
)
if
path
.
is_dir
():
path
=
path
/
AlternateChainSpecs
.
FILENAME
assert
path
.
is_file
(),
f
"
Given path: `
{
path
.
as_posix
()
}
` is not pointing to file!
"
return
super
().
parse_file
(
path
,
content_type
=
content_type
,
encoding
=
encoding
,
proto
=
proto
,
allow_pickle
=
allow_pickle
# type: ignore
)
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