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
8d5924fb
Commit
8d5924fb
authored
1 day ago
by
Raymond Cheung
Browse files
Options
Downloads
Patches
Plain Diff
Add TestEventEmitter
parent
fb4a56c2
Branches
Branches containing commit
No related merge requests found
Pipeline
#519120
waiting for manual action with stages
in 34 minutes and 14 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
polkadot/xcm/xcm-runtime-apis/tests/mock.rs
+83
-2
83 additions, 2 deletions
polkadot/xcm/xcm-runtime-apis/tests/mock.rs
with
83 additions
and
2 deletions
polkadot/xcm/xcm-runtime-apis/tests/mock.rs
+
83
−
2
View file @
8d5924fb
...
...
@@ -40,7 +40,7 @@ use xcm_builder::{
MintLocation
,
NoChecking
,
TakeWeightCredit
,
};
use
xcm_executor
::{
traits
::{
ConvertLocation
,
JustTry
},
traits
::{
ConvertLocation
,
EventEmitter
,
JustTry
},
XcmExecutor
,
};
...
...
@@ -296,11 +296,92 @@ pub type Barrier = (
pub
type
Trader
=
FixedRateOfFungible
<
NativeTokenPerSecondPerByte
,
()
>
;
thread_local!
{
static
EMITTED_EVENTS
:
RefCell
<
Vec
<<
TestRuntime
as
frame_system
::
Config
>
::
RuntimeEvent
>>
=
RefCell
::
new
(
Vec
::
new
());
}
pub
struct
TestEventEmitter
{}
impl
TestEventEmitter
{
pub
fn
events
()
->
Vec
<<
TestRuntime
as
frame_system
::
Config
>
::
RuntimeEvent
>
{
EMITTED_EVENTS
.with
(|
events
|
events
.borrow
()
.clone
())
}
pub
fn
reset_events
()
{
EMITTED_EVENTS
.with
(|
events
|
events
.borrow_mut
()
.clear
());
}
}
impl
EventEmitter
for
TestEventEmitter
{
fn
emit_sent_event
(
origin
:
Location
,
destination
:
Location
,
message
:
Option
<
Xcm
<
()
>>
,
message_id
:
XcmHash
,
)
{
sp_tracing
::
tracing
::
trace!
(
target
:
"xcm::mock"
,
?
origin
,
?
destination
,
?
message
,
?
message_id
,
"EventEmitter::emit_sent_event =>"
);
XcmPallet
::
emit_sent_event
(
origin
,
destination
,
message
,
message_id
);
let
events
=
frame_system
::
Pallet
::
<
TestRuntime
>
::
events
();
if
let
Some
(
event
)
=
events
.last
()
{
EMITTED_EVENTS
.with
(|
q
|
q
.borrow_mut
()
.push
(
event
.event
.clone
()));
sp_tracing
::
tracing
::
trace!
(
target
:
"xcm::mock"
,
?
event
,
"EventEmitter::emit_sent_event <="
);
}
}
fn
emit_send_failure_event
(
origin
:
Location
,
destination
:
Location
,
error
:
SendError
,
message_id
:
XcmHash
,
)
{
sp_tracing
::
tracing
::
debug!
(
target
:
"xcm::mock"
,
?
origin
,
?
destination
,
?
error
,
?
message_id
,
"EventEmitter::emit_send_failure_event =>"
);
XcmPallet
::
emit_send_failure_event
(
origin
,
destination
,
error
,
message_id
);
let
events
=
frame_system
::
Pallet
::
<
TestRuntime
>
::
events
();
if
let
Some
(
event
)
=
events
.last
()
{
EMITTED_EVENTS
.with
(|
q
|
q
.borrow_mut
()
.push
(
event
.event
.clone
()));
sp_tracing
::
tracing
::
debug!
(
target
:
"xcm::mock"
,
?
event
,
"EventEmitter::emit_send_failure_event <="
);
}
}
fn
emit_process_failure_event
(
origin
:
Location
,
error
:
XcmError
,
message_id
:
XcmHash
)
{
sp_tracing
::
tracing
::
debug!
(
target
:
"xcm::mock"
,
?
origin
,
?
error
,
?
message_id
,
"EventEmitter::emit_process_failure_event =>"
);
XcmPallet
::
emit_process_failure_event
(
origin
,
error
,
message_id
);
let
events
=
frame_system
::
Pallet
::
<
TestRuntime
>
::
events
();
if
let
Some
(
event
)
=
events
.last
()
{
EMITTED_EVENTS
.with
(|
q
|
q
.borrow_mut
()
.push
(
event
.event
.clone
()));
sp_tracing
::
tracing
::
debug!
(
target
:
"xcm::mock"
,
?
event
,
"EventEmitter::emit_process_failure_event <="
);
}
}
}
pub
struct
XcmConfig
;
impl
xcm_executor
::
Config
for
XcmConfig
{
type
RuntimeCall
=
RuntimeCall
;
type
XcmSender
=
XcmRouter
;
type
XcmEventEmitter
=
XcmPallet
;
type
XcmEventEmitter
=
TestEventEmitter
;
type
AssetTransactor
=
AssetTransactors
;
type
OriginConverter
=
();
type
IsReserve
=
RelayTokenToAssetHub
;
...
...
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