-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add get_key_string method to RuntimeEvent #1107
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
mod modules; | ||
use modules::{first_test_module, second_test_module}; | ||
use modules::{first_test_module, second_test_module, third_test_module}; | ||
use sov_modules_api::default_context::DefaultContext; | ||
use sov_modules_api::macros::DefaultRuntime; | ||
use sov_modules_api::{ | ||
|
@@ -12,12 +12,35 @@ struct Runtime<C: Context> | |
{ | ||
pub first: first_test_module::FirstTestStruct<C>, | ||
pub second: second_test_module::SecondTestStruct<C>, | ||
pub third: third_test_module::ThirdTestStruct<C, u32>, | ||
} | ||
|
||
fn main() { | ||
// Check to see if the runtime events are getting initialized correctly | ||
let _event = RuntimeEvent::<DefaultContext>::first(first_test_module::Event::FirstModuleEnum1(10)); | ||
let _event = RuntimeEvent::<DefaultContext>::first(first_test_module::Event::FirstModuleEnum2); | ||
let _event = RuntimeEvent::<DefaultContext>::first(first_test_module::Event::FirstModuleEnum3(vec![1;3])); | ||
let _event = RuntimeEvent::<DefaultContext>::second(second_test_module::Event::SecondModuleEnum); | ||
{ | ||
let event = RuntimeEvent::<DefaultContext>::first(first_test_module::Event::FirstModuleEnum1(10)); | ||
assert_eq!(event.get_key_string(), "first-FirstModuleEnum1"); | ||
} | ||
|
||
{ | ||
let event = RuntimeEvent::<DefaultContext>::first(first_test_module::Event::FirstModuleEnum2); | ||
assert_eq!(event.get_key_string(), "first-FirstModuleEnum2"); | ||
} | ||
|
||
{ | ||
let event = RuntimeEvent::<DefaultContext>::first(first_test_module::Event::FirstModuleEnum3(vec![1; 3])); | ||
assert_eq!(event.get_key_string(), "first-FirstModuleEnum3"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To create the key string using the Now, let's consider a scenario where a user wishes to query the database using the |
||
} | ||
|
||
{ | ||
let event = RuntimeEvent::<DefaultContext>::second(second_test_module::Event::SecondModuleEnum); | ||
assert_eq!(event.get_key_string(), "second-SecondModuleEnum"); | ||
} | ||
|
||
{ | ||
// Not sure if this is how we'd want to keep this. But wanted to highlight this edge case. | ||
let event = RuntimeEvent::<DefaultContext>::third(()); | ||
assert_eq!(event.get_key_string(), "third-"); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this generate an expected string even if
Event
isstruct/tuple/array/nested enum
instead of an enum type?