Skip to content

Commit

Permalink
chore: merge branch 'main' into alex/complete-unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexD10S committed Apr 17, 2024
2 parents 9c6aac1 + ede976d commit 9cfd1a0
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 150 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,32 @@ git2 = "0.18"
tempfile = "3.8"
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
url = { version = "2.5"}

# contracts
subxt-signer = { version = "0.34.0", features = ["subxt", "sr25519"]}
subxt = { version = "0.34.0" }
ink_env = { version = "5.0.0-rc.2" }
sp-core = { version = "30.0.0"}
sp-weights = { version = "29.0.0" }
contract-build = { version = "4.0.2" }
contract-extrinsics = { version = "4.0.0-rc.3"}

# parachains
askama = "0.12"
regex="1.5.4"
walkdir = "2.4"
indexmap = { version = "2.2"}
toml_edit = { version = "0.22" }
symlink = { version = "0.1" }
reqwest = { version = "0.11" }
serde_json = { version = "1.0"}
serde = { version = "1.0", features = ["derive"] }
zombienet-sdk = { git = "https://github.com/r0gue-io/zombienet-sdk", branch = "pop", version = "0.1.0-alpha.1"}
zombienet-support = { git = "https://github.com/r0gue-io/zombienet-sdk", branch = "pop", version = "0.1.0-alpha.1" }

# pop-cli
clap = { version = "4.4", features = ["derive"] }
cliclack = "0.1"
console = "0.15"
strum = "0.26"
strum_macros = "0.26"
93 changes: 46 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ cargo install --locked --git https://github.com/r0gue-io/pop-cli

### Parachains

Use `pop` to generate a new parachain from a template:
Use `pop` to create a new Parachain project:

```sh
# Create a minimal parachain
Expand All @@ -29,7 +29,7 @@ pop new parachain my-app cpt
pop new parachain my-app fpt
```

Use `pop` to build your parachain.
Use `pop` to build your Parachain:

```sh
# Build your parachain
Expand Down Expand Up @@ -57,50 +57,49 @@ There's also the shorter version:
pop new parachain my-app -s DOT -d 6 -i 1_000_000_000
```

To create a new pallet, simply `pop new pallet`. And that's it. You will have a new `pallet-template` ready for hacking.
To customize the new pallet you can follow these options:
Finally, to build your Parachain:

```sh
# create a pallet with name `pallet-awesome` in the current working directory
pop new pallet pallet-awesome
# or with options
pop new pallet pallet-awesome --authors Me --description "This pallet oozes awesomeness" --path my_app/pallets
cd my-app
pop build parachain --release
```

Finally, you would need to build and run it.
## Spawn Network using Zombienet

```sh
cd my-app
pop build parachain --release
You can spawn a local network using [zombienet](https://github.com/paritytech/zombienet-sdk) as follows:

```shell
pop up parachain -f ./tests/zombienet.toml -p https://github.com/r0gue-io/pop-node
```

For running any parachain, we recommend using [zombienet](https://github.com/paritytech/zombienet).
See below for more information about using `pop up parachain` to help you with this.
> :information_source: Pop CLI will automatically source the necessary polkadot binaries. Currently, these will be built
> if on a non-linux system.

### Contracts

Use `pop` to create a smart contract:
Use `pop` to create a new Smart Contract project:

```sh
# Create a minimal smart contract
# Create a minimal Smart Contract
pop new contract my_contract
```

Test the smart contract:
Test the Smart Contract:

```sh
# Test an existing smart contract
# Test an existing Smart Contract
pop test contract -p ./my_contract
```

Build the smart contract:
Build the Smart Contract:

```sh
# Build an existing smart contract
# Build an existing Smart Contract
pop build contract -p ./my_contract
```

To deploy a contract you need your chain running. For testing purposes one option is to
To deploy a Smart Contract you need a chain running. For testing purposes one option is to
run [substrate-contracts-node](https://github.com/paritytech/substrate-contracts-node):

```sh
Expand All @@ -110,7 +109,7 @@ substrate-contracts-node

> :information_source: We plan to automate this in the future.
Deploy and instantiate the smart contract:
Deploy and instantiate the Smart Contract:

