Skip to content

Commit

Permalink
Reactivate extrinsic creation unit tests (#805)
Browse files Browse the repository at this point in the history
* enable unit tests for metadata hash check

* add runtime.wasm

* remove extra spacing
  • Loading branch information
haerdib authored Sep 19, 2024
1 parent c12b735 commit ae15187
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pallet-contracts = { optional = true, git = "https://github.com/paritytech/polka
pallet-staking = { optional = true, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "master" }

[dev-dependencies]
frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "master" }
solochain-template-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "master" }
sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "master" }
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "master" }
Expand Down
9 changes: 4 additions & 5 deletions primitives/src/extrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ mod tests {
use super::*;
use crate::AssetRuntimeConfig;
use extrinsic_params::{GenericAdditionalParams, GenericExtrinsicParams, PlainTip};
use frame_metadata_hash_extension::CheckMetadataHash;
use frame_system::{
CheckEra, CheckGenesis, CheckNonZeroSender, CheckNonce, CheckSpecVersion, CheckTxVersion,
CheckWeight,
Expand Down Expand Up @@ -325,8 +326,6 @@ mod tests {
assert_eq!(call, call1);
}

// Currently does not with available version of substrate extrinsic
#[cfg(not(feature = "disable-metadata-hash-check"))]
#[test]
fn xt_hash_matches_substrate_impl() {
// Define extrinsic params.
Expand All @@ -353,6 +352,7 @@ mod tests {
CheckNonce::<Runtime>::from(nonce),
CheckWeight::<Runtime>::new(),
ChargeTransactionPayment::<Runtime>::from(fee),
CheckMetadataHash::<Runtime>::new(false),
);

let substrate_extrinsic = UncheckedExtrinsic::new_signed(
Expand Down Expand Up @@ -386,13 +386,11 @@ mod tests {
)
}

// Currently does not work with stored bytes. Need to create a new version
#[cfg(not(feature = "disable-metadata-hash-check"))]
#[test]
fn xt_hash_matches_substrate_impl_large_xt() {
// Define xt parameters,
let alice = MultiAddress::Id(AccountKeyring::Alice.to_account_id());
let code: Vec<u8> = include_bytes!("test-runtime.compact.wasm").to_vec();
let code: Vec<u8> = include_bytes!("solochain_template_runtime.wasm").to_vec();
let call = RuntimeCall::System(SystemCall::set_code { code });

let msg = &b"test-message"[..];
Expand All @@ -412,6 +410,7 @@ mod tests {
CheckNonce::<Runtime>::from(nonce),
CheckWeight::<Runtime>::new(),
ChargeTransactionPayment::<Runtime>::from(fee),
CheckMetadataHash::<Runtime>::new(false),
);
let substrate_extrinsic = UncheckedExtrinsic::new_signed(
call.clone(),
Expand Down
Binary file not shown.
Binary file removed primitives/src/extrinsics/test-runtime.compact.wasm
Binary file not shown.
3 changes: 1 addition & 2 deletions src/api/api_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ mod tests {
use super::*;
use crate::rpc::mocks::RpcClientMock;
use ac_primitives::{
AssetRuntimeConfig, DefaultRuntimeConfig, GenericAdditionalParams, GenericExtrinsicParams,
PlainTip,
DefaultRuntimeConfig, GenericAdditionalParams, GenericExtrinsicParams, PlainTip,
};
use frame_metadata::{v14::ExtrinsicMetadata, RuntimeMetadata};
use scale_info::form::PortableForm;
Expand Down

0 comments on commit ae15187

Please sign in to comment.