From 34f0cbcf19fb8210d39afc164bd08a759d1c80d1 Mon Sep 17 00:00:00 2001 From: Gav Date: Thu, 15 Feb 2018 18:40:04 +0100 Subject: [PATCH] Fix tests. --- substrate/substrate/client/src/block_builder.rs | 8 ++------ substrate/substrate/rpc/src/state/tests.rs | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/substrate/substrate/client/src/block_builder.rs b/substrate/substrate/client/src/block_builder.rs index 8c2d0c0628..097dd670dc 100644 --- a/substrate/substrate/client/src/block_builder.rs +++ b/substrate/substrate/client/src/block_builder.rs @@ -21,7 +21,7 @@ use codec::{Joiner, Slicable}; use state_machine::{self, CodeExecutor}; use primitives::{Header, Block}; use primitives::block::Transaction; -use {backend, error, BlockId, BlockStatus, Client}; +use {backend, error, BlockId, Client}; use triehash::ordered_trie_root; /// Utility for building new (valid) blocks from a stream of transactions. @@ -44,11 +44,7 @@ impl BlockBuilder where { /// Create a new instance of builder from the given client, building on the latest block. pub fn new(client: &Client) -> error::Result { - let best = (client.info().map(|i| i.chain.best_number)?..1) - .find(|&n| if let Ok(BlockStatus::InChain) = client.block_status(&BlockId::Number(n)) - { true } else { false }) - .unwrap_or(0); - Self::at_block(&BlockId::Number(best), client) + client.info().and_then(|i| Self::at_block(&BlockId::Hash(i.chain.best_hash), client)) } /// Create a new instance of builder from the given client using a particular block's ID to diff --git a/substrate/substrate/rpc/src/state/tests.rs b/substrate/substrate/rpc/src/state/tests.rs index 469b794b05..9bae8b1cd5 100644 --- a/substrate/substrate/rpc/src/state/tests.rs +++ b/substrate/substrate/rpc/src/state/tests.rs @@ -35,7 +35,7 @@ fn should_return_storage() { assert_matches!( StateApi::storage(&client, StorageKey(vec![10]), genesis_hash), - Ok(ref x) if x.0.is_empty() + Err(Error(ErrorKind::Client(client::error::ErrorKind::NoValueForKey(ref k)), _)) if *k == vec![10] ) }