client: fix decode block number as u32 (#3130)

* client: fix panic on decode block number as u32

* client: add test for number_index_key

* client: add another test at client level

* client: address review grumbles
This commit is contained in:
André Silva
2019-07-18 15:55:14 +01:00
committed by GitHub
parent e8a2fee6d6
commit 991e9ae263
4 changed files with 81 additions and 45 deletions
+10
View File
@@ -2633,4 +2633,14 @@ pub(crate) mod tests {
b3.hash(),
);
}
#[test]
fn get_header_by_block_number_doesnt_panic() {
let client = test_client::new();
// backend uses u32 for block numbers, make sure we don't panic when
// trying to convert
let id = BlockId::<Block>::Number(72340207214430721);
client.header(&id).expect_err("invalid block number overflows u32");
}
}