add tests

This commit is contained in:
Nicolas Ochem 2017-07-02 14:13:27 -07:00
parent e628885a00
commit c3172a71a1
1 changed files with 25 additions and 0 deletions

View File

@ -262,6 +262,10 @@ pub mod tests {
test_data::genesis().hash()
}
fn block_count(&self) -> u32 {
1
}
fn block_hash(&self, _height: u32) -> Option<GlobalH256> {
Some(test_data::genesis().hash())
}
@ -324,6 +328,10 @@ pub mod tests {
test_data::genesis().hash()
}
fn block_count(&self) -> u32 {
1
}
fn block_hash(&self, _height: u32) -> Option<GlobalH256> {
None
}
@ -364,6 +372,23 @@ pub mod tests {
assert_eq!(&sample, r#"{"jsonrpc":"2.0","result":"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f","id":1}"#);
}
#[test]
fn block_count_success() {
let client = BlockChainClient::new(SuccessBlockChainClientCore::default());
let mut handler = IoHandler::new();
handler.extend_with(client.to_delegate());
let sample = handler.handle_request_sync(&(r#"
{
"jsonrpc": "2.0",
"method": "getblockcount",
"params": [],
"id": 1
}"#)).unwrap();
assert_eq!(&sample, r#"{"jsonrpc":"2.0","result":1,"id":1}"#);
}
#[test]
fn block_hash_success() {
let client = BlockChainClient::new(SuccessBlockChainClientCore::default());