add tests
This commit is contained in:
parent
e628885a00
commit
c3172a71a1
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue