Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-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
polkadot-sdk
Commits
59b36b43
Commit
59b36b43
authored
2 years ago
by
Branislav Kontur
Committed by
Bastian Köcher
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Utility to generate hex bytes for send-message command (#1658)
parent
9da22df1
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bridges/primitives/test-utils/Cargo.toml
+3
-0
3 additions, 0 deletions
bridges/primitives/test-utils/Cargo.toml
bridges/primitives/test-utils/src/lib.rs
+44
-0
44 additions, 0 deletions
bridges/primitives/test-utils/src/lib.rs
with
47 additions
and
0 deletions
bridges/primitives/test-utils/Cargo.toml
+
3
−
0
View file @
59b36b43
...
...
@@ -15,6 +15,9 @@ sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch
sp-runtime
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
,
default-features
=
false
}
sp-std
=
{
git
=
"https://github.com/paritytech/substrate"
,
branch
=
"master"
,
default-features
=
false
}
[dev-dependencies]
xcm
=
{
git
=
"https://github.com/paritytech/polkadot"
,
branch
=
"master"
,
default-features
=
false
}
[features]
default
=
[
"std"
]
std
=
[
...
...
This diff is collapsed.
Click to expand it.
bridges/primitives/test-utils/src/lib.rs
+
44
−
0
View file @
59b36b43
...
...
@@ -299,3 +299,47 @@ macro_rules! generate_owned_bridge_module_tests {
}
};
}
#[cfg(test)]
mod
tests
{
use
codec
::
Encode
;
use
sp_application_crypto
::
sp_core
::{
hexdisplay
,
hexdisplay
::
HexDisplay
};
use
xcm
::
VersionedXcm
;
fn
print_xcm
<
RuntimeCall
>
(
xcm
:
&
VersionedXcm
<
RuntimeCall
>
)
{
println!
(
"-----------------"
);
println!
(
"xcm (plain): {:?}"
,
xcm
);
println!
(
"xcm (bytes): {:?}"
,
xcm
.encode
());
println!
(
"xcm (hex): {:?}"
,
hexdisplay
::
HexDisplay
::
from
(
&
xcm
.encode
()));
}
fn
as_hex
<
RuntimeCall
>
(
xcm
:
&
VersionedXcm
<
RuntimeCall
>
)
->
String
{
HexDisplay
::
from
(
&
xcm
.encode
())
.to_string
()
}
pub
type
RuntimeCall
=
();
#[test]
fn
generate_versioned_xcm_message_hex_bytes
()
{
let
xcm
:
xcm
::
v2
::
Xcm
<
RuntimeCall
>
=
xcm
::
v2
::
Xcm
(
vec!
[
xcm
::
v2
::
Instruction
::
Trap
(
43
)]);
let
xcm
:
VersionedXcm
<
RuntimeCall
>
=
From
::
from
(
xcm
);
print_xcm
(
&
xcm
);
assert_eq!
(
"020419ac"
,
format!
(
"{}"
,
as_hex
(
&
xcm
)));
let
xcm
:
xcm
::
v3
::
Xcm
<
RuntimeCall
>
=
vec!
[
xcm
::
v3
::
Instruction
::
Trap
(
43
)]
.into
();
let
xcm
:
VersionedXcm
<
RuntimeCall
>
=
From
::
from
(
xcm
);
print_xcm
(
&
xcm
);
assert_eq!
(
"030419ac"
,
format!
(
"{}"
,
as_hex
(
&
xcm
)));
let
xcm
:
xcm
::
v3
::
Xcm
<
RuntimeCall
>
=
vec!
[
xcm
::
v3
::
Instruction
::
ClearError
,
xcm
::
v3
::
Instruction
::
ClearTopic
,
xcm
::
v3
::
Instruction
::
ClearTransactStatus
,
xcm
::
v3
::
Instruction
::
Trap
(
43
),
]
.into
();
let
xcm
:
VersionedXcm
<
RuntimeCall
>
=
From
::
from
(
xcm
);
print_xcm
(
&
xcm
);
assert_eq!
(
"0310172c2319ac"
,
format!
(
"{}"
,
as_hex
(
&
xcm
)));
}
}
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