fix digest in check_execution_proof (#3469)

This commit is contained in:
Svyatoslav Nikolsky
2019-08-24 18:42:57 +03:00
committed by Gavin Wood
parent a528b7dc56
commit e9273329ae
2 changed files with 20 additions and 13 deletions
@@ -471,7 +471,7 @@ pub fn check_execution_proof<Header, E, H>(
Default::default(),
Default::default(),
request.header.hash(),
request.header.digest().clone(),
Default::default(),
);
execution_proof_check_on_trie_backend::<H, _>(
&trie_backend,
@@ -498,7 +498,7 @@ pub fn check_execution_proof<Header, E, H>(
#[cfg(test)]
mod tests {
use consensus::BlockOrigin;
use test_client::{self, runtime::Header, ClientExt, TestClient};
use test_client::{self, runtime::{Header, Digest}, ClientExt, TestClient};
use executor::NativeExecutor;
use crate::backend::{Backend, NewBlockState};
use crate::in_mem::Backend as InMemBackend;
@@ -509,8 +509,7 @@ mod tests {
fn execution_proof_is_generated_and_checked() {
fn execute(remote_client: &TestClient, at: u64, method: &'static str) -> (Vec<u8>, Vec<u8>) {
let remote_block_id = BlockId::Number(at);
let remote_root = remote_client.state_at(&remote_block_id)
.unwrap().storage_root(::std::iter::empty()).0;
let remote_header = remote_client.header(&remote_block_id).unwrap().unwrap();
// 'fetch' execution proof from remote node
let (remote_result, remote_execution_proof) = remote_client.execution_proof(
@@ -523,13 +522,7 @@ mod tests {
let local_executor = NativeExecutor::<test_client::LocalExecutor>::new(None);
let local_result = check_execution_proof(&local_executor, &RemoteCallRequest {
block: test_client::runtime::Hash::default(),
header: test_client::runtime::Header {
state_root: remote_root.into(),
parent_hash: Default::default(),
number: at,
extrinsics_root: Default::default(),
digest: Default::default(),
},
header: remote_header,
method: method.into(),
call_data: vec![],
retry_count: None,
@@ -540,10 +533,12 @@ mod tests {
// prepare remote client
let remote_client = test_client::new();
for _ in 1..3 {
for i in 1u32..3u32 {
let mut digest = Digest::default();
digest.push(sr_primitives::generic::DigestItem::Other::<H256>(i.to_le_bytes().to_vec()));
remote_client.import_justified(
BlockOrigin::Own,
remote_client.new_block(Default::default()).unwrap().bake().unwrap(),
remote_client.new_block(digest).unwrap().bake().unwrap(),
Default::default(),
).unwrap();
}