shaunxw / xcm-simulator

Test kit to simulate cross-chain message passing and XCM execution
Apache License 2.0
43 stars 45 forks source link

`xcm-emulator` tests fail when switching `yayoi` runtime for `statemint-runtime` #16

Closed jakehemmerle closed 2 years ago

jakehemmerle commented 3 years ago

I'm trying to make some reserve transfer tests using the Kusama and Statemine runtimes for XCM documentation for runtime developers. I figured swapping the yayoi runtime for statemine-runtime would be a good start (literally swapping every yayoi:: string for statemine_runtime:: and adding statemine-runtime to Config.toml), but I'm getting the following errors.

~/codebases/w3f/xcm-simulator master !3                                                                                                          
❯ RUST_BACKTRACE=1 cargo test -p xcm-emulator-example 
    Finished test [unoptimized + debuginfo] target(s) in 2.17s
     Running unittests (target/debug/deps/xcm_emulator_example-5877f358a5b09661)

running 4 tests
test tests::ump ... ok
test tests::dmp ... ok
test tests::xcmp ... FAILED
test tests::xcmp_through_a_parachain ... FAILED

failures:

---- tests::xcmp stdout ----
>>> Event::XcmpQueue(Event::Fail(Some(0xef3c53636b690c322a099df7a38f9d6ef1b67352147e0170204f58b79c4814bc), Barrier))
thread 'tests::xcmp' panicked at 'assertion failed: System::events().iter().any(|r|\n                                matches!(r.event, Event ::\n                                         System(frame_system :: Event ::\n                                                Remarked(_, _))))', xcm-emulator/example/src/lib.rs:239:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:50:5
   3: xcm_emulator_example::tests::xcmp::{{closure}}
             at ./src/lib.rs:239:4
   4: environmental::using::{{closure}}
             at /Users/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/environmental-1.1.3/src/lib.rs:125:3
   5: std::thread::local::LocalKey<T>::try_with
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/local.rs:399:16
   6: std::thread::local::LocalKey<T>::with
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/local.rs:375:9
   7: environmental::using
             at /Users/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/environmental-1.1.3/src/lib.rs:106:2
   8: sp_externalities::scope_limited::ext::using
             at /Users/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/environmental-1.1.3/src/lib.rs:252:5
   9: sp_externalities::scope_limited::set_and_run_with_externalities
             at /Users/jake/.cargo/git/checkouts/substrate-7e08433d4c370a21/57346f6/primitives/externalities/src/scope_limited.rs:31:2
  10: sp_state_machine::testing::TestExternalities<H,N>::execute_with
             at /Users/jake/.cargo/git/checkouts/substrate-7e08433d4c370a21/57346f6/primitives/state-machine/src/testing.rs:200:3
  11: <xcm_emulator_example::YayoiMushroom as xcm_emulator::TestExt>::execute_with::{{closure}}
             at /Users/jake/codebases/w3f/xcm-simulator/xcm-emulator/src/lib.rs:225:32
  12: std::thread::local::LocalKey<T>::try_with
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/local.rs:399:16
  13: std::thread::local::LocalKey<T>::with
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/local.rs:375:9
  14: <xcm_emulator_example::YayoiMushroom as xcm_emulator::TestExt>::execute_with
             at /Users/jake/codebases/w3f/xcm-simulator/xcm-emulator/src/lib.rs:225:13
  15: xcm_emulator_example::tests::xcmp
             at ./src/lib.rs:235:3
  16: xcm_emulator_example::tests::xcmp::{{closure}}
             at ./src/lib.rs:217:2
  17: core::ops::function::FnOnce::call_once
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/ops/function.rs:227:5
  18: core::ops::function::FnOnce::call_once
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

---- tests::xcmp_through_a_parachain stdout ----
>>> Event::XcmpQueue(Event::Fail(Some(0xee89f42c7f7adbb1839aa1b01ba550bab977718eb7c6fff52f378a0cf9430b4e), Barrier))
thread 'tests::xcmp_through_a_parachain' panicked at 'assertion failed: System::events().iter().any(|r|\n                                matches!(r.event, Event ::\n                                         PolkadotXcm(pallet_xcm :: Event ::\n                                                     Sent(_, _, _))))', xcm-emulator/example/src/lib.rs:279:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:50:5
   3: xcm_emulator_example::tests::xcmp_through_a_parachain::{{closure}}
             at ./src/lib.rs:279:4
   4: environmental::using::{{closure}}
             at /Users/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/environmental-1.1.3/src/lib.rs:125:3
   5: std::thread::local::LocalKey<T>::try_with
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/local.rs:399:16
   6: std::thread::local::LocalKey<T>::with
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/local.rs:375:9
   7: environmental::using
             at /Users/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/environmental-1.1.3/src/lib.rs:106:2
   8: sp_externalities::scope_limited::ext::using
             at /Users/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/environmental-1.1.3/src/lib.rs:252:5
   9: sp_externalities::scope_limited::set_and_run_with_externalities
             at /Users/jake/.cargo/git/checkouts/substrate-7e08433d4c370a21/57346f6/primitives/externalities/src/scope_limited.rs:31:2
  10: sp_state_machine::testing::TestExternalities<H,N>::execute_with
             at /Users/jake/.cargo/git/checkouts/substrate-7e08433d4c370a21/57346f6/primitives/state-machine/src/testing.rs:200:3
  11: <xcm_emulator_example::YayoiMushroom as xcm_emulator::TestExt>::execute_with::{{closure}}
             at /Users/jake/codebases/w3f/xcm-simulator/xcm-emulator/src/lib.rs:225:32
  12: std::thread::local::LocalKey<T>::try_with
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/local.rs:399:16
  13: std::thread::local::LocalKey<T>::with
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/local.rs:375:9
  14: <xcm_emulator_example::YayoiMushroom as xcm_emulator::TestExt>::execute_with
             at /Users/jake/codebases/w3f/xcm-simulator/xcm-emulator/src/lib.rs:225:13
  15: xcm_emulator_example::tests::xcmp_through_a_parachain
             at ./src/lib.rs:275:3
  16: xcm_emulator_example::tests::xcmp_through_a_parachain::{{closure}}
             at ./src/lib.rs:246:2
  17: core::ops::function::FnOnce::call_once
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/ops/function.rs:227:5
  18: core::ops::function::FnOnce::call_once
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

failures:
    tests::xcmp
    tests::xcmp_through_a_parachain

test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.34s

error: test failed, to rerun pass '-p xcm-emulator-example --lib'

It appears that it's checking for the event type to have a remark or something similar, but it does not appear to exist. The relevant lines of code are https://github.com/shaunxw/xcm-simulator/blob/master/xcm-emulator/example/src/lib.rs#L239 and https://github.com/shaunxw/xcm-simulator/blob/master/xcm-emulator/example/src/lib.rs#L279

shaunxw commented 2 years ago

There is barrier errors in failing test. I believe it's the XCM configuration in statemine preventing to execute Transact messages in these test cases. But the messages that are allowed by statemine runtime config should work well.