Skip to content

Commit

Permalink
Update toolchain to fix codecov and fuzz errors (#1269)
Browse files Browse the repository at this point in the history
* Update toolchain

* Fix formatting and linter errors

* Update copyright notices

* Fix copyright notice
  • Loading branch information
maltekliemann authored Feb 29, 2024
1 parent 40b3c02 commit ff3b5f1
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 51 deletions.
4 changes: 2 additions & 2 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Forecasting Technologies LTD.
// Copyright 2023-2024 Forecasting Technologies LTD.
// Copyright 2021-2022 Zeitgeist PM LLC.
// Copyright 2017-2020 Parity Technologies (UK) Ltd.
//
Expand Down Expand Up @@ -38,8 +38,8 @@ use sp_runtime::{
};
use sp_storage::{ChildInfo, StorageData, StorageKey};
use std::sync::Arc;
pub use zeitgeist_primitives::types::{AccountId, Balance, BlockNumber, Hash, Index};
use zeitgeist_primitives::types::{Block, Header};
pub use zeitgeist_primitives::types::{BlockNumber, Hash};
#[cfg(feature = "with-battery-station-runtime")]
use {
super::service::BatteryStationExecutor,
Expand Down
6 changes: 2 additions & 4 deletions node/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 Forecasting Technologies LTD.
// Copyright 2022-2024 Forecasting Technologies LTD.
// Copyright 2021-2022 Zeitgeist PM LLC.
//
// This file is part of Zeitgeist.
Expand Down Expand Up @@ -30,9 +30,7 @@ use sc_service::{
error::Error as ServiceError, ChainSpec, Configuration, PartialComponents, TaskManager,
};
#[cfg(feature = "parachain")]
pub use service_parachain::{
new_full, new_partial, FullBackend, FullClient, ParachainPartialComponents,
};
pub use service_parachain::{new_full, new_partial, FullBackend, FullClient};
#[cfg(not(feature = "parachain"))]
pub use service_standalone::{new_full, new_partial, FullBackend, FullClient};
use sp_api::ConstructRuntimeApi;
Expand Down
44 changes: 22 additions & 22 deletions primitives/src/math/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,28 @@ mod tests {

pub(crate) const _1_10: u128 = _1 / 10;

#[macro_export]
macro_rules! assert_approx {
($left:expr, $right:expr, $precision:expr $(,)?) => {
match (&$left, &$right, &$precision) {
(left_val, right_val, precision_val) => {
let diff = if *left_val > *right_val {
*left_val - *right_val
} else {
*right_val - *left_val
};
if diff > *precision_val {
panic!(
"assertion `left approx== right` failed\n left: {}\n right: \
{}\n precision: {}\ndifference: {}",
*left_val, *right_val, *precision_val, diff
);
}
}
}
};
}

#[test_case(0, 0, 0)]
#[test_case(0, _1, 0)]
#[test_case(0, _2, 0)]
Expand Down Expand Up @@ -1075,25 +1097,3 @@ mod tests {
assert_approx!(result, expected, 1);
}
}

#[macro_export]
macro_rules! assert_approx {
($left:expr, $right:expr, $precision:expr $(,)?) => {
match (&$left, &$right, &$precision) {
(left_val, right_val, precision_val) => {
let diff = if *left_val > *right_val {
*left_val - *right_val
} else {
*right_val - *left_val
};
if diff > *precision_val {
panic!(
"assertion `left approx== right` failed\n left: {}\n right: {}\n \
precision: {}\ndifference: {}",
*left_val, *right_val, *precision_val, diff
);
}
}
}
};
}
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "nightly-2023-08-23"
channel = "nightly-2024-01-31"
components = ["clippy", "rustfmt", "llvm-tools-preview"]
profile = "minimal"
targets = ["wasm32-unknown-unknown"]
4 changes: 2 additions & 2 deletions zrml/authorized/src/mock_storage.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Copyright 2023 Forecasting Technologies LTD.
// Copyright 2022 Forecasting Technologies LTD.
// Copyright 2022-2024 Forecasting Technologies LTD.
//
// This file is part of Zeitgeist.
//
Expand All @@ -18,6 +17,7 @@

#![cfg(test)]
#![allow(dead_code)]
#![allow(unused_imports)]

#[frame_support::pallet]
pub(crate) mod pallet {
Expand Down
2 changes: 1 addition & 1 deletion zrml/court/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,7 @@ mod pallet {
remainder
);

T::Currency::burn(remainder);
let _ = T::Currency::burn(remainder);
}

T::WeightInfo::handle_inflation(pool_len)
Expand Down
3 changes: 2 additions & 1 deletion zrml/court/src/mock_storage.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Forecasting Technologies LTD.
// Copyright 2023-2024 Forecasting Technologies LTD.
//
// This file is part of Zeitgeist.
//
Expand All @@ -17,6 +17,7 @@

#![cfg(test)]
#![allow(dead_code)]
#![allow(unused_imports)]

pub use pallet::*;
use parity_scale_codec::Encode;
Expand Down
2 changes: 1 addition & 1 deletion zrml/court/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@ fn appeal_emits_event() {

let court = Courts::<Runtime>::get(court_id).unwrap();
let new_round_ends = Some(court.round_ends);
let appeal_info = court.appeals.get(0).unwrap().clone();
let appeal_info = court.appeals.first().unwrap().clone();

System::assert_last_event(
Event::CourtAppealed { court_id, appeal_info, new_round_ends }.into(),
Expand Down
14 changes: 7 additions & 7 deletions zrml/global-disputes/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 Forecasting Technologies LTD.
// Copyright 2022-2024 Forecasting Technologies LTD.
//
// This file is part of Zeitgeist.
//
Expand Down Expand Up @@ -241,7 +241,7 @@ fn start_global_dispute_fails_if_max_owner_reached() {
ExtBuilder::default().build().execute_with(|| {
let market_id = 0u128;
let market = market_mock::<Runtime>();
Markets::<Runtime>::insert(market_id, &market);
Markets::<Runtime>::insert(market_id, market);

let mut initial_items = Vec::new();
initial_items.push(InitialItem {
Expand Down Expand Up @@ -269,7 +269,7 @@ fn start_global_dispute_fails_if_shared_possession_required() {
ExtBuilder::default().build().execute_with(|| {
let market_id = 0u128;
let market = market_mock::<Runtime>();
Markets::<Runtime>::insert(market_id, &market);
Markets::<Runtime>::insert(market_id, market);

let outcome_info = OutcomeInfo {
outcome_sum: SETUP_AMOUNT,
Expand Down Expand Up @@ -303,7 +303,7 @@ fn start_global_dispute_adds_owners_for_existing_outcome() {
ExtBuilder::default().build().execute_with(|| {
let market_id = 0u128;
let market = market_mock::<Runtime>();
Markets::<Runtime>::insert(market_id, &market);
Markets::<Runtime>::insert(market_id, market);

let mut initial_items = Vec::new();
initial_items.push(InitialItem {
Expand Down Expand Up @@ -334,7 +334,7 @@ fn start_global_dispute_updates_to_highest_winner() {
ExtBuilder::default().build().execute_with(|| {
let market_id = 0u128;
let market = market_mock::<Runtime>();
Markets::<Runtime>::insert(market_id, &market);
Markets::<Runtime>::insert(market_id, market);

let mut initial_items = Vec::new();
initial_items.push(InitialItem {
Expand Down Expand Up @@ -1153,7 +1153,7 @@ fn purge_outcomes_partially_cleaned_works() {
ExtBuilder::default().build().execute_with(|| {
let market_id = 0u128;
let market = market_mock::<Runtime>();
Markets::<Runtime>::insert(market_id, &market);
Markets::<Runtime>::insert(market_id, market);

let mut initial_items = Vec::new();
for i in 0..(2 * RemoveKeysLimit::get()) {
Expand Down Expand Up @@ -1187,7 +1187,7 @@ fn refund_vote_fees_works() {
ExtBuilder::default().build().execute_with(|| {
let market_id = 0u128;
let market = market_mock::<Runtime>();
Markets::<Runtime>::insert(market_id, &market);
Markets::<Runtime>::insert(market_id, market);

let pushed_outcome_1 = 0;
let pushed_outcome_2 = 20;
Expand Down
7 changes: 5 additions & 2 deletions zrml/liquidity-mining/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 Forecasting Technologies LTD.
// Copyright 2022-2024 Forecasting Technologies LTD.
// Copyright 2021-2022 Zeitgeist PM LLC.
//
// This file is part of Zeitgeist.
Expand Down Expand Up @@ -145,7 +145,10 @@ mod pallet {
#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
fn build(&self) {
T::Currency::deposit_creating(&Pallet::<T>::pallet_account_id(), self.initial_balance);
let _ = T::Currency::deposit_creating(
&Pallet::<T>::pallet_account_id(),
self.initial_balance,
);
<PerBlockIncentive<T>>::put(self.per_block_distribution);
}
}
Expand Down
4 changes: 2 additions & 2 deletions zrml/prediction-markets/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ pub struct DeployPoolArgs {
}

thread_local! {
pub static DEPLOY_POOL_CALL_DATA: RefCell<Vec<DeployPoolArgs>> = RefCell::new(vec![]);
pub static DEPLOY_POOL_RETURN_VALUE: RefCell<DispatchResult> = RefCell::new(Ok(()));
pub static DEPLOY_POOL_CALL_DATA: RefCell<Vec<DeployPoolArgs>> = const { RefCell::new(vec![]) };
pub static DEPLOY_POOL_RETURN_VALUE: RefCell<DispatchResult> = const { RefCell::new(Ok(())) };
}

#[allow(unused)]
Expand Down
5 changes: 4 additions & 1 deletion zrml/rikiddo/src/tests/rikiddo_sigmoid_mv/cost.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2021-2022 Zeitgeist PM LLC.
// Copyright 2024 Forecasting Technologies LTD.
// Copyright 2021-2022, 2024 Zeitgeist PM LLC.
//
// This file is part of Zeitgeist.
//
Expand All @@ -15,6 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>.

#![allow(clippy::useless_vec)]

use frame_support::assert_err;
use hashbrown::HashMap;
use substrate_fixed::{traits::ToFixed, types::extra::U64, FixedI128, FixedU128};
Expand Down
5 changes: 4 additions & 1 deletion zrml/rikiddo/src/tests/rikiddo_sigmoid_mv/misc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2021-2022 Zeitgeist PM LLC.
// Copyright 2024 Forecasting Technologies LTD.
// Copyright 2021-2022, 2024 Zeitgeist PM LLC.
//
// This file is part of Zeitgeist.
//
Expand All @@ -15,6 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>.

#![allow(clippy::useless_vec)]

use frame_support::assert_err;
use substrate_fixed::{traits::ToFixed, types::extra::U64, FixedI128};

Expand Down
4 changes: 3 additions & 1 deletion zrml/rikiddo/src/tests/rikiddo_sigmoid_mv/price.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 Forecasting Technologies LTD.
// Copyright 2022-2024 Forecasting Technologies LTD.
// Copyright 2021-2022 Zeitgeist PM LLC.
//
// This file is part of Zeitgeist.
Expand All @@ -17,6 +17,8 @@
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>.

#![allow(clippy::needless_late_init)]
#![allow(clippy::useless_vec)]

use frame_support::assert_err;
use substrate_fixed::{traits::ToFixed, types::extra::U64, FixedI128, FixedU128};

Expand Down
6 changes: 3 additions & 3 deletions zrml/styx/src/benchmarks.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Forecasting Technologies LTD.
// Copyright 2023-2024 Forecasting Technologies LTD.
// Copyright 2021-2022 Zeitgeist PM LLC.
//
// This file is part of Zeitgeist.
Expand Down Expand Up @@ -40,15 +40,15 @@ benchmarks! {
cross {
let caller: T::AccountId = whitelisted_caller();
let balance = (90_000_000 * BASE).saturated_into();
T::Currency::deposit_creating(&caller, balance);
let _ = T::Currency::deposit_creating(&caller, balance);
}: _(RawOrigin::Signed(caller))

set_burn_amount {
let origin = T::SetBurnAmountOrigin::try_successful_origin().unwrap();
let caller: T::AccountId = whitelisted_caller();
let balance = (10_000 * BASE).saturated_into();
let amount = (20 * BASE).saturated_into();
T::Currency::deposit_creating(&caller, balance);
let _ = T::Currency::deposit_creating(&caller, balance);
let call = Call::<T>::set_burn_amount { amount };
}: { call.dispatch_bypass_filter(origin)? }

Expand Down

0 comments on commit ff3b5f1

Please sign in to comment.