Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauthamastro committed May 15, 2024
1 parent 09bd718 commit d05f1a0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 40 deletions.
26 changes: 1 addition & 25 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,7 @@ members = [
"polkadex-xcm-simulator",
]
exclude = ["scripts/check-off-on-deviation"]
default-members = [
"client",
"nodes/mainnet",
"nodes/parachain",
"runtimes/mainnet",
"runtimes/parachain",
"pallets/pdex-migration",
"pallets/pdex-migration",
"pallets/ocex",
"pallets/ocex/rpc",
"pallets/liquidity-mining",
"pallets/ocex/rpc/runtime-api",
"pallets/rewards",
"primitives/orderbook",
"primitives/polkadex",
"primitives/thea",
"primitives/bls",
"pallets/thea",
"pallets/thea-executor",
"pallets/rewards/rpc",
"pallets/rewards/rpc/runtime-api",
"rpc/swap",
"polkadex-xcm-simulator",
]


[workspace.dependencies]
log = { version = "0.4.8", default-features = false }
Expand Down Expand Up @@ -135,7 +112,6 @@ pallet-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-staking-reward-curve = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
#pallet-randomness-collective-flip = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-statement = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion check-all-ci-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ cargo build --features try-runtime || exit
cargo build --features runtime-benchmarks || exit
./target/debug/polkadex-node benchmark pallet --pallet "*" --extrinsic "*" --steps 2 --repeat 1 || exit
cargo clippy -- -D warnings || exit
RUSTFLAGS="-D warnings" cargo test || exit
RUSTFLAGS="-D warnings" cargo test --workspace || exit
11 changes: 6 additions & 5 deletions pallets/thea-message-handler/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,19 @@ impl thea_executor::Config for Test {
type Currency = Balances;
type Assets = Assets;
type AssetId = u128;
type MultiAssetIdAdapter = AssetId;
type AssetBalanceAdapter = u128;
type AssetCreateUpdateOrigin = EnsureRoot<Self::AccountId>;
type Executor = Thea;
type NativeAssetId = PolkadexAssetId;
type TheaPalletId = TheaPalletId;
type Swap = AssetConversion;
type Orderbook = ();
type WithdrawalSize = WithdrawalSize;
type ExistentialDeposit = ExistentialDeposit;
type ParaId = ParaId;
type Swap = AssetConversion;
type TheaExecWeightInfo = thea_executor::weights::WeightInfo<Test>;
type MultiAssetIdAdapter = AssetId;
type AssetBalanceAdapter = u128;
type GovernanceOrigin = EnsureRoot<u64>;
type ExistentialDeposit = ExistentialDeposit;
type TheaExecWeightInfo = thea_executor::weights::WeightInfo<Test>;
}

impl crate::Config for Test {
Expand Down
26 changes: 17 additions & 9 deletions pallets/xcm-helper/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@

use crate::{mock::*, Error, PendingWithdrawals};
use frame_support::{assert_noop, assert_ok, traits::Currency};
use sp_core::H160;
use sp_runtime::{traits::AccountIdConversion, DispatchError, SaturatedConversion};
use thea_primitives::extras::ExtraData;
use thea_primitives::types::Withdraw;
use xcm::latest::{AssetId, MultiLocation};

Expand Down Expand Up @@ -124,31 +126,37 @@ fn test_transfer_fee_with_bad_origin_will_return_bad_origin_error() {
fn test_block_by_ele() {
new_test_ext().execute_with(|| {
let first_withdrawal = Withdraw {
id: Vec::new(),
asset_id: 1,
id: H160::zero(),
asset_id: polkadex_primitives::AssetId::Asset(1),
amount: 1,
destination: vec![],
fee_asset_id: None,
fee_amount: None,
is_blocked: false,
extra: vec![],
extra: ExtraData::None,
};
let sec_withdrawal = Withdraw {
id: Vec::new(),
asset_id: 2,
id: H160::zero(),
asset_id: polkadex_primitives::AssetId::Asset(1),
amount: 2,
destination: vec![],
fee_asset_id: None,
fee_amount: None,
is_blocked: false,
extra: vec![],
extra: ExtraData::None,
};
<PendingWithdrawals<Test>>::insert(1, vec![first_withdrawal, sec_withdrawal]);
assert_ok!(XcmHelper::block_by_ele(1, 1));
let actual_withdrawals = <PendingWithdrawals<Test>>::get(1);
let expected_withdraw = Withdraw {
id: Vec::new(),
asset_id: 2,
id: H160::zero(),
asset_id: polkadex_primitives::AssetId::Asset(1),
amount: 2,
destination: vec![],
fee_asset_id: None,
fee_amount: None,
is_blocked: true,
extra: vec![],
extra: ExtraData::None,
};
assert_eq!(actual_withdrawals[1], expected_withdraw);
assert_noop!(XcmHelper::block_by_ele(1, 4), Error::<Test>::IndexNotFound);
Expand Down

0 comments on commit d05f1a0

Please sign in to comment.