Skip to content

Commit

Permalink
fix bitacross indirect-calls-executor tests (#2827)
Browse files Browse the repository at this point in the history
  • Loading branch information
kziemianek committed Jun 18, 2024
1 parent f2359af commit 4238dee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ mod test {
TestStfEnclaveSigner,
TestTopPoolAuthor,
TestNodeMetadataRepository,
MockExtrinsicFilter<MockParentchainExtrinsicParser>,
TestEventCreator,
MockParentchainEventHandler,
TrustedCallSignedMock,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
error::{Error, Result as ICResult},
filter_metadata::{EventsFromMetadata, FilterIntoDataFrom},
filter_metadata::EventsFromMetadata,
IndirectDispatch,
};
use bc_relayer_registry::RelayerRegistry;
Expand All @@ -10,10 +10,7 @@ use core::marker::PhantomData;
use litentry_primitives::DecryptableRequest;

use bc_enclave_registry::EnclaveRegistry;
use itp_node_api::{
api_client::{CallIndex, PairSignature, UncheckedExtrinsicV4},
metadata::NodeMetadataTrait,
};
use itp_node_api::api_client::{CallIndex, PairSignature, UncheckedExtrinsicV4};
use itp_sgx_runtime_primitives::types::{AccountId, Balance};
use itp_stf_primitives::{traits::IndirectExecutor, types::Signature};
use itp_test::mock::stf_mock::{GetterMock, TrustedCallMock, TrustedCallSignedMock};
Expand All @@ -27,52 +24,6 @@ use itp_types::{
use log::*;
use std::vec::Vec;

/// Default filter we use for the Integritee-Parachain.
pub struct MockExtrinsicFilter<ExtrinsicParser> {
_phantom: PhantomData<ExtrinsicParser>,
}

impl<ExtrinsicParser, NodeMetadata: NodeMetadataTrait> FilterIntoDataFrom<NodeMetadata>
for MockExtrinsicFilter<ExtrinsicParser>
where
ExtrinsicParser: ParseExtrinsic,
{
type Output = IndirectCall;
type ParseParentchainMetadata = ExtrinsicParser;

fn filter_into_from_metadata(
encoded_data: &[u8],
metadata: &NodeMetadata,
) -> Option<Self::Output> {
let call_mut = &mut &encoded_data[..];

// Todo: the filter should not need to parse, only filter. This should directly be configured
// in the indirect executor.
let xt = match Self::ParseParentchainMetadata::parse(call_mut) {
Ok(xt) => xt,
Err(e) => {
log::error!(
"[ShieldFundsAndInvokeFilter] Could not parse parentchain extrinsic: {:?}",
e
);
return None
},
};
let index = xt.call_index;
let call_args = &mut &xt.call_args[..];
log::trace!(
"[ShieldFundsAndInvokeFilter] attempting to execute indirect call with index {:?}",
index
);
if index == metadata.post_opaque_task_call_indexes().ok()? {
log::debug!("executing invoke call");
let args = InvokeArgs::decode(call_args).unwrap();
Some(IndirectCall::Invoke(args))
} else {
None
}
}
}
pub struct ExtrinsicParser<SignedExtra> {
_phantom: PhantomData<SignedExtra>,
}
Expand Down

0 comments on commit 4238dee

Please sign in to comment.