Skip to content

Commit

Permalink
Fix try-runtime usage
Browse files Browse the repository at this point in the history
  • Loading branch information
louismerlin committed Feb 8, 2024
1 parent 783ecba commit 4b1e9cf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
1 change: 0 additions & 1 deletion polkadot/xcm/xcm-simulator/fuzzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ polkadot-runtime-parachains = { path = "../../../runtime/parachains" }
polkadot-parachain-primitives = { path = "../../../parachain" }

[features]
default = ["try-runtime"]
try-runtime = [
"frame-executive/try-runtime",
"frame-support/try-runtime",
Expand Down
6 changes: 3 additions & 3 deletions polkadot/xcm/xcm-simulator/fuzzer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ cargo install honggfuzz
In this directory, run this command:

```
cargo hfuzz run xcm-fuzzer
HFUZZ_BUILD_ARGS="--features=try-runtime" cargo hfuzz run xcm-fuzzer
```

## Run a single input

In this directory, run this command:

```
cargo hfuzz run-debug xcm-fuzzer hfuzz_workspace/xcm-fuzzer/fuzzer_input_file
cargo run --features=try-runtime -- hfuzz_workspace/xcm-fuzzer/fuzzer_input_file
```

## Generate coverage
Expand All @@ -31,7 +31,7 @@ In this directory, run these four commands:

```
RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" \
CARGO_INCREMENTAL=0 SKIP_WASM_BUILD=1 CARGO_HOME=./cargo cargo build
CARGO_INCREMENTAL=0 SKIP_WASM_BUILD=1 CARGO_HOME=./cargo cargo build --features=try-runtime
../../../target/debug/xcm-fuzzer hfuzz_workspace/xcm-fuzzer/input/
zip -0 ccov.zip `find ../../../target/ \( -name "*.gc*" -o -name "test-*.gc*" \) -print`
grcov ccov.zip -s ../../../ -t html --llvm --branch --ignore-not-existing -o ./coverage
Expand Down
9 changes: 5 additions & 4 deletions polkadot/xcm/xcm-simulator/fuzzer/src/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ use polkadot_parachain_primitives::primitives::Id as ParaId;
use sp_runtime::{traits::AccountIdConversion, BuildStorage};
use xcm_simulator::{decl_test_network, decl_test_parachain, decl_test_relay_chain, TestExt};

use frame_support::{
assert_ok,
traits::{IntegrityTest, TryState, TryStateSelect::All},
};
#[cfg(feature = "try-runtime")]
use frame_support::traits::{TryState, TryStateSelect::All};
use frame_support::{assert_ok, traits::IntegrityTest};
use xcm::{latest::prelude::*, MAX_XCM_DECODE_DEPTH};

use arbitrary::{Arbitrary, Error, Unstructured};
Expand Down Expand Up @@ -224,12 +223,14 @@ fn run_input(xcm_messages: [XcmMessage; 5]) {
[ParaA::execute_with, ParaB::execute_with, ParaC::execute_with].iter().for_each(
|execute_with| {
execute_with(|| {
#[cfg(feature = "try-runtime")]
parachain::AllPalletsWithSystem::try_state(Default::default(), All).unwrap();
parachain::AllPalletsWithSystem::integrity_test();
});
},
);
Relay::execute_with(|| {
#[cfg(feature = "try-runtime")]
relay_chain::AllPalletsWithSystem::try_state(Default::default(), All).unwrap();
relay_chain::AllPalletsWithSystem::integrity_test();
});
Expand Down

0 comments on commit 4b1e9cf

Please sign in to comment.