```sh
pop up contract -p ./my_contract --constructor new --args "false" --suri //Alice
Expand All @@ -136,23 +135,23 @@ check [cargo-contract documentation](https://github.com/paritytech/cargo-contrac
Interacting with the Smart Contract:

1. Read-only Operations: For operations that only require reading from the blockchain state. This approach does not
require to submit an extrinsic (skip the flag `x/--execute`).
require to submit an extrinsic.
Example using the get() message:

```sh
pop call contract -p ./my_contract --contract $INSTANTIATED_CONTRACT_ADDRESS --message get --suri //Alice
```

2. State-modifying Operations: For operations that change a storage value, thus altering the blockchain state. Include
the `x/--execute` flag to submit an extrinsic on-chain.
the `x / --execute` flag to submit an extrinsic on-chain.

Example executing the `flip()` message:

```sh
pop call contract -p ./my_contract --contract $INSTANTIATED_CONTRACT_ADDRESS --message flip --suri //Alice -x
```

### E2E testing
## E2E testing

For end-to-end testing you will need to have a Substrate node with `pallet contracts`.
You do not need to run it in the background since the node is started for each test independently.
Expand All @@ -168,13 +167,25 @@ If you want to run any other node with `pallet-contracts` you need to change `CO
export CONTRACTS_NODE="YOUR_CONTRACTS_NODE_PATH"
```

Run e2e testing on the smart contract:
Run e2e testing on the Smart Contract:

```sh
# Run e2e tests for an existing smart contract
pop test contract -p ./my_contract --features e2e-tests
```

### Pallets

To create a new Pallet, simply run `pop new pallet`. You will have a new pallet ready for hacking.
To customize the new Pallet you can follow these options:

```sh
# create a pallet with name `pallet-awesome` in the current working directory
pop new pallet pallet-awesome
# or with options
pop new pallet pallet-awesome --authors Me --description "This pallet oozes awesomeness" --path my_app/pallets
```

## Building Pop CLI locally

Build the tool locally with all the features:
Expand All @@ -183,30 +194,18 @@ Build the tool locally with all the features:
cargo build --all-features
```

Build the tool only for parachain functionality:
Build the tool only for Parachain functionality:

```sh
cargo build --features parachain
```

Build the tool only for contracts functionality:
Build the tool only for Smart Contracts functionality:

```sh
cargo build --features contract
```

## Spawn Network using Zombienet

You can spawn a local network using [zombienet](https://github.com/paritytech/zombienet-sdk) as follows:

```shell
pop up parachain -f ./tests/zombienet.toml -p https://github.com/r0gue-io/pop-node
```

> :information_source: Pop CLI will automatically source the necessary polkadot binaries. Currently, these will be built
> if on a non-linux system.

## Testing Pop CLI

To test the tool locally.
Expand All @@ -217,29 +216,29 @@ Run the unit tests:
cargo test
```

Due to the time it can take to build a test or a contract some tests has been separate to the normal testing flow.
Due to the time it can take to build a Parachain or a Smart Contract, some tests have been separated from the normal testing flow.

To run the unit tests that involves building a contract:
To run the unit tests that involves building a Smart Contract:

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

To run the unit tests that involves building a parachain:
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:
Then we have some tests that check all the flows are correct:

Run the e2e tests for contracts functionality:
Run the e2e tests for Smart Contracts functionality:

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

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

```sh
cargo test --features e2e_parachain
Expand All @@ -255,4 +254,4 @@ cargo test --all-features
Pop CLI would not be possible without these awesome crates!

- Local network deployment powered by [zombienet-sdk](https://github.com/paritytech/zombienet-sdk)
- [cargo contract](https://github.com/paritytech/cargo-contract) a setup and deployment tool for developing Wasm based smart contracts via ink!
- [cargo contract](https://github.com/paritytech/cargo-contract) a setup and deployment tool for developing Wasm based Smart Contracts via ink!
22 changes: 11 additions & 11 deletions crates/pop-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ url.workspace = true
tokio.workspace = true

# pop-cli
clap = { version = "4.4", features = ["derive"] }
cliclack = "0.1"
console = "0.15"
strum = "0.26"
strum_macros = "0.26"
clap.workspace = true
cliclack.workspace = true
console.workspace = true
strum.workspace = true
strum_macros.workspace = true

# contracts
pop-contracts = { version = "0.1.0", path = "../pop-contracts", optional = true}
sp-core = { version = "30.0.0", optional = true }
sp-weights = { version = "29.0.0", optional = true }
pop-contracts = { path = "../pop-contracts", optional = true}
sp-core = { workspace = true, optional = true }
sp-weights = { workspace = true, optional = true }

# parachains
pop-parachains = { version = "0.1.0", path = "../pop-parachains", optional = true }
dirs = { version = "5.0", optional = true }
git2.workspace = true
pop-parachains = { path = "../pop-parachains", optional = true }
dirs = { version = "5.0", optional = true}
git2.workspace = true

[dev-dependencies]
assert_cmd = "2.0.14"
Expand Down
Loading

0 comments on commit 9cfd1a0

Please sign in to comment.