Skip to content

Commit

Permalink
A0-3409 membrane ink tests (#23)
Browse files Browse the repository at this point in the history
* Simple unit tests + e2e setup

* Use substrate-contract-node

* Move e2e out of a contract

* A few more send_request test cases

* Better error checking

* Add github pipeline for ink tests

* Faster ink test pipeline

* Change workflow labels

* Add docker-compose installation step

* Fix malformed workflow file

* Test

* Bootstrap before running contracts node

* Some tests for receive_request

* Use psp22 from crates

* Make set_owner a message + set initial caller in unit tests

* Remove leftover make instruction + rename call methods in ink_e2e tests

* More explicit variable naming

* Turns some frequently used values into consts

* ink_e2e tests: add generic funtion for message calling

* Split adding pair test into two + more values as consts

* Asserts only on things we test + change test return types

* Make depoyments depend on success of test workflow

* Membrane constructor returns a Result

* Check if pair is supported before transferring tokens

* is_guardian message

* Change is_guardian description and return type

* Comment change
  • Loading branch information
krzysztofziobro authored Nov 15, 2023
1 parent 8888a3f commit f367c61
Show file tree
Hide file tree
Showing 20 changed files with 6,539 additions and 93 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/deploy-azero-contracts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
name: Bridgenet - deploy azero contracts

on:
push:
branches:
- 'master'
workflow_run:
workflows: ["Ink! tests"]
types: [completed]
branches: [master]

jobs:
compile:
name: Compile and deploy contracts
runs-on: self-hosted
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/deploy-eth-contracts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
name: Bridgenet - deploy eth contracts

on:
push:
branches:
- 'master'
workflow_run:
workflows: ["Solidity tests"]
types: [completed]
branches: [master]

jobs:
compile:
name: Compile and deploy contracts
runs-on: self-hosted
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -27,4 +29,4 @@ jobs:

- name: Deploy contracts
shell: bash
run: make deploy-eth NETWORK=bridgenet
run: make deploy-eth NETWORK=bridgenet
34 changes: 34 additions & 0 deletions .github/workflows/test-azero-contracts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Runs a local ethereum network and tests contracts.

name: Ink! tests

on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
test:
name: Test ink! contracts
runs-on: [self-hosted, Linux, X64, large]
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: "Install Rust toolchain"
uses: Cardinal-Cryptography/aleph-node/.github/actions/install-rust-toolchain@5eda3cd85e7e3aec3f2db7a26631c65d52c4b9ea

- name: "Install Docker Compose"
uses: KengoTODA/actions-setup-docker-compose@v1
with:
version: '1.29.2'

- name: "Check Docker Compose version"
run: docker-compose --version

- name: Run tests
shell: bash
run: make test-ink
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ target/
# env files
.env

# logs
*.log

# contracts
addresses.json
azero/artifacts/
Expand All @@ -30,4 +33,4 @@ azero/types/
node_modules

# emacs
relayer/src/ markdown-code-fontification:rustic-mode
relayer/src/ markdown-code-fontification:rustic-mode
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,20 @@ bridge: local-bridgenet deploy run-relayer
test-solidity: # Run solidity tests
test-solidity: eth-deps
cd eth && npx hardhat test ./test/Membrane.js

.PHONY: test-ink-e2e
test-ink-e2e: # Run ink e2e tests
test-ink-e2e: bootstrap-azero
export CONTRACTS_NODE="../../scripts/azero_contracts_node.sh" && \
cd azero/contracts/tests && \
cargo test -- --test-threads=1

.PHONY: test-ink
test-ink: # Run ink tests
test-ink: test-ink-e2e
cd azero/contracts/membrane && \
cargo test && \
cd ../governance && \
cargo test && \
cd ../psp22 && \
cargo test
13 changes: 7 additions & 6 deletions azero/contracts/membrane/Cargo.lock

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

5 changes: 1 addition & 4 deletions azero/contracts/membrane/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ edition = "2021"

[dependencies]
ink = { version = "=4.3.0", default-features = false }
psp22 = { git = "https://github.com/Cardinal-Cryptography/PSP22.git", default-features = false, features = [
"mintable",
"burnable",
]}
psp22 = { version = "0.2.0", default-features = false }
psp22-traits = { path = "../psp22-traits" , default-features = false }
shared = { path = "../shared" }

Expand Down
Loading

0 comments on commit f367c61

Please sign in to comment.