Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zombienet-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
parity
Mirrored projects
zombienet-sdk
Commits
2fc985a5
Verified
Commit
2fc985a5
authored
1 year ago
by
Loris Moulin
Browse files
Options
Downloads
Patches
Plain Diff
feat: added correct error types to ParachainConfigBuilder
parent
b11a1bee
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
crates/configuration/src/parachain.rs
+72
-37
72 additions, 37 deletions
crates/configuration/src/parachain.rs
with
72 additions
and
37 deletions
crates/configuration/src/parachain.rs
+
72
−
37
View file @
2fc985a5
use
std
::
marker
::
PhantomData
;
use
std
::
{
error
::
Error
,
marker
::
PhantomData
}
;
use
multiaddr
::
Multiaddr
;
use
crate
::
shared
::{
helpers
::
merge_errors
,
errors
::
FieldError
,
helpers
::{
merge_errors
,
merge_errors_vecs
},
macros
::
states
,
node
::{
self
,
NodeConfig
,
NodeConfigBuilder
},
types
::{
AssetLocation
,
Chain
,
Command
},
...
...
@@ -112,10 +113,10 @@ states! {
}
#[derive(Debug)]
pub
struct
ParachainConfigBuilder
<
S
tate
>
{
pub
struct
ParachainConfigBuilder
<
S
>
{
config
:
ParachainConfig
,
errors
:
Vec
<
String
>
,
_state
:
PhantomData
<
S
tate
>
,
errors
:
Vec
<
Box
<
dyn
Error
>
>
,
_state
:
PhantomData
<
S
>
,
}
impl
Default
for
ParachainConfigBuilder
<
Initial
>
{
...
...
@@ -142,7 +143,10 @@ impl Default for ParachainConfigBuilder<Initial> {
}
impl
<
A
>
ParachainConfigBuilder
<
A
>
{
fn
transition
<
B
>
(
config
:
ParachainConfig
,
errors
:
Vec
<
String
>
)
->
ParachainConfigBuilder
<
B
>
{
fn
transition
<
B
>
(
config
:
ParachainConfig
,
errors
:
Vec
<
Box
<
dyn
Error
>>
,
)
->
ParachainConfigBuilder
<
B
>
{
ParachainConfigBuilder
{
config
,
errors
,
...
...
@@ -179,7 +183,11 @@ impl ParachainConfigBuilder<WithId> {
}
impl
ParachainConfigBuilder
<
WithAtLeastOneCollator
>
{
pub
fn
with_chain
(
self
,
chain
:
impl
TryInto
<
Chain
>
)
->
Self
{
pub
fn
with_chain
<
T
>
(
self
,
chain
:
T
)
->
Self
where
T
:
TryInto
<
Chain
>
,
T
::
Error
:
Error
+
'static
,
{
match
chain
.try_into
()
{
Ok
(
chain
)
=>
Self
::
transition
(
ParachainConfig
{
...
...
@@ -188,10 +196,9 @@ impl ParachainConfigBuilder<WithAtLeastOneCollator> {
},
self
.errors
,
),
Err
(
_
error
)
=>
Self
::
transition
(
Err
(
error
)
=>
Self
::
transition
(
self
.config
,
// merge_errors(self.errors, format!("chain: {error}")),
merge_errors
(
self
.errors
,
format!
(
"chain: "
)),
merge_errors
(
self
.errors
,
FieldError
::
InvalidChain
(
error
)
.into
()),
),
}
}
...
...
@@ -216,7 +223,11 @@ impl ParachainConfigBuilder<WithAtLeastOneCollator> {
)
}
pub
fn
with_genesis_wasm_path
(
self
,
location
:
impl
TryInto
<
AssetLocation
>
)
->
Self
{
pub
fn
with_genesis_wasm_path
<
T
>
(
self
,
location
:
T
)
->
Self
where
T
:
TryInto
<
AssetLocation
>
,
T
::
Error
:
Error
+
'static
,
{
match
location
.try_into
()
{
Ok
(
location
)
=>
Self
::
transition
(
ParachainConfig
{
...
...
@@ -225,15 +236,21 @@ impl ParachainConfigBuilder<WithAtLeastOneCollator> {
},
self
.errors
,
),
Err
(
_
error
)
=>
Self
::
transition
(
Err
(
error
)
=>
Self
::
transition
(
self
.config
,
// merge_errors(self.errors, format!("genesis_wasm_path: {error}")),
merge_errors
(
self
.errors
,
format!
(
"genesis_wasm_path: "
)),
merge_errors
(
self
.errors
,
FieldError
::
InvalidGenesisWasmPath
(
error
)
.into
(),
),
),
}
}
pub
fn
with_genesis_wasm_generator
(
self
,
command
:
impl
TryInto
<
Command
>
)
->
Self
{
pub
fn
with_genesis_wasm_generator
<
T
>
(
self
,
command
:
T
)
->
Self
where
T
:
TryInto
<
Command
>
,
T
::
Error
:
Error
+
'static
,
{
match
command
.try_into
()
{
Ok
(
command
)
=>
Self
::
transition
(
ParachainConfig
{
...
...
@@ -242,15 +259,21 @@ impl ParachainConfigBuilder<WithAtLeastOneCollator> {
},
self
.errors
,
),
Err
(
_
error
)
=>
Self
::
transition
(
Err
(
error
)
=>
Self
::
transition
(
self
.config
,
// merge_errors(self.errors, format!("genesis_wasm_generator: {error}")),
merge_errors
(
self
.errors
,
format!
(
"genesis_wasm_generator: "
)),
merge_errors
(
self
.errors
,
FieldError
::
InvalidGenesisWasmGenerator
(
error
)
.into
(),
),
),
}
}
pub
fn
with_genesis_state_path
(
self
,
location
:
impl
TryInto
<
AssetLocation
>
)
->
Self
{
pub
fn
with_genesis_state_path
<
T
>
(
self
,
location
:
T
)
->
Self
where
T
:
TryInto
<
AssetLocation
>
,
T
::
Error
:
Error
+
'static
,
{
match
location
.try_into
()
{
Ok
(
location
)
=>
Self
::
transition
(
ParachainConfig
{
...
...
@@ -259,15 +282,21 @@ impl ParachainConfigBuilder<WithAtLeastOneCollator> {
},
self
.errors
,
),
Err
(
_
error
)
=>
Self
::
transition
(
Err
(
error
)
=>
Self
::
transition
(
self
.config
,
// merge_errors(self.errors, format!("genesis_state_path: {error}")),
merge_errors
(
self
.errors
,
format!
(
"genesis_state_path: "
)),
merge_errors
(
self
.errors
,
FieldError
::
InvalidGenesisStatePath
(
error
)
.into
(),
),
),
}
}
pub
fn
with_genesis_state_generator
(
self
,
command
:
impl
TryInto
<
Command
>
)
->
Self
{
pub
fn
with_genesis_state_generator
<
T
>
(
self
,
command
:
T
)
->
Self
where
T
:
TryInto
<
Command
>
,
T
::
Error
:
Error
+
'static
,
{
match
command
.try_into
()
{
Ok
(
command
)
=>
Self
::
transition
(
ParachainConfig
{
...
...
@@ -276,15 +305,21 @@ impl ParachainConfigBuilder<WithAtLeastOneCollator> {
},
self
.errors
,
),
Err
(
_
error
)
=>
Self
::
transition
(
Err
(
error
)
=>
Self
::
transition
(
self
.config
,
// merge_errors(self.errors, format!("genesis_state_generator: {error}")),
merge_errors
(
self
.errors
,
format!
(
"genesis_state_generator: "
)),
merge_errors
(
self
.errors
,
FieldError
::
InvalidGenesisStateGenerator
(
error
)
.into
(),
),
),
}
}
pub
fn
with_chain_spec_path
(
self
,
location
:
impl
TryInto
<
AssetLocation
>
)
->
Self
{
pub
fn
with_chain_spec_path
<
T
>
(
self
,
location
:
T
)
->
Self
where
T
:
TryInto
<
AssetLocation
>
,
T
::
Error
:
Error
+
'static
,
{
match
location
.try_into
()
{
Ok
(
location
)
=>
Self
::
transition
(
ParachainConfig
{
...
...
@@ -293,10 +328,9 @@ impl ParachainConfigBuilder<WithAtLeastOneCollator> {
},
self
.errors
,
),
Err
(
_
error
)
=>
Self
::
transition
(
Err
(
error
)
=>
Self
::
transition
(
self
.config
,
// merge_errors(self.errors, format!("chain_spec_path: {error}")),
merge_errors
(
self
.errors
,
format!
(
"chain_spec_path: "
)),
merge_errors
(
self
.errors
,
FieldError
::
InvalidChainSpecPath
(
error
)
.into
()),
),
}
}
...
...
@@ -311,17 +345,18 @@ impl ParachainConfigBuilder<WithAtLeastOneCollator> {
)
}
pub
fn
with_bootnodes_addresses
(
self
,
bootnodes_addresses
:
Vec
<
impl
TryInto
<
Multiaddr
>>
,
)
->
Self
{
pub
fn
with_bootnodes_addresses
<
T
>
(
self
,
bootnodes_addresses
:
Vec
<
T
>
)
->
Self
where
T
:
TryInto
<
Multiaddr
>
,
T
::
Error
:
Error
+
'static
,
{
let
mut
addrs
=
vec!
[];
let
mut
errors
=
vec!
[];
for
addr
in
bootnodes_addresses
{
for
(
index
,
addr
)
in
bootnodes_addresses
.into_iter
()
.enumerate
()
{
match
addr
.try_into
()
{
Ok
(
addr
)
=>
addrs
.push
(
addr
),
Err
(
error
)
=>
errors
.push
(
error
),
Err
(
error
)
=>
errors
.push
(
FieldError
::
InvalidBootnodesAddress
(
index
,
error
)
.into
()
),
}
}
...
...
@@ -330,7 +365,7 @@ impl ParachainConfigBuilder<WithAtLeastOneCollator> {
bootnodes_addresses
:
addrs
,
..
self
.config
},
self
.
errors
,
//
vec
![
self.errors, errors
].concat(
),
merge_
errors
_
vec
s
(
self
.errors
,
errors
),
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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