Skip to content

Commit

Permalink
Fix existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JuaniRios committed Aug 5, 2024
1 parent f3ce8f0 commit 706a0c4
Show file tree
Hide file tree
Showing 36 changed files with 9,587 additions and 12,165 deletions.
12 changes: 6 additions & 6 deletions integration-tests/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,9 @@ pub mod polimec {
#[allow(unused)]
pub fn set_prices() {
PolimecNet::execute_with(|| {
let dot = (AcceptedFundingAsset::DOT.to_assethub_id(), FixedU128::from_rational(69, 1));
let usdc = (AcceptedFundingAsset::USDC.to_assethub_id(), FixedU128::from_rational(1, 1));
let usdt = (AcceptedFundingAsset::USDT.to_assethub_id(), FixedU128::from_rational(1, 1));
let dot = (AcceptedFundingAsset::DOT.id(), FixedU128::from_rational(69, 1));
let usdc = (AcceptedFundingAsset::USDC.id(), FixedU128::from_rational(1, 1));
let usdt = (AcceptedFundingAsset::USDT.id(), FixedU128::from_rational(1, 1));
let plmc = (pallet_funding::PLMC_FOREIGN_ID, FixedU128::from_rational(840, 100));

let values: BoundedVec<(u32, FixedU128), <PolimecRuntime as orml_oracle::Config>::MaxFeedValues> =
Expand Down Expand Up @@ -424,9 +424,9 @@ pub mod polimec {
}

pub fn genesis() -> Storage {
let dot_asset_id = AcceptedFundingAsset::DOT.to_assethub_id();
let usdt_asset_id = AcceptedFundingAsset::USDT.to_assethub_id();
let usdc_asset_id = AcceptedFundingAsset::USDC.to_assethub_id();
let dot_asset_id = AcceptedFundingAsset::DOT.id();
let usdt_asset_id = AcceptedFundingAsset::USDT.id();
let usdc_asset_id = AcceptedFundingAsset::USDC.id();
let mut funded_accounts = vec![
(
PolimecNet::sovereign_account_id_of((Parent, xcm::prelude::Parachain(penpal::PARA_ID)).into()),
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/src/tests/ct_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ fn create_settled_project() -> (ProjectId, Vec<AccountId>) {
default_community_contributions(),
default_remainder_contributions(),
);
inst.advance_time(<PolimecRuntime as pallet_funding::Config>::SuccessToSettlementTime::get()).unwrap();
inst.advance_time(<PolimecRuntime as pallet_funding::Config>::SuccessToSettlementTime::get());
let mut participants: Vec<AccountId> =
pallet_funding::Evaluations::<PolimecRuntime>::iter_prefix_values((project_id,))
.map(|eval| eval.evaluator)
Expand Down Expand Up @@ -229,7 +229,7 @@ fn create_project_with_unsettled_participation(participation_type: Participation
default_remainder_contributions(),
);

inst.advance_time(<PolimecRuntime as pallet_funding::Config>::SuccessToSettlementTime::get()).unwrap();
inst.advance_time(<PolimecRuntime as pallet_funding::Config>::SuccessToSettlementTime::get());
let evaluations_to_settle =
pallet_funding::Evaluations::<PolimecRuntime>::iter_prefix_values((project_id,)).collect_vec();
let bids_to_settle = pallet_funding::Bids::<PolimecRuntime>::iter_prefix_values((project_id,)).collect_vec();
Expand Down
18 changes: 8 additions & 10 deletions integration-tests/src/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,8 @@ fn remainder_round_completed() {
let total_stored =
contributions.into_iter().fold(0, |acc, contribution| acc + contribution.funding_asset_amount);

let usdt_decimals = <PolimecRuntime as pallet_funding::Config>::FundingCurrency::decimals(
AcceptedFundingAsset::USDT.to_assethub_id(),
);
let usdt_decimals =
<PolimecRuntime as pallet_funding::Config>::FundingCurrency::decimals(AcceptedFundingAsset::USDT.id());
let usdt_total_from_excel_f64 = 503_945.4_517_000_000f64;
let usdt_total_from_excel_fixed = FixedU128::from_float(usdt_total_from_excel_f64);
let usdt_total_from_excel = usdt_total_from_excel_fixed.saturating_mul_int(10u128.pow(usdt_decimals as u32));
Expand Down Expand Up @@ -405,12 +404,11 @@ fn funds_raised() {
inst.execute(|| {
let project_specific_account: AccountId = PolimecFunding::fund_account_id(project_id);
let stored_usdt_funded =
PolimecForeignAssets::balance(AcceptedFundingAsset::USDT.to_assethub_id(), project_specific_account);
PolimecForeignAssets::balance(AcceptedFundingAsset::USDT.id(), project_specific_account);
let excel_usdt_funded_f64 = 1_004_256.0_140_000_000f64;
let excet_usdt_funding_fixed = FixedU128::from_float(excel_usdt_funded_f64);
let usdt_decimals = <PolimecRuntime as pallet_funding::Config>::FundingCurrency::decimals(
AcceptedFundingAsset::USDT.to_assethub_id(),
);
let usdt_decimals =
<PolimecRuntime as pallet_funding::Config>::FundingCurrency::decimals(AcceptedFundingAsset::USDT.id());
let excel_usdt_funded = excet_usdt_funding_fixed.saturating_mul_int(10u128.pow(usdt_decimals as u32));
assert_close_enough!(stored_usdt_funded, excel_usdt_funded, Perquintill::from_float(0.99));
})
Expand All @@ -433,7 +431,7 @@ fn ct_minted() {
excel_contributions(),
excel_remainders(),
);
inst.advance_time(<PolimecRuntime as Config>::SuccessToSettlementTime::get()).unwrap();
inst.advance_time(<PolimecRuntime as Config>::SuccessToSettlementTime::get());

inst.settle_project(project_id).unwrap();

Expand Down Expand Up @@ -462,7 +460,7 @@ fn ct_migrated() {
excel_contributions(),
excel_remainders(),
);
inst.advance_time(<PolimecRuntime as Config>::SuccessToSettlementTime::get()).unwrap();
inst.advance_time(<PolimecRuntime as Config>::SuccessToSettlementTime::get());

inst.settle_project(project_id).unwrap();

Expand Down Expand Up @@ -540,7 +538,7 @@ fn ct_migrated() {
));
let key: [u8; 32] = account.clone().into();
println!("Migrated CTs for {}", names[&key]);
inst.advance_time(1u32).unwrap();
inst.advance_time(1u32);
});
}

Expand Down
6 changes: 3 additions & 3 deletions integration-tests/src/tests/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn members_can_feed_data() {

PolimecNet::execute_with(|| {
// pallet_funding genesis builder already inputs prices, so we need to advance one block to feed new values.
inst.advance_time(1u32).unwrap();
inst.advance_time(1u32);
let alice = PolimecNet::account_id_of(ALICE);
assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([4.84, 1.0, 1.0, 0.4])));

Expand Down Expand Up @@ -81,7 +81,7 @@ fn data_is_correctly_combined() {
let mut inst = IntegrationInstantiator::new(None);
PolimecNet::execute_with(|| {
// pallet_funding genesis builder already inputs prices, so we need to advance one block to feed new values.
inst.advance_time(1u32).unwrap();
inst.advance_time(1u32);

let alice = PolimecNet::account_id_of(ALICE);
assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([1.0, 1.5, 1.1, 0.11111])));
Expand Down Expand Up @@ -113,7 +113,7 @@ fn pallet_funding_works() {

PolimecNet::execute_with(|| {
// pallet_funding genesis builder already inputs prices, so we need to advance one block to feed new values.
inst.advance_time(1u32).unwrap();
inst.advance_time(1u32);

let alice = PolimecNet::account_id_of(ALICE);
assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([4.84, 1.0, 1.0, 0.4])));
Expand Down
12 changes: 6 additions & 6 deletions nodes/parachain/src/chain_spec/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ pub fn genesis_config(genesis_config_params: GenesisConfigParams) -> serde_json:
#[cfg(feature = "runtime-benchmarks")]
let staking_candidates: Vec<(AccountId, Balance)> = vec![];

let usdt_id = pallet_funding::types::AcceptedFundingAsset::USDT.to_assethub_id();
let usdc_id = pallet_funding::types::AcceptedFundingAsset::USDC.to_assethub_id();
let dot_id = pallet_funding::types::AcceptedFundingAsset::DOT.to_assethub_id();
let usdt_id = pallet_funding::types::AcceptedFundingAsset::USDT.id();
let usdc_id = pallet_funding::types::AcceptedFundingAsset::USDC.id();
let dot_id = pallet_funding::types::AcceptedFundingAsset::DOT.id();

serde_json::json!({
"balances": {
Expand All @@ -114,19 +114,19 @@ pub fn genesis_config(genesis_config_params: GenesisConfigParams) -> serde_json:
},
"foreignAssets": {
"assets": vec![(
pallet_funding::types::AcceptedFundingAsset::USDT.to_assethub_id(),
pallet_funding::types::AcceptedFundingAsset::USDT.id(),
&AccountIdConversion::<AccountId>::into_account_truncating(&<Runtime as pallet_funding::Config>::PalletId::get()),
true,
70000,
),
(
pallet_funding::types::AcceptedFundingAsset::USDC.to_assethub_id(),
pallet_funding::types::AcceptedFundingAsset::USDC.id(),
&AccountIdConversion::<AccountId>::into_account_truncating(&<Runtime as pallet_funding::Config>::PalletId::get()),
true,
70000,
),
(
pallet_funding::types::AcceptedFundingAsset::DOT.to_assethub_id(),
pallet_funding::types::AcceptedFundingAsset::DOT.id(),
&AccountIdConversion::<AccountId>::into_account_truncating(&<Runtime as pallet_funding::Config>::PalletId::get()),
true,
70000,
Expand Down
Loading

0 comments on commit 706a0c4

Please sign in to comment.