Skip to content

Commit

Permalink
test: pop up parachain (#86)
Browse files Browse the repository at this point in the history
* chore: install mockfall

* test: unit test for relay_chain function

* test: missing relaychain in zombienet config

* test: zombienet::new and aux functions

* test: missing_binaries function

* test: process functions

* test: spawn

* chore: remove mockall dependency

* test: integration test for pop up parachain

* chore: cargo fmt

* fix: manual format to fix CI

* fix: make sure tempdir is close after each test

* refactor: generate toml files for testing

* refactor: kill process without adding external dependencies

* reactor: fix feedback

* fix: fmt

* chore: pr feedback

* fix: ci tests

* refactor: remove close tempfile

* chore: modify seconds to wait

* set default value to Yes for confirm

* cargo fmt

* fix: up parachain test

* chore: adapt test features to new format

* fix: remove e2e test that goes throught all the process

---------

Co-authored-by: Bruno Galvao <[email protected]>
  • Loading branch information
AlexD10S and brunopgalvao authored Apr 9, 2024
1 parent eca2d30 commit 07c8414
Show file tree
Hide file tree
Showing 5 changed files with 427 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ parachain = [
"dep:zombienet-support"
]
e2e_parachain = []
unit_parachain = []

16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,29 @@ Run the unit tests:
cargo test
```

Run only contracts unit tests:
Due to the time it can take to build a test or a contract some tests has been separate to the normal testing flow.

To run the unit tests that involves building a contract:

```sh
cargo test --features unit_contract
```

Run the contracts e2e tests:
To run the unit tests that involves building a parachain:

```sh
cargo test --features unit_parachain
```

Then we have some tests that check all the flow is correct:

Run the e2e tests for contracts functionality:

```sh
cargo test --features e2e_contract
```

Run the parachain e2e tests:
Run the e2e tests for parachain functionality:

```sh
cargo test --features e2e_parachain
Expand Down
12 changes: 9 additions & 3 deletions src/commands/up/parachain.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use crate::style::{style, Theme};
use crate::{
parachains::zombienet::Zombienet,
style::{style, Theme},
};
use clap::Args;
use cliclack::{clear_screen, confirm, intro, log, outro, outro_cancel, set_theme};
use console::{Emoji, Style};
Expand Down Expand Up @@ -31,7 +34,7 @@ impl ZombienetCommand {
set_theme(Theme);
// Parse arguments
let cache = crate::cache()?;
let mut zombienet = crate::parachains::zombienet::Zombienet::new(
let mut zombienet = Zombienet::new(
cache.clone(),
&self.file,
self.relay_chain.as_ref(),
Expand All @@ -46,7 +49,10 @@ impl ZombienetCommand {
"The following missing binaries are required: {}",
missing.iter().map(|b| b.name.as_str()).collect::<Vec<_>>().join(", ")
))?;
if !confirm("Would you like to source them automatically now?").interact()? {
if !confirm("Would you like to source them automatically now?")
.initial_value(true)
.interact()?
{
outro_cancel("Cannot deploy parachain to local network until all required binaries are available.")?;
return Ok(());
}
Expand Down
2 changes: 2 additions & 0 deletions src/engines/contract_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ mod tests {
// Verify that the generated Cargo.toml file contains the expected content
fs::read_to_string(temp_dir.path().join("test_contract/Cargo.toml"))
.expect("Could not read file");

Ok(())
}

Expand Down Expand Up @@ -243,6 +244,7 @@ mod tests {
let result = test_smart_contract(&Some(temp_contract_dir.path().join("test_contract")));

assert!(result.is_ok(), "Result should be Ok");

Ok(())
}
}
Loading

0 comments on commit 07c8414

Please sign in to comment.