-
Notifications
You must be signed in to change notification settings - Fork 13
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
UTs for service functionalities #4
base: master
Are you sure you want to change the base?
Conversation
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.
Log crates might not need to be brought in scope again.
src/core/src/service.rs
Outdated
@@ -61,7 +127,6 @@ impl Poet2Service { | |||
} | |||
|
|||
pub fn get_block(&mut self, block_id: BlockId) -> Block { | |||
debug!("Getting block {:?}", block_id); |
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.
Why should this log be removed?
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.
The block_id's value is unknown as it's not holding any value,so it should be removed.
src/core/src/service.rs
Outdated
@@ -84,15 +149,13 @@ impl Poet2Service { | |||
sleep(time::Duration::from_secs(1)); | |||
summary = self.service.summarize_block(); | |||
} | |||
|
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.
Ensure no changes apart from the intended are made to the codebase.
src/core/src/service.rs
Outdated
use log::LogLevelFilter; | ||
use log4rs::append::console::ConsoleAppender; | ||
use log4rs::config::{Appender, Config, Root}; | ||
use log4rs::encode::pattern::PatternEncoder; |
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.
Are log crates needed to be brought in scope here ?
src/core/src/service.rs
Outdated
test_mock_str.insert(String::from("test_min"), String::from("10")); | ||
debug!("In Mocking get block"); | ||
let block_id_map = BlockId::from(vec![16,16,85,32]); | ||
let block_id_test = BlockId::from(vec![16,16,85,32]); |
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.
Does having repetitive block ids(16) here serve any purpose?
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.
I don't think so as it's a map so key should be unique.
src/core/src/service.rs
Outdated
if wt > min_time && wt < max_time{ | ||
assert_gt!(wt, min_time); | ||
assert_lt!(wt, max_time); | ||
debug!("wait_time is generated within the range {:?} and {:?}, {:?}",min_time, max_time, wt); |
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.
Need not have log here.
src/core/src/service.rs
Outdated
cal_time.get_settings.return_value(test_result); | ||
let mut svc = Poet2Service::new( Box::new(cal_time)); | ||
let mut wt = svc.calculate_wait_time(Default::default()).as_secs(); | ||
debug!("Wait time generated should be zero and wait_time is {:?}", wt); |
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.
Log not needed here. Assert might have an option to add some description.
src/core/src/service.rs
Outdated
@@ -323,7 +505,6 @@ mod tests { | |||
svc.broadcast(Default::default()); | |||
assert_eq!(2, 2); | |||
*/ |
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.
Remove this commented piece of code as well
src/core/src/service.rs
Outdated
cal_time.get_settings.return_value(test_result); | ||
let mut svc = Poet2Service::new( Box::new(cal_time)); | ||
let mut wt = svc.calculate_wait_time(Default::default()).as_secs(); | ||
assert_eq!(wt, 0); |
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.
Should this be 0 or some default value?
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.
Anything is fine.As default value is not declared in tests scope, made it to 0.
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.
Try having some other non-zero default value and then assert it.
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.
There are yet other comments you need to address. Also merge it into a single commit.
You still do not have a descriptive comment for your commit.
Signed-off-by: Vlakshmi <[email protected]> Made changes as suggested Signed-off-by: Vlakshmi <[email protected]> Fixed comments raised Signed-off-by: Vlakshmi <[email protected]> removed comments in the code Signed-off-by: Vlakshmi <[email protected]>
579bd23
to
3596c14
Compare
@@ -12,3 +12,5 @@ protobuf="2.0" | |||
zmq = { git = "https://github.com/erickt/rust-zmq", branch = "release/v0.8" } | |||
num = "*" | |||
clap = "~2.27.0" | |||
double = "0.2.2" |
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.
why do we need the double crate?
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.
double is the mocking library we are using here.
Signed-off-by: Vlakshmi [email protected]