mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 14:31:02 +00:00
Get substrate dependencies from crates io (#387)
* get Substrate dependencies from crates.io * removing unused dependencies * cargo fmt --all * remove commented dependencies * remove commented dependencies again * try to fix compilation
This commit is contained in:
committed by
Bastian Köcher
parent
f43e405b5e
commit
07a514e9f7
@@ -175,75 +175,3 @@ fn unwrap_or_best<Block: BlockT>(backend: &impl BackendT<Block>, block: Option<B
|
||||
fn blockchain_err(err: BlockchainError) -> Error {
|
||||
Error::Client(Box::new(err))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use sp_core::Blake2Hasher;
|
||||
use sp_runtime::{codec::Decode, traits::Header as HeaderT};
|
||||
use substrate_test_runtime_client::{
|
||||
runtime::Block, Backend, DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt,
|
||||
};
|
||||
|
||||
const TEST_INSTANCE: InstanceId = [0, 0, 0, 1];
|
||||
const TEST_LANE: LaneId = [0, 0, 0, 1];
|
||||
|
||||
fn test_key() -> StorageKey {
|
||||
StorageKey(sp_core::storage::well_known_keys::CODE.to_vec())
|
||||
}
|
||||
|
||||
struct TestRuntimeAdapter;
|
||||
|
||||
impl Runtime for TestRuntimeAdapter {
|
||||
fn message_key(&self, instance: &InstanceId, _lane: &LaneId, _nonce: MessageNonce) -> Option<StorageKey> {
|
||||
if *instance == TEST_INSTANCE {
|
||||
Some(test_key())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn inbound_lane_data_key(&self, instance: &InstanceId, _lane: &LaneId) -> Option<StorageKey> {
|
||||
if *instance == TEST_INSTANCE {
|
||||
Some(test_key())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn test_handler() -> MessageLaneRpcHandler<Block, Backend, TestRuntimeAdapter> {
|
||||
let builder = TestClientBuilder::new();
|
||||
let (_, backend) = builder.build_with_backend();
|
||||
|
||||
MessageLaneRpcHandler::new(backend, Arc::new(TestRuntimeAdapter))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn storage_proof_is_actually_generated() {
|
||||
// the only thing we actually care here is that RPC actually generates storage proof
|
||||
// that can be verified from runtime
|
||||
|
||||
// proof is generated by RPC
|
||||
let handler = test_handler();
|
||||
let proof = handler
|
||||
.prove_messages(TEST_INSTANCE, TEST_LANE, 1, 3, None)
|
||||
.wait()
|
||||
.unwrap();
|
||||
|
||||
// proof is then relayed + checked by runtime (sp_trie supports no_std)
|
||||
// (storage root is known to underlying bridge pallet)
|
||||
let root = *handler
|
||||
.backend
|
||||
.blockchain()
|
||||
.header(BlockId::Number(0))
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.state_root();
|
||||
let proof = StorageProof::new(Decode::decode(&mut &proof[..]).unwrap());
|
||||
let trie_db = proof.into_memory_db::<Blake2Hasher>();
|
||||
let checked_storage_value =
|
||||
sp_trie::read_trie_value::<sp_trie::Layout<_>, _>(&trie_db, &root, &test_key().0).unwrap();
|
||||
assert!(checked_storage_value.is_some());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user