Skip to content

Commit

Permalink
fix: cargo check --all-targets works
Browse files Browse the repository at this point in the history
  • Loading branch information
kylezs committed Jan 6, 2023
1 parent ee54618 commit 110a17f
Show file tree
Hide file tree
Showing 42 changed files with 275 additions and 333 deletions.
19 changes: 10 additions & 9 deletions api/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ where
async fn connect_submit_and_get_events<Call>(
state_chain_settings: &settings::StateChain,
call: Call,
) -> Result<Vec<state_chain_runtime::Event>>
) -> Result<Vec<state_chain_runtime::RuntimeEvent>>
where
Call: Into<state_chain_runtime::Call> + Clone + std::fmt::Debug + Send + Sync + 'static,
Call: Into<state_chain_runtime::RuntimeCall> + Clone + std::fmt::Debug + Send + Sync + 'static,
{
task_scope(|scope| {
async {
Expand Down Expand Up @@ -516,13 +516,14 @@ pub async fn register_swap_intent(
)
.await?;

if let Some(state_chain_runtime::Event::Swapping(pallet_cf_swapping::Event::NewSwapIntent {
ingress_address,
..
})) = events.iter().find(|event| {
if let Some(state_chain_runtime::RuntimeEvent::Swapping(
pallet_cf_swapping::Event::NewSwapIntent { ingress_address, .. },
)) = events.iter().find(|event| {
matches!(
event,
state_chain_runtime::Event::Swapping(pallet_cf_swapping::Event::NewSwapIntent { .. })
state_chain_runtime::RuntimeEvent::Swapping(
pallet_cf_swapping::Event::NewSwapIntent { .. }
)
)
}) {
Ok(*ingress_address)
Expand All @@ -542,12 +543,12 @@ pub async fn liquidity_deposit(
)
.await?;

if let Some(state_chain_runtime::Event::LiquidityProvider(
if let Some(state_chain_runtime::RuntimeEvent::LiquidityProvider(
pallet_cf_lp::Event::DepositAddressReady { ingress_address, intent_id: _ },
)) = events.iter().find(|event| {
matches!(
event,
state_chain_runtime::Event::LiquidityProvider(
state_chain_runtime::RuntimeEvent::LiquidityProvider(
pallet_cf_lp::Event::DepositAddressReady { .. }
)
)
Expand Down
2 changes: 1 addition & 1 deletion engine/src/eth/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ mod tests {

use std::str::FromStr;

use sp_core::H160;
use web3::types::H160;

use crate::eth::{key_manager::KeyManager, EthContractWitnesser};

Expand Down
3 changes: 1 addition & 2 deletions engine/src/eth/http_safe_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ pub mod tests {

use futures::StreamExt;
use mockall::{predicate::eq, Sequence};
use sp_core::{H256, U256};
use web3::types::{Block, H2048};
use web3::types::{Block, H2048, H256, U256};

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion engine/src/eth/merged_block_items_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ mod merged_stream_tests {

use std::time::Duration;

use sp_core::U256;
use utilities::assert_future_panics;
use web3::types::U256;

use crate::{
eth::{
Expand Down
3 changes: 1 addition & 2 deletions engine/src/eth/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,7 @@ pub mod mocks {
use super::*;

use mockall::mock;
use sp_core::H256;
use web3::types::{Block, Bytes, Filter, Log};
// use web3::types::{Block, Bytes, Filter, Log, H256};

mock!(
// becomes MockEthHttpRpcClient
Expand Down
2 changes: 1 addition & 1 deletion engine/src/eth/ws_safe_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ where
#[cfg(test)]
pub mod tests {

use sp_core::{H160, H256, U256};
use web3::types::{H160, H256, U256};

use crate::logging::test_utils::new_test_logger;

Expand Down
1 change: 0 additions & 1 deletion engine/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use chainflip_node::chain_spec::use_chainflip_account_id_encoding;
use clap::Parser;
use futures::FutureExt;
use pallet_cf_validator::SemVer;
use sp_core::U256;

#[cfg(feature = "ibiza")]
use chainflip_engine::dot::{rpc::DotRpcClient, DotBroadcaster};
Expand Down
6 changes: 3 additions & 3 deletions engine/src/state_chain_observer/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,21 +278,21 @@ pub mod mocks {
logger: &slog::Logger,
) -> Result<H256>
where
Call: Into<state_chain_runtime::Call> + Clone + std::fmt::Debug + Send + Sync + 'static;
Call: Into<state_chain_runtime::RuntimeCall> + Clone + std::fmt::Debug + Send + Sync + 'static;

async fn submit_unsigned_extrinsic<Call>(
&self,
call: Call,
logger: &slog::Logger,
) -> Result<H256>
where
Call: Into<state_chain_runtime::Call> + Clone + std::fmt::Debug + Send + Sync + 'static;
Call: Into<state_chain_runtime::RuntimeCall> + Clone + std::fmt::Debug + Send + Sync + 'static;

async fn watch_submitted_extrinsic<BlockStream>(
&self,
extrinsic_hash: state_chain_runtime::Hash,
block_stream: &mut BlockStream,
) -> Result<Vec<state_chain_runtime::Event>>
) -> Result<Vec<state_chain_runtime::RuntimeEvent>>
where
BlockStream:
Stream<Item = state_chain_runtime::Header> + Unpin + Send + 'static;
Expand Down
45 changes: 24 additions & 21 deletions engine/src/state_chain_observer/sc_observer/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use pallet_cf_vaults::Vault;
#[cfg(feature = "ibiza")]
use cf_primitives::PolkadotAccountId;

use sp_core::{Hasher, H256, U256};
use sp_core::{Hasher, H256};
use sp_runtime::{traits::Keccak256, AccountId32, Digest};
use state_chain_runtime::{AccountId, CfeSettings, EthereumInstance, Header};
use tokio::sync::watch;
Expand Down Expand Up @@ -606,9 +606,9 @@ expect_storage_map_entry::<pallet_cf_validator::HistoricalActiveEpochs<state_cha
.return_once(move |_| {
Ok(vec![Box::new(frame_system::EventRecord {
phase: Phase::ApplyExtrinsic(0),
event: state_chain_runtime::Event::Validator(pallet_cf_validator::Event::NewEpoch(
new_epoch,
)),
event: state_chain_runtime::RuntimeEvent::Validator(
pallet_cf_validator::Event::NewEpoch(new_epoch),
),
topics: vec![H256::default()],
})])
});
Expand Down Expand Up @@ -820,9 +820,9 @@ expect_storage_map_entry::<pallet_cf_validator::HistoricalActiveEpochs<state_cha
.return_once(move |_| {
Ok(vec![Box::new(frame_system::EventRecord {
phase: Phase::ApplyExtrinsic(0),
event: state_chain_runtime::Event::Validator(pallet_cf_validator::Event::NewEpoch(
new_epoch,
)),
event: state_chain_runtime::RuntimeEvent::Validator(
pallet_cf_validator::Event::NewEpoch(new_epoch),
),
topics: vec![H256::default()],
})])
});
Expand Down Expand Up @@ -1035,9 +1035,9 @@ expect_storage_map_entry::<pallet_cf_validator::HistoricalActiveEpochs<state_cha
.return_once(move |_| {
Ok(vec![Box::new(frame_system::EventRecord {
phase: Phase::ApplyExtrinsic(0),
event: state_chain_runtime::Event::Validator(pallet_cf_validator::Event::NewEpoch(
new_epoch,
)),
event: state_chain_runtime::RuntimeEvent::Validator(
pallet_cf_validator::Event::NewEpoch(new_epoch),
),
topics: vec![H256::default()],
})])
});
Expand Down Expand Up @@ -1239,24 +1239,27 @@ async fn only_encodes_and_signs_when_specified() {

// when we are selected to sign we must estimate gas and sign
// NB: We only do this once, since we are only selected to sign once
eth_rpc_mock.expect_estimate_gas().once().returning(|_| Ok(U256::from(100_000)));
eth_rpc_mock
.expect_estimate_gas()
.once()
.returning(|_| Ok(web3::types::U256::from(100_000)));

eth_rpc_mock.expect_sign_transaction().once().return_once(|_, _| {
// just a nothing signed transaction
Ok(SignedTransaction {
message_hash: H256::default(),
message_hash: web3::types::H256::default(),
v: 1,
r: H256::default(),
s: H256::default(),
r: web3::types::H256::default(),
s: web3::types::H256::default(),
raw_transaction: Bytes(Vec::new()),
transaction_hash: H256::default(),
transaction_hash: web3::types::H256::default(),
})
});

eth_rpc_mock
.expect_send_raw_transaction()
.once()
.return_once(|tx| Ok(Keccak256::hash(&tx.0[..])));
.return_once(|tx| Ok(Keccak256::hash(&tx.0[..]).0.into()));

state_chain_client
.expect_storage_value::<frame_system::Events<state_chain_runtime::Runtime>>()
Expand All @@ -1266,7 +1269,7 @@ async fn only_encodes_and_signs_when_specified() {
Ok(vec![
Box::new(frame_system::EventRecord {
phase: Phase::ApplyExtrinsic(0),
event: state_chain_runtime::Event::EthereumBroadcaster(
event: state_chain_runtime::RuntimeEvent::EthereumBroadcaster(
pallet_cf_broadcast::Event::TransactionBroadcastRequest {
broadcast_attempt_id: BroadcastAttemptId::default(),
nominee: account_id,
Expand All @@ -1277,7 +1280,7 @@ async fn only_encodes_and_signs_when_specified() {
}),
Box::new(frame_system::EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: state_chain_runtime::Event::EthereumBroadcaster(
event: state_chain_runtime::RuntimeEvent::EthereumBroadcaster(
pallet_cf_broadcast::Event::TransactionBroadcastRequest {
broadcast_attempt_id: BroadcastAttemptId::default(),
nominee: AccountId32::new([1; 32]), // NOT OUR ACCOUNT ID
Expand Down Expand Up @@ -1362,7 +1365,7 @@ where
C: CryptoScheme + Send + Sync,
I: 'static + Send + Sync,
state_chain_runtime::Runtime: pallet_cf_threshold_signature::Config<I>,
state_chain_runtime::Call:
state_chain_runtime::RuntimeCall:
std::convert::From<pallet_cf_threshold_signature::Call<state_chain_runtime::Runtime, I>>,
<<state_chain_runtime::Runtime as pallet_cf_threshold_signature::Config<I>>::TargetChain as ChainCrypto>::ThresholdSignature: std::convert::From<<C as CryptoScheme>::Signature>,
{
Expand All @@ -1382,7 +1385,7 @@ where
state_chain_client.
expect_submit_signed_extrinsic::<pallet_cf_threshold_signature::Call<state_chain_runtime::Runtime,
I>>() .once()
.return_once(|_, _| Ok(H256::default()));
.return_once(|_, _| Ok(sp_core::H256::default()));
let state_chain_client = Arc::new(state_chain_client);

let mut multisig_client = MockMultisigClientApi::<C>::new();
Expand Down Expand Up @@ -1472,7 +1475,7 @@ where
C: CryptoScheme<AggKey = <<state_chain_runtime::Runtime as pallet_cf_vaults::Config<I>>::Chain as ChainCrypto>::AggKey> + Send + Sync,
I: 'static + Send + Sync,
state_chain_runtime::Runtime: pallet_cf_vaults::Config<I>,
state_chain_runtime::Call:
state_chain_runtime::RuntimeCall:
std::convert::From<pallet_cf_vaults::Call<state_chain_runtime::Runtime, I>>,
{
let logger = new_test_logger();
Expand Down
3 changes: 2 additions & 1 deletion state-chain/cf-integration-tests/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ fn account_deletion_removes_relevant_storage_items() {
assert!(MappedPeers::<Runtime>::contains_key(peer_id));

network::Cli::activate_account(&backup_node);
Reputation::heartbeat(state_chain_runtime::Origin::signed(backup_node.clone())).unwrap();
Reputation::heartbeat(state_chain_runtime::RuntimeOrigin::signed(backup_node.clone()))
.unwrap();
assert!(Reputations::<Runtime>::get(backup_node.clone()).online_credits > 0);

let elon_vanity_name = "ElonShibMoonInu";
Expand Down
5 changes: 3 additions & 2 deletions state-chain/cf-integration-tests/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ use pallet_transaction_payment::OnChargeTransaction;
// Governance is allowed to make free calls to governance gated extrinsics.
fn governance_members_pay_no_fees_for_governance_extrinsics() {
super::genesis::default().build().execute_with(|| {
let call: state_chain_runtime::Call = frame_system::Call::remark { remark: vec![] }.into();
let gov_call: state_chain_runtime::Call =
let call: state_chain_runtime::RuntimeCall =
frame_system::Call::remark { remark: vec![] }.into();
let gov_call: state_chain_runtime::RuntimeCall =
pallet_cf_governance::Call::approve { approved_id: 1 }.into();
// Expect a successful normal call to work
let ordinary = FlipTransactionPayment::<Runtime>::withdraw_fee(
Expand Down
4 changes: 2 additions & 2 deletions state-chain/cf-integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::crypto::{Pair, Public};
use sp_finality_grandpa::AuthorityId as GrandpaId;
use state_chain_runtime::{
constants::common::*, opaque::SessionKeys, AccountId, Emissions, Flip, Governance, Origin,
Reputation, Runtime, Staking, System, Timestamp, Validator, Witnesser,
constants::common::*, opaque::SessionKeys, AccountId, Emissions, Flip, Governance, Reputation,
Runtime, RuntimeOrigin, Staking, System, Timestamp, Validator, Witnesser,
};

use cf_primitives::{AuthorityCount, BlockNumber, EpochIndex, FlipBalance};
Expand Down
Loading

0 comments on commit 110a17f

Please sign in to comment.