Questions tagged [testing]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
2 answers
31 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() { ...
Bruno's user avatar
  • 8,130
0 votes
0 answers
9 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 ...
Yrefef's user avatar
  • 73
0 votes
1 answer
15 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 ...
Tomasz Waszczyk's user avatar
1 vote
1 answer
53 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 ...
Xavier's user avatar
  • 395
1 vote
0 answers
56 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 ...
ALeSD's user avatar
  • 499
1 vote
0 answers
18 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-...
ryvers's user avatar
  • 11
1 vote
0 answers
22 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&...
UPENDRA SINGH's user avatar
1 vote
1 answer
48 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 ...
Gonzalo Cerro's user avatar
2 votes
2 answers
40 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>::...
Amiya Behera's user avatar
3 votes
0 answers
57 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, ...
Wolf's user avatar
  • 61
5 votes
1 answer
36 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 ...
chexware's user avatar
  • 325
4 votes
1 answer
43 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 ...
Luke Schoen's user avatar
  • 2,292
3 votes
1 answer
39 views

A function returning Result::Error will not revert the execution

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 ...
george huang's user avatar
5 votes
1 answer
30 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 ...
Tomasz Waszczyk's user avatar
3 votes
1 answer
41 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: ...
Tomasz Waszczyk's user avatar
4 votes
1 answer
55 views

How we can do the integration testing of a substrate project?

How we can do the integration testing of the substrate application?
Pankaj's user avatar
  • 1,896
5 votes
1 answer
97 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 ...
goastler's user avatar
  • 549
3 votes
1 answer
47 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 ...
goastler's user avatar
  • 549
1 vote
1 answer
41 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/ ...
Andrew's user avatar
  • 11
3 votes
0 answers
73 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,...
Syed Kamran's user avatar
1 vote
1 answer
52 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 ...
Bruno's user avatar
  • 8,130
2 votes
4 answers
98 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 ...
blairmunroakusa's user avatar
1 vote
1 answer
41 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, ...
Gonzalo Cerro's user avatar
0 votes
2 answers
38 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 ...
Bruno's user avatar
  • 8,130
0 votes
0 answers
27 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 ...
wcl's user avatar
  • 41
2 votes
0 answers
74 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 '...
David Searle's user avatar
0 votes
1 answer
25 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 ...
Nakul Amate's user avatar
0 votes
1 answer
64 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>, ...
Burak's user avatar
  • 893
0 votes
1 answer
32 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 ...
Chralt's user avatar
  • 503
1 vote
1 answer
68 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/...
Syed Kamran's user avatar
2 votes
2 answers
112 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 ...
amab8901's user avatar
2 votes
2 answers
312 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 ...
amab8901's user avatar
1 vote
1 answer
42 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 ...
brenzi's user avatar
  • 503
1 vote
1 answer
52 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 ...
Nate Armstrong's user avatar
5 votes
1 answer
202 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 ...
Mathis Wellmann's user avatar
0 votes
1 answer
33 views

How to set Alice as author in the mock.rs for testing?

I want to test my pallet that get digest info to collect the author of the current block. So, is it possible to set, for example, Alice as a block author in the mock.rs so I can test it? I set up the ...
viac92's user avatar
  • 87
1 vote
1 answer
30 views

How do you hide test accounts when they are not endowed?

Our chain spec does not endow any of the test accounts yet we are still seeing them shown (with zero balances) in the Polkadot UI. How do we hide them?
lovelikelando's user avatar
3 votes
1 answer
74 views

Potential storage issue with try-runtime tool

Hey guys I'm seeing a weird thing with the following migration code: pub struct SomeMigration; impl OnRuntimeUpgrade for SomeMigration { fn on_runtime_upgrade() -> Weight { let ...
Georgi Zlatarev's user avatar
3 votes
1 answer
102 views

Testing Custom RPC with a Mock Runtime API

I'm trying to test a Custom RPC. Let's make it a simple pass through. p_api::decl_runtime_apis! { pub trait SimpleApi<AccountId> where AccountId: Codec, { fn is_true() -&...
Wil W's user avatar
  • 433
1 vote
1 answer
83 views

How to use an outer mock inside `impl_benchmark_test_suite`?

Hey valuable Substrate pros, do you know a way to use impl_benchmark_test_suite inside another crate like the runtime? I have multiple pallets. There are no mocks inside these pallets. There is only ...
Chralt's user avatar
  • 503
0 votes
1 answer
98 views

How to get access to pallet storage from tests

I have approvals map in my pallet So when i try to get value from my storage, I'm getting this error So how to properly use pallet storage in tests?
Nikita Chernega's user avatar
1 vote
1 answer
76 views

Is it possible to test/mock the rpc calls in substrate?

I was trying to mock the rpc calls in substrate, but if there's any example for that then I guess it would help better.
kroos47's user avatar
  • 59
4 votes
1 answer
86 views

Test hooks weights using dbWeights

Imagine I have a on_initialize hook like this: impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> { fn on_initialize(n: T::BlockNumber) -> Weight { ...
Nathan's user avatar
  • 464
1 vote
1 answer
35 views

Constructor not found when testing smart contract

I am implementing a project using the directory structure proposed by openbrush. The contract compiles without a problem, but when it comes to testing I run into the following error: error[E0599]: no ...
rajohs's user avatar
  • 491
0 votes
2 answers
58 views

How do I mock `BalanceOf` for testing staking?

I'm trying to learn how to use the staking pallet in a game I'm building as a way to learn substrate, linked here, and I'd like to implement staking an amount when challenging another player. However, ...
stonecharioteer's user avatar
2 votes
3 answers
264 views

Stress test a substrated based blockchain

Are there any tools/script to stress a substrate bases blockchain? Generating transfers between accounts should be Ok. I think I saw one a few months ago but I can't find it :-( Thanks very much. ...
Fernando Ruscitti's user avatar
0 votes
1 answer
76 views

Building precompile mock results in error[E0277]: the trait bound `currencies::MultiCurrencyPrecompile<TestRuntime>: Precompile` is not satisfied

I am currently implementing a mock for our EVM precompiles but ran into the following error when building the tests error[E0277]: the trait bound `currencies::MultiCurrencyPrecompile<...
chexware's user avatar
  • 325
2 votes
2 answers
114 views

Testing transaction fee movements

I am attempting to build some tests that initiate and validate transaction fee movements. The problem is that I seem unable to initiate transaction fees in a mock runtime at all. I suspect I am ...
K. Lane's user avatar
  • 41
1 vote
1 answer
74 views

How to persist TestExternalities via impl_benchmark_test_suite testing?

I set up a state via impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default().build_storage::<TestRuntime>().unwrap(); let mut ext =...
ohboy21's user avatar
  • 125
1 vote
1 answer
52 views

How to rerun test with TRYBUILD=overwrite?

I want to rerun a test inside frame-support and overwrite the .stderr file with the actual error. The CI checks give me the instruction to rerun the test with the environment variable TRYBUILD=...
Szegoo's user avatar
  • 603