9
votes
How to test cross-contract Ink! contracts
I'm posting a link to the discussion on GitHub: https://github.com/paritytech/ink/issues/1125.
AFAIK there is currently only the the possibility to do this with the redspot tool mentioned in the issue....
7
votes
Writing a test to call staking.chill() so as to remove Charlie as a Validator
No, the issue here is not related to invulnerables.
Invulnerables are only immune to getting slashed when an offence occurs.
Instead, the issue here is probably that you need to wait a full session ...
5
votes
How to integration-test a parachain
polkadot-launch is being deprecated in favor of zombienet.
You can find some examples on polkadot and cumulus, although some might be depending on Parity internal infrastructure and you won't ...
5
votes
How can I configure genesis state for my pallet's tests without hardcoding it?
You can configure the new_test_ext function however you like. In this case, you can make it take the parameters you'll want to use to modify your genesis state and then just pass values into your ...
5
votes
Accepted
Potential storage issue with try-runtime tool
There is no magic involved here. The key of the storage location is
Twox128(Prefix::pallet_prefix()) ++ Twox128(Prefix::STORAGE_PREFIX)
(explained here)
In your case the old storage hash and the new ...
5
votes
Accepted
construct_runtime_integrity_test failing
Good question!
The reason for this is the recent introduction of a new component in the Weight struct; the proof size.
This makes it mandatory to slightly adjust your definition of BlockWeights to ...
5
votes
Accepted
Why is the AccountId of a contract always 1 when unit testing?
Off-chain environment used in the unit testing is just a mock environment so there aren't any dedicated mapping created b/w addresses & contracts. Latter is just an object with some associated ...
4
votes
Accepted
Problem running assert_last_event in tests.rs
I believe the problem here is small and easy to miss.
Substrate chains do not emit events when the block number is 0. This is to avoid hundreds or even thousands of events being generated in the ...
4
votes
testing pallet with ensure_root
If this is for tests, have you tried using:
RuntimeOrigin::root()
Example here:
assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 1_000, 0));
https://github.com/paritytech/substrate/blob/...
3
votes
Accepted
Testing transaction fee movements
Thanks to @kianenigma and @shawn-tabrizi pointing me in the right direction, I realized that to do what I'm looking for I just need to call pre_dispatch and post_dispatch manually on the call.
In ...
3
votes
Accepted
How can I use `Balances::deposit_creating` in pallet tests?
First of all, deposit_creating is not a function exposed by Balance, but a function from the Currency trait.
So, to use it, first thing to do is to use the Balance pallet as the Currency trait in your ...
3
votes
Accepted
How can I access custom pallet Event data in a test?
Here is a working example of a test using the pallet-template from the substrate-node-template:
#[test]
fn stackexchange_question() {
new_test_ext().execute_with(|| {
// To emit events, we ...
3
votes
How can I test a parachain against a production relay chain's live state and configuration?
Fork off Relay Chain
This script allows bootstrapping a new substrate chain with the current state of a live chain. Using this, you can create a fork of Polkadot, Kusama and other substrate chain for ...
3
votes
Stress test a substrated based blockchain
There is sTPS repo contains some functions to spin up a multi-node network and stress-test it.
Unfortunately there are some non-deterministic bugs with how we are using Zombienet which does not allow ...
3
votes
Accepted
Testing Custom RPC with a Mock Runtime API
tldr: used the sp_api::mock_impl_runtime_apis! macro to mock the implementation.
Example is in this PR along with a lot of other changes:
https://github.com/LibertyDSNP/frequency/pull/490
See pallets/...
3
votes
Accepted
How to use the follow-chain subcommand in try-runtime?
Clone repo:
git clone https://github.com/paritytech/substrate
cd substrate
Run a dev chain locally. This is the chain that I want to "follow":
cargo b -r
cp target/release/node-template .
./...
3
votes
Accepted
How we can do the integration testing of a substrate project?
There are few tool which might be useful,
subxt - a library to submit extrinsics to a substrate node via RPC. (from its readme)
XCM emulator to test XCM configurations - original location, fork in ...
3
votes
Accepted
How to stub ink! contract environment to produce fake values for use in tests?
There is advance_block function in the ink::env::test and
you can do something like this:
fn advance_n_blocks(n: u32) {
for _ in 0..n {
advance_block();
}
}
fn advance_block() {
...
3
votes
Testing benchmarks with V2
You can simply use the impl_benchmark_test_suite macro which generates those tests for your benchmarks (detailed explanation).
2
votes
Accepted
Client testing - Runtime trait implementation approach
I think you are missing a bound C: ProvideRuntimeApi<B> on your start_module_gadget function.
2
votes
Accepted
How to assert deposited event in pallet call?
The FRAME System pallet has two helper functions for this:
/// Assert the given `event` exists.
#[cfg(any(feature = "std", feature = "runtime-benchmarks", test))]
pub fn ...
2
votes
Accepted
What is integrity_test?
The integrity test function is some logic that you can place in your pallet, that will then be executed in the construct_runtime! in your final runtime configuration.
Note that this function does not ...
2
votes
Stress test a substrated based blockchain
I have come across this https://socket.dev/npm/package/artillery-engine-substrate but I have not used it yet unfortunately.
2
votes
Accepted
Configure chain parameters (epoch/era/bondig/etc) for dev node?
cargo build --release --features fast-runtime
2
votes
Accepted
Transactional macro deprecated but still required
I believe that this is is just an artifact of the original implementation detail of the storage layer, which shows up in tests.
This PR: https://github.com/paritytech/substrate/pull/11927
Should solve ...
2
votes
Accepted
Best way to provide mock data for cross-contract calls
Testing cross-contract calls is the biggest missing piece for developer experience in ink! 3.0 right now.
There are ways to do it currently, but none of them is ideal. The concept of using feature ...
2
votes
Accepted
How to test a pallet that depends on the staking pallet?
You will need to add the Staking Pallet into your mock construct_runtime!:
From frame/session/benchmarking/src/mock.rs:
frame_support::construct_runtime!(
pub enum Test where
Block = Block,...
2
votes
Accepted
Stress test a substrated based blockchain
You can benchmark your chain:
https://docs.substrate.io/test/benchmark/#benchmarking-tools
Take a look at these transfer benchmarks:
https://github.com/paritytech/substrate/blob/...
2
votes
Accepted
Constructor not found when testing smart contract
A solution to the problem was to not have the tests in a seperate test module.
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(min_specialization)]
#[openbrush::contract]
pub mod name ...
2
votes
Accepted
Test hooks weights using dbWeights
You are very close, but the sp_weights is not needed.
I think in your case the Rust compiler is just being annoying.
You can write it more explicit like this to help the type-interference understand ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
testing × 91ink × 16
pallet × 14
smart-contract × 10
unit-tests × 9
mock × 8
storage × 5
runtime × 4
substrate-node-template × 4
rust × 4
e2e × 4
substrate-node × 3
parachain × 3
polkadot-js × 3
weight × 3
rpc × 3
events × 3
try-runtime × 3
benchmark × 3
test-network × 3
polkadot × 2
balances × 2
xcm × 2
extrinsic × 2
database × 2