Docs
Submit an issue
Appchains on Polkadot
Appchains on Polkadot
  • WELCOME
    • Polkadot Appchains
    • Installing Pop CLI
    • How to contribute
  • GUIDES
    • Set up your development environment
    • Create a new parachain
      • Create an Assets parachain
      • Create a Contracts parachain
      • Create an EVM parachain
    • Benchmarking
    • Build your parachain
      • Build your runtime deterministically
    • Call a chain
    • Launch a Chain
      • Launch a Chain in Development
      • Launch a Chain to Paseo
        • Launch Paseo
        • Set up keys
        • Acquire Coretime
      • Deploy a chain with Polkadot Deployment Portal
      • Running a post-startup command
    • Securely Sign Transactions from CLI
    • Test runtime upgrades
  • POP CLI
    • welcome
    • install
    • new
    • bench
    • build
    • build spec
    • call
    • up
    • clean
    • test
Powered by GitBook
On this page
  • test on-runtime-upgrade
  • test on-runtime-upgrade live
  • test on-runtime-upgrade snap
  • test create-snapshot
  • test execute-block
  • test fast-forward
  • Learning Resources

Was this helpful?

Edit on GitHub
  1. POP CLI

test

Test runtime upgrades

Previousclean

Last updated 1 month ago

Was this helpful?

The Pop CLI feature is built on top of the , a programmatic testing framework designed for Substrate. It allows you to test runtime upgrades and state transitions.

  • on-runtime-upgrade: Tests migrations.

  • execute-block: Executes a specified block against some state.

  • fast-forward: Executes a runtime upgrade (optional), then mines a number of blocks while performing try-state checks.

  • create-snapshot: Creates a chain state snapshot.

test on-runtime-upgrade

To test , you can use the on-runtime-upgrade subcommand. This command allows you to test migrations by executing the hooks of a runtime against the state of a live blockchain or a snapshot.

pop test on-runtime-upgrade live

Note: If you choose to run migrations on a local runtime binary, you will be prompted to provide a valid runtime binary path. .

Pop CLI will automatically locate the runtime binary based on the provided --profile. If the binary is not found, Pop CLI will build it automatically.

If a runtime is not specified, the migration will be executed on the code currently running on the remote node of a live blockchain or the one stored in the provided snapshot file.

test on-runtime-upgrade live

To run migrations against a live blockchain, use the on-runtime-upgrade live subcommand:

pop test on-runtime-upgrade live

You'll be prompted to provide an RPC URI of a live blockchain. A valid RPC URI must start with ws:// or wss://. You can also specify an optional block hash to define the state execution point.

To manually provide the URI and block hash, use:

pop test on-runtime-upgrade \
    --runtime=<path_to_runtime_binary> \
    live \
    --uri=wss://rpc1.paseo.popnetwork.xyz \
    --at=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef

test on-runtime-upgrade snap

To run migrations against a snapshot, use the on-runtime-upgrade snap subcommand:

pop test on-runtime-upgrade \
    --runtime=<path_to_runtime_binary> \
    snap \
    --path=./example.snap

test create-snapshot

This command saves a copy of the blockchain's current state to a file (a snapshot). You can use this snapshot to run tests quickly instead of downloading the state from a live blockchain each time.

pop test create-snapshot

You'll be prompted to enter the RPC URI (the network address of the live blockchain) and the file path where the snapshot should be stored.

To provide these parameters manually:

pop test create-snapshot \
    --uri=wss://rpc1.paseo.popnetwork.xyz \
    --path=./example.snap

test execute-block

This command executes a given number of blocks. Currently, execute-block only supports executing blocks against a live state. You can also specify a block hash to execute from.

pop test execute-block

You'll be prompted to select state tests to execute, with the following options:

  • None: No state tests will be executed.

  • All: Executes all available state tests.

  • Round Robin: Runs a fixed number of state tests in a round-robin manner.

  • Only Pallets: Executes only state tests related to specific pallets.

Available pallets on the live network will be listed for selection:

◆  Select pallets (select with SPACE):
│
│  ◻ Assets
│  ◻ Aura
│  ◻ AuraExt
│  ◻ Authorship
│  ◻ Balances
│  ◻ CollatorSelection
│  ◻ Contracts
│  ◻ Council
└

To skip the interactive interface and provide arguments manually:

pop test execute-block \
    --runtime=<path_to_runtime_binary> \
    --try-state=Aura,Assets,Authorship \
    -y \
    --uri=wss://rpc1.paseo.popnetwork.xyz

For round-robin state tests, use:

pop test execute-block \
    --runtime=<path_to_runtime_binary> \
    --try-state=rr-10 \
    -y \
    --uri=wss://rpc1.paseo.popnetwork.xyz

test fast-forward

Executes a runtime upgrade (optional), then mines a number of blocks while performing try-state checks.

pop test fast-forward

You'll be prompted to specify the number of blocks to mine and whether to run pending migrations before fast-forwarding.

◇  How many empty blocks should be processed?
│  10
│
◆  Do you want to run pending migrations before fast-forwarding?
│  ● Yes  / ○ No
└

Like on-runtime-upgrade, fast-forward supports live and snap subcommands to define the source of the runtime state.

To skip the interactive interface and specify arguments manually:

pop test fast-forward \
    --n-blocks 10 \
    --run-migrations \
    live \
    --uri=wss://rpc1.paseo.popnetwork.xyz

Pop CLI will automatically locate the runtime binary based on the provided --profile. If the binary is not found, it will be built automatically.

Learning Resources

Note: A live blockchain node must be .

Note: If you run migrations on a local runtime binary, you will be prompted to provide a valid runtime binary path. .

Learn more about and .

try-runtime-cli
runtime upgrades
OnRuntimeUpgrade
Ensure the binary is built with the try-runtime feature
built with the --try-runtime feature
Ensure the binary is built with the try-runtime feature
Runtime Upgrades
Storage Migrations