Questions tagged [testing]
The testing tag has no usage guidance.
91
questions
1
vote
0
answers
2
views
How to write test cases to validate if fees is paid?
I'm working on writing test cases for an extrinsic that conditionally bypasses transaction fees based on specific conditions. I need to verify whether the fees are paid or not for a given call. My ...
0
votes
1
answer
20
views
Creation of a smart contract in contracts pallet
I need to create a smart contract using contracts pallet. I look at the source code of the contracts pallet and see:
pub fn upload_code(
origin: OriginFor<T>,
code: Vec<u8>,
...
0
votes
0
answers
23
views
How to execute transactions from Root within a "fork locally" chain within Polkadot.js UI?
I'm trying to test XCM using Chopsticks but running into issues. One workaround I'm trying is to use Polkadot.js UI's "Fork Locally" option. I know several accounts are built in (Alice, Bob, ...
0
votes
1
answer
38
views
Zombienet js script weird behaviour
I got the latest binary of polkadot(v1.10.0) by running zombienet setup and set up the following test files:
0001-network.toml
[settings]
timeout = 1000
[relaychain]
default_image = "{{...
0
votes
0
answers
55
views
Bittensor Subtensor Chain
Does anyone know how to run a public subtensor node and synchronize with Bittensor network on nakamoto instead of the current finney ? There are some nodes currently running on nakamoto chain.
I am ...
0
votes
0
answers
13
views
Testing pallet_democracy proposal enactment
I am testing a pallet using the democracy pallet, and I am struggling with the enactment step. First of all, the proposal is correctly enacted when using the pallet in polkadot.js: the problem occurs ...
0
votes
1
answer
51
views
Issue building substrate on linux
I'm trying to run the substrate tests with cargo test --workspace but seeing the following errors on linux (it works on a mac):
error: proc macro panicked
--> substrate/frame/support/src/lib.rs:...
0
votes
2
answers
61
views
Wrong Proposal Weight in collective pallet tests
I have a pallet using the propose extrinsic of the collective pallet. one of the parameter of this extrinsic is length_bound which I define as follows:
let proposal_len:u32 = proposal.using_encoded(|p|...
0
votes
1
answer
39
views
None of the tests of pallet-template is running
When I run cargo test, it shows in console that:
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
for node-template, pallet-template and ...
0
votes
0
answers
23
views
How can I manually build message in ink-e2e test?
I would like to manually build a message and send it in my ink-e2e test.
I'd like to construct and pass a selector and call data by myself.
How can I do it using ink 5.0.0-rc and ink-e2e 5.0.0-rc?
0
votes
0
answers
11
views
How to call function with the same name but from different trait inside ink-e2e-test
Let's say I have the following impl of my Contract:
impl Contract{
#[ink(message)]
pub fn my_fun(&self);
}
impl MyTrait1 for Contract {
#[ink(message)]
pub fn my_fun(&self);
}
...
0
votes
0
answers
38
views
Ink e2e tests with custom environment
I have an ink! contract that uses a custom environment that contains custom chain extensions.
I am trying to write e2e tests for this contract however there is a problem.
Instantiate the contract how ...
0
votes
1
answer
79
views
Build fast-runtime for kusama on PolkadotSDK
Im quite a newbie in the new polkadot-sdk, can sm1 guide me how can I build a fast-runtime kusama polkadot image?
When I try to run a polkadot build with fast-runtime with kusama-local spec it tells:
...
1
vote
1
answer
69
views
Differences between xcm-simulator and xcm-emulator
I'm trying to have a deep understanding of the differences between xcm-simulator and xcm-emulator.
I understand that xcm-emulator is "less mocked" than xcm-simulator. But because when using ...
1
vote
0
answers
37
views
Testing & pallet_collective
I have a pallet that is using the pallet_collective to trigger votes for roles affectations requests. everything works fine in the polkadot.js interface, but testing is not going as expected.
in the ...
1
vote
2
answers
249
views
How to print / output from within async tokio test
I am writing a new test and when I run this code, the println's do not output in the terminal.
#[tokio::test]
async fn can_fetch_child_keys() {
if std::option_env!("TEST_WS").is_none() {
...
0
votes
0
answers
15
views
How to test smart contract timestamp dependent behavior?
how can I test block_timestamp-dependent smart contract behavior?
The substrate contact node doesn't allow block_timestamp manipulations.
For context, in the EVM ecosystem, one can use hardhat helpers ...
0
votes
1
answer
21
views
Creation of account ids
A brief context: I want to deliver the test.
The exact context: Creation of account_id's (first point in an outline).
Question: Do I correctly create account_id in the context of my task. Should I ...
2
votes
1
answer
80
views
Testing benchmarks with V2
Im writing benchmarks for a pallet using benchmarking version 2. And it seems I cant call Pallet::<Test>::test_benchmarks_"extrinsic_name" inside of a test anymore.
Is it no longer ...
1
vote
0
answers
62
views
Automating Sync Tests for a Substrate Node: Best Approaches?
I am working on a Substrate node that needs to sync with specific live networks. My goal is to ensure that the node is able to initiate and maintain synchronization with these networks, and I would ...
1
vote
0
answers
21
views
e2e-tests We should find port before reader ends - ink! 4.2.1, rust 1.69, cargo contracts 3.0.1
I have the same problem and error message as described here: e2e-tests "We should find a port before the reader ends" for rust = 1.69 and cargo-contract-contract 3.0.1-unknown-x86_64-apple-...
1
vote
0
answers
25
views
How to resolve "mismatched types" error while ink_e2e test : expected String, found Vec<u8>
I am working with ink_e2e testing framework in ink smart contract, and I have encountered an error message that's a bit confusing. The error says: mismatched types - expected String, found Vec<u8&...
1
vote
1
answer
51
views
Simulate block finalization error
I would like to simulate how our parachain reacts to events like,
A collator produces a block that is not accepted by other collators in that parachain. Aka a malicious collator.
The relay chain ...
2
votes
2
answers
53
views
How to get Error from different pallet in test?
In tests we use following statement to check error:
assert_noop!(
ProfileValidation::add_citizen(RuntimeOrigin::signed(1), content.clone()),
Error::<Test>::...
3
votes
1
answer
65
views
Can we define ink_e2e tests outside of contracts module?
devs. I am writing the e2e tests for my smart contracts using ink_e2e
In contracts, I define the e2e-tests like this.
#[openbrush::contract]
pub mod controller {
...
#[cfg(all(test, ...
5
votes
1
answer
66
views
__construct_runtime_integrity_test fails after upgrading to polkadot 0.9.38
After upgrading our chain to polkadot version 0.9.38 and run SKIP_WASM_BUILD= cargo test --all I get the following test error
'__construct_runtime_integrity_test::runtime_integrity_tests' panicked at ...
4
votes
1
answer
50
views
How to stub ink! contract environment to produce fake values for use in tests?
In an ink! contract I need to use Self.env().block_number() to get the current block number to compare it with a block_number_guessed value that I provide when instantiating the contract and check ...
3
votes
1
answer
42
views
A function returning Result::Error will not revert the execution [closed]
I used the example Flipper, and changed the code like this:
#[ink(message)]
pub fn flip(&mut self) -> Result<(), Error> {
self.value = !self.value;
return ...
5
votes
1
answer
35
views
The package `` depends on `ink_env`, with features: `ink-experimental-engine` but `ink_env` does not have these features
I want to write tests and found the question that potentially soles my problem, but made exactly all what is recommended but still have the same issue.
I have added on top of my module with tests ...
3
votes
1
answer
49
views
No caller has been set
I write tests for my smart contract and got this error:
no caller has been set
The error comes from: ink_engine-4.2.0/src/ext.rs:325:14. In function that I want to write tests I have following line:
...
4
votes
1
answer
67
views
How we can do the integration testing of a substrate project?
How we can do the integration testing of the substrate application?
5
votes
1
answer
117
views
Why is the AccountId of a contract always 1 when unit testing?
I've been building unit tests in ink and have come across a strange issue. If I instantiate a contract multiple times, the account id is always the same. I thought the account id is the address of the ...
3
votes
1
answer
59
views
How to obtain code_hash, contract address, etc, when unit testing an ink smart contract?
I've been unit testing an ink smart contract by calling the constructor and testing various methods on the smart contract.
However, I now need to obtain the account of the contract in order to set its ...
1
vote
1
answer
61
views
How to stub win.injectedWeb3 for testing dApp with Cypress?
I'm looking for guidance on how to best stub the win.injectedWeb3 object that's usually created by Polkadot{.js}. This is so that I can write some automated tests for a dApp frontend in Cypress w/ ...
3
votes
0
answers
84
views
Steps to import a parachain running in a production environment to test environment?
I am using export-state to copy a parachain running in production environment to development with all the configuration and blocks data. I am following these steps. Can any one please review the steps,...
2
votes
1
answer
64
views
How to use the follow-chain subcommand in try-runtime?
In the try-runtime documentation, there is note of a follow-chain subcommand which follows the given chain’s finalized blocks and apply all of its extrinsics.
There are also some examples here.
I ...
2
votes
4
answers
108
views
ink-e2e: Metadata artifacts not generated when importing crate
Context:
I am trying to detach end-to-end tests from my main contract lib.rs. I created a new module in tests_e2e.rs.
I import the module in main contract like so:
lib.rs...vvv
#[cfg(all(test, feature ...
1
vote
1
answer
47
views
How to run "paras" extrinsics on local setups
I would like to test a few scenarios about relaychain council / sudo can update our parachain code in case of emergency.
I searched over the web, and try to use "paras" module to do such, ...
0
votes
2
answers
41
views
How to access StorageValue without getter function in tests?
I have the following StorageValue:
#[pallet::storage]
#[pallet::getter(fn something)]
pub type Something<T> = StorageValue<_, u32>;
With the getter function I can access it like this in ...
0
votes
0
answers
28
views
What is the account code in genesis account?
What does account code use for? No idea why are 0xff (INVALID) and 0x00 (STOP)...
https://github.com/paritytech/frontier/blob/08dfe8986e3f92ce213244c438eb9178653fce59/primitives/evm/src/lib.rs#L87
...
2
votes
0
answers
86
views
Fuzzing Polkadot produces Invalid Signature after chaos is injected
I'm using Polkadot version 0.9.37-08b1c09ca46, across 4 Nodes - Alice, Bob, Charlie, Dave, in a local testnet environment. I have a period of network chaos applied, and then moments of stabilized '...
0
votes
1
answer
33
views
construct_runtime macro panics in a mock environment while it builds in normal runtime [closed]
Trying to create a mock environment for testing a pallet, but getting an error msg failed to resolve: could not find tt_error_token in the crate root whenever trying to add my pallet in the mock ...
0
votes
1
answer
73
views
How do I create Hash in tests?
I have a function that creates hash from AccountId's.
#[pallet::call_index(2)]
#[pallet::weight(10_000 + T::DbWeight::get().writes(1).ref_time())]
pub fn connection_request(origin: OriginFor<T>, ...
0
votes
1
answer
44
views
How is it possible to avoid a mock runtime and use the actual runtime for testing?
I would like to avoid the most pallet config initialisation and just want to use the actual runtime configuration for the (unit) tests. This would simplify my mock process a lot. The only thing that ...
1
vote
1
answer
90
views
Integration tests for custom pallets
There is a very nice and structured way of writing unit test against a pallet. One can find a lot of examples of unit tests as well.
I will be thankful if any one can point me to some resources/...
2
votes
2
answers
139
views
Polkadot - tests fail out-of-the-box
How can I make the tests pass?
Steps to reproduce:
git clone https://github.com/paritytech/polkadot
cd polkadot
cargo build
cargo test
$ cargo test
⚡ Found 3 strongly connected components which ...
2
votes
2
answers
354
views
Computer crashing on `cargo test`
I use archlinux on x64_64 CPU architecture. Steps to reproduce:
git clone https://github.com/paritytech/substrate
cd substrate
cargo test
it runs up until 1600/1706. And I did it carefully with ...
1
vote
1
answer
52
views
how to test for storage leaks in pallets
Storage leaks in runtimes can be very damaging and cleaning up with a runtime update migration is non-trivial. I'd like to ensure the absence of storage leaks already in unit testing.
My strategy ...
1
vote
1
answer
63
views
Best way to automate extrinsic submissions for testing
I am developing a chain in substrate, and am trying to find the best way to run integration tests against certain sets of extrinsic submissions when the network is running in development mode. It's ...
5
votes
1
answer
253
views
construct_runtime_integrity_test failing
After bumping my substrate branch to 0.9.31 along some other changes,
I came across a test case failure which I have a hard time getting to the bottom of.
The node compiles and runs just fine after ...