This PR are connected to Ganache-like testing feature #49. The main purpose of this issue is to make testing easier by implementing next features:
block time stamp manipulation (can mine a block with arbitrary block time stamp)
block number manipulation
taking a snapshot and retrieve later
Balance manipulation of accounts
Impersonate any account
All of them can already implemented in Chopsticks. Below I will explain how to use it.
Firstly, you should set up your swanky project with swanky init and choose that you want to install swanky-node. Then you should use swanky node chopsticks init to initiate chopsticks config, which will be stored in the ./node/config/ folder. Then you start the node(swanky node start) and fork it with chopsticks(swanky node chopsticks start).
Now we have a testing node that has all the features that we need. Chopsticks allow to use of different RPC calls. Full list of them you can check here.
For example, you can do timestamp manipulation by `dev_timeTravel' RPC call:
import { WsProvider } from '@polkadot/rpc-provider'
const ws = new WsProvider(`ws://localhost:8000`)
await ws.send('dev_timeTravel', ['Jan 1, 2023'])
Or go back to any block by 'dev_setHead':
import { WsProvider } from '@polkadot/rpc-provider'
const ws = new WsProvider(`ws://localhost:8000`)
await ws.send('dev_setHead', [1000000])
This PR are connected to Ganache-like testing feature #49. The main purpose of this issue is to make testing easier by implementing next features:
All of them can already implemented in Chopsticks. Below I will explain how to use it. Firstly, you should set up your swanky project with
swanky init
and choose that you want to install swanky-node. Then you should useswanky node chopsticks init
to initiate chopsticks config, which will be stored in the./node/config/
folder. Then you start the node(swanky node start
) and fork it with chopsticks(swanky node chopsticks start
). Now we have a testing node that has all the features that we need. Chopsticks allow to use of different RPC calls. Full list of them you can check here. For example, you can do timestamp manipulation by `dev_timeTravel' RPC call:Or go back to any block by 'dev_setHead':