The purpose of this directory is to consolidate all the necessary components for testing RegionX functionality in one place. This repository offers scrits, simplifying the process of spinning up the required chains for testing.
The local environment consists of three chains:
- Rococo relay chain
- Coretime parachain
- Astar Shibuya parachain
NOTE: Before proceeding make sure to have zombienet setup on your machine and accessible from your PATH. You can find linux and macOS executables of the Zombienet CLI here
# Clone the repo:
git clone https://github.com/RegionX-Labs/Coretime-Mock.git
# Pull the submodules:
git submodule update --initTo run the local environment, we will first need to get all the necessary binaries.
If we only want to test functionality that is not related to any of the contracts, we can simply run the minimal_network.toml zombienet script:
# This script compiles all the necessary binaries for running a Rococo relay chain,
# Coretime chain.
./scripts/minimal_init.sh In case we want to run the full local network, which will allow us to test the contracts as well, we need to get the binary from the contracts parachain as well:
# This script compiles all the necessary binaries for running a Rococo relay chain,
# Coretime chain, and a smart contract chain.
./scripts/full_init.shAfter waiting a few minutes for the network initialization and once both parachains begin block production, we can proceed to initialize the environment.
This repo provides an init program which will based on the selected options set up the local network appropriately. The program exposes the following options:
-
--relayInit:- Description: Initializes the relay chain. The only thing this actually does is open an HRMP channel between the two parachains.
-
--coretimeInit:- Description: Initializes the coretime chain by setting the initial configuration, starting the bulk sale and buying a region.
-
--contractsInit:- Description: Initializes the contracts parachain by creating a collection to represent regions, and mints a mock region. Also, deploys both the
xc-regionsand thecoretime-marketcontracts.
- Description: Initializes the contracts parachain by creating a collection to represent regions, and mints a mock region. Also, deploys both the
-
--contractsAccount <string>:- Description: Specify an account on the contracts chain. When specified the program will transfer a mock region to this account.
-
--contractsPath <string>:- Description: The path to the compiled contracts.
-
--coretimeAccount <string>:- Description: Specify an account on the coretime chain. When specified the program will transfer a mock region to this account.
Example: Testing contracts related stuff only:
NOTE: For the following to work, it is expected that the
astar-collatornode is running in the background in--devmode at port9920.Command for running the node:
astar-collator --dev --rpc-port 9920
-
Compile the contracts in the RegionX directory. Before compilation ensure the uniques pallet index is configured correctly. In this case it should be set to 30: https://github.com/RegionX-Labs/RegionX?tab=readme-ov-file#4-deploy
cd RegionX/contracts/xc-regions cargo contract build cd ../coretime_market cargo contract build
-
After successful compilation, you can initialize the contracts chain with the command below.
npm run zombienet-init -- \ --contractsInit \ --contractsPath ../RegionX/target/ink/ \ --contractsAccount "X2pK59cdJrdw4Ca7cNywKFtCc9bPMRGVefbeYWXa1GJJJsk"
Example: Testing with full environment
NOTE: For the following to work, it is expected that you run
npm run zombienet:fullin the background.
- Compile the contracts in the RegionX directory. Before compilation ensure the uniques pallet index is configured correctly. In this case it should be set to 37: https://github.com/RegionX-Labs/RegionX?tab=readme-ov-file#4-deploy
cd RegionX/contracts/xc-regions cargo contract build cd ../coretime_market cargo contract build
- After successful compilation and once all the parachains started producing blocks, you can initialize the full network setup using the command below.
npm run zombienet-init -- \ --contractsInit \ --coretimeInit \ --relayInit \ --contractsPath ../RegionX/target/ink/ \ --contractsAccount "X2pK59cdJrdw4Ca7cNywKFtCc9bPMRGVefbeYWXa1GJJJsk" \ --coretimeAccount "5DADsnBXr5DXiEAjdJvruf6c7ZSUR8iXUTATQqJfheGLiEVm"
The Coretime chain is already deployed on Rococo (🥳), allowing us to use Chopsticks for aspects of local frontend testing that do not require the xc-regions contract.
The steps to run a Coretime chain locally and setup the mock environment:
npm i
# This will run a parallel copy of the Coretime chain
npm run chopsticks
# In a new terminal:
# This will add some mock data to the Coretime chain
npm run chopsticks-init