Skip to content

Commit

Permalink
fix test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
claravanstaden authored and claravanstaden committed Jan 23, 2024
1 parent 3231690 commit 2d5929a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
27 changes: 12 additions & 15 deletions parachain/pallets/ethereum-client/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,22 +629,19 @@ fn submit_update_with_skipped_sync_committee_period() {

#[test]
fn submit_update_execution_headers_too_far_behind() {
let checkpoint = load_checkpoint_update_fixture();
let finalized_header_update = load_finalized_header_update_fixture();
let execution_header_update = load_execution_header_update_fixture();
let next_update = load_next_sync_committee_update_fixture();
let checkpoint = Box::new(load_checkpoint_update_fixture());
let finalized_header_update = Box::new(load_finalized_header_update_fixture());
let execution_header_update = Box::new(load_execution_header_update_fixture());
let next_update = Box::new(load_next_sync_committee_update_fixture());

new_tester().execute_with(|| {
let far_ahead_finalized_header_slot = finalized_header_update.finalized_header.slot +
(EPOCHS_PER_SYNC_COMMITTEE_PERIOD * SLOTS_PER_EPOCH * 2) as u64;
assert_ok!(EthereumBeaconClient::process_checkpoint_update(&checkpoint));
assert_ok!(EthereumBeaconClient::submit(
RuntimeOrigin::signed(1),
Box::new(finalized_header_update)
));
assert_ok!(EthereumBeaconClient::submit(RuntimeOrigin::signed(1), finalized_header_update));
assert_ok!(EthereumBeaconClient::submit_execution_header(
RuntimeOrigin::signed(1),
Box::new(execution_header_update)
execution_header_update
));

let header_root: H256 = TEST_HASH.into();
Expand All @@ -658,7 +655,7 @@ fn submit_update_execution_headers_too_far_behind() {
LatestFinalizedBlockRoot::<Test>::set(header_root);

assert_err!(
EthereumBeaconClient::submit(RuntimeOrigin::signed(1), Box::new(next_update)),
EthereumBeaconClient::submit(RuntimeOrigin::signed(1), next_update),
Error::<Test>::ExecutionHeaderTooFarBehind
);
});
Expand Down Expand Up @@ -699,14 +696,14 @@ fn submit_update_with_missing_bootstrap() {

#[test]
fn submit_update_with_invalid_sync_committee_update() {
let checkpoint = load_checkpoint_update_fixture();
let update = load_sync_committee_update_fixture();
let mut next_update = load_next_sync_committee_update_fixture();
let checkpoint = Box::new(load_checkpoint_update_fixture());
let update = Box::new(load_sync_committee_update_fixture());
let mut next_update = Box::new(load_next_sync_committee_update_fixture());

new_tester().execute_with(|| {
assert_ok!(EthereumBeaconClient::process_checkpoint_update(&checkpoint));

assert_ok!(EthereumBeaconClient::submit(RuntimeOrigin::signed(1), Box::new(update)));
assert_ok!(EthereumBeaconClient::submit(RuntimeOrigin::signed(1), update));

// makes update with invalid next_sync_committee
<FinalizedBeaconState<Test>>::mutate(<LatestFinalizedBlockRoot<Test>>::get(), |x| {
Expand All @@ -719,7 +716,7 @@ fn submit_update_with_invalid_sync_committee_update() {
next_update.next_sync_committee_update = Some(next_sync_committee);

assert_err!(
EthereumBeaconClient::submit(RuntimeOrigin::signed(1), Box::new(next_update)),
EthereumBeaconClient::submit(RuntimeOrigin::signed(1), next_update),
Error::<Test>::InvalidSyncCommitteeUpdate
);
});
Expand Down
2 changes: 1 addition & 1 deletion parachain/runtime/runtime-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl<Balance, AccountId, FeeAssetLocation, EthereumNetwork, AssetTransactor, Fee
FeeProvider,
> where
Balance: BaseArithmetic + Unsigned + Copy + From<u128> + Into<u128> + Debug,
AccountId: Clone + Into<[u8; 32]> + From<[u8; 32]> + FullCodec,
AccountId: Clone + FullCodec,
FeeAssetLocation: Get<Location>,
EthereumNetwork: Get<NetworkId>,
AssetTransactor: TransactAsset,
Expand Down
12 changes: 6 additions & 6 deletions parachain/runtime/runtime-common/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use xcm::prelude::{
Asset, Assets, Here, Kusama, Location, NetworkId, Parachain, XcmContext, XcmError, XcmHash,
XcmResult,
};
use xcm_builder::HandleFee;
use xcm_executor::{
traits::{FeeReason, TransactAsset},
traits::{FeeReason, TransactAsset}, AssetsInHolding,
};
use xcm_builder::HandleFee;

parameter_types! {
pub EthereumNetwork: NetworkId = NetworkId::Ethereum { chain_id: 11155111 };
Expand Down Expand Up @@ -74,17 +74,17 @@ impl TransactAsset for MockAssetTransactor {
_what: &Asset,
_who: &Location,
_context: Option<&XcmContext>,
) -> Result<Assets, XcmError> {
Ok(Assets::default())
) -> Result<AssetsInHolding, XcmError> {
Ok(Assets::default().into())
}

fn internal_transfer_asset(
_what: &Asset,
_from: &Location,
_to: &Location,
_context: &XcmContext,
) -> Result<Assets, XcmError> {
Ok(Assets::default())
) -> Result<AssetsInHolding, XcmError> {
Ok(Assets::default().into())
}
}

Expand Down

0 comments on commit 2d5929a

Please sign in to comment.