Skip to content

Commit

Permalink
Improve framework coverage v2 (#489)
Browse files Browse the repository at this point in the history
* update whitelist tests and fixes

* upgrade account test

* ans host full filter test

* ans-host coverage

* aftermerge fixes

* abstract sdk codecov progress

* update snapshots

* protobuf unused dep

* change code coverage tool

* download correct binary

* tarpaulin misses branches

* try nightly coverage

* circlecli orb typo

* no coverage feature

* AbstractApi update

* update module id for MockBinding

* splitter tests

* AccountVerification & AccountRegistry tests

* nits

* exclude error files

* version registry tests

* move interchain mock tests to framework

* abstract app extra tests

* migrate instantiate test

* standalone cover tests

* add comment on _update_whitelisted_modules

* typo

* verify nft test

* remove lcov

* no interchain mock tests anymore

* clippy

* cargo update

* fix namespace key and add migration

* update workspace hack

* snapshots

* postmerge fixes

* get_account->account

* account getter fmt

* apply coverage helper for all unit tests

* feature coverage attribute

---------

Co-authored-by: Kayanski <[email protected]>
  • Loading branch information
Buckram123 and Kayanski authored Oct 15, 2024
1 parent 2297ea2 commit 6d9cebe
Show file tree
Hide file tree
Showing 188 changed files with 2,510 additions and 1,830 deletions.
10 changes: 10 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ orbs:
codecov: codecov/[email protected]
discord: antonioned/[email protected]

commands:
rust_install_nightly:
steps:
- run:
name: "Install nightly toolchain"
command: |
rustup toolchain install nightly-x86_64-unknown-linux-gnu
rustup component add llvm-tools-preview
parameters:
GHA_Event:
type: string
Expand Down Expand Up @@ -368,6 +377,7 @@ jobs:
- image: cimg/rust:1.80.0
resource_class: xlarge
steps:
- rust_install_nightly
- setup_remote_docker
- checkout
- run:
Expand Down
41 changes: 5 additions & 36 deletions .github/workflows/interchain-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,46 +49,15 @@ jobs:
mkdir -p ~/.cw-orchestrator
echo -n '${{ secrets.CW_ORCH_NETWORKS }}' > ~/.cw-orchestrator/networks.toml
- uses: Swatinem/rust-cache@v2
with:
workspaces: "interchain/framework-clone-testing -> target"
with:
workspaces: "interchain/framework-clone-testing -> target"
- name: cargo test --locked
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
working-directory: ./interchain/framework-clone-testing
run: cargo nextest run --retries 3

interchain-tests:
runs-on: ubuntu-latest
name: interchain mock tests
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: webfactory/[email protected]
with:
ssh-private-key: |
${{ secrets.SSH_PRIVATE_KEY_MULTI_TEST }}
${{ secrets.SSH_PRIVATE_KEY_CW_ORCH_INTERCHAIN }}
- name: Setup sccache
uses: mozilla-actions/[email protected]
with:
version: "v0.8.1"
- name: Install stable
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: cargo generate-lockfile
if: hashFiles('Cargo.lock') == ''
working-directory: ./interchain/interchain-tests
run: cargo generate-lockfile
- uses: Swatinem/rust-cache@v2
with:
workspaces: "interchain/interchain-tests -> target"
- name: cargo test --locked
working-directory: ./interchain/interchain-tests
run: cargo test --locked

modules-clone-tests:
runs-on: ubuntu-latest
name: module clone tests
Expand Down Expand Up @@ -119,8 +88,8 @@ jobs:
mkdir -p ~/.cw-orchestrator
echo -n '${{ secrets.CW_ORCH_NETWORKS }}' > ~/.cw-orchestrator/networks.toml
- uses: Swatinem/rust-cache@v2
with:
workspaces: "interchain/modules-clone-testing -> target"
with:
workspaces: "interchain/modules-clone-testing -> target"
- name: cargo test --locked
working-directory: ./interchain/modules-clone-testing
run: cargo nextest run --retries 3
run: cargo nextest run --retries 3
30 changes: 25 additions & 5 deletions framework/Cargo.lock

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

6 changes: 6 additions & 0 deletions framework/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ abstract-integration-tests = { path = "packages/abstract-integration-tests" }
rstest = "0.17.0"
speculoos = "0.11.0"
anyhow = "1"
coverage-helper = { version = "0.2.2" }

# Predictable abstract addresses
cw-blob = { version = "=0.2.0", features = ["library"] }
Expand Down Expand Up @@ -129,3 +130,8 @@ abstract-cw-orch-polytone = { git = "https://github.com/AbstractSDK/polytone.git
# ensures CI doens't flag workspace-hack as unused dep
normal = ["workspace-hack"]
development = ["workspace-hack"]

[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(coverage,coverage_nightly)',
] }
4 changes: 4 additions & 0 deletions framework/contracts/account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ repository = "https://github.com/AbstractSDK/abstract"

exclude = ["contract.wasm", "hash.txt"]

[lints]
workspace = true

[[example]]
name = "schema"
required-features = ["xion"]
Expand Down Expand Up @@ -115,6 +118,7 @@ abstract-standalone = { workspace = true, features = ["test-utils"] }
abstract-testing = { workspace = true }
abstract-macros = { workspace = true }
abstract-integration-tests = { workspace = true }
coverage-helper = { workspace = true }

[profile.release]
overflow-checks = true
2 changes: 1 addition & 1 deletion framework/contracts/account/src/absacc/auth/eth_crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ mod tests {

use super::*;

#[test]
#[coverage_helper::test]
fn verifying_ethereum_signature() {
let api = MockApi::default();

Expand Down
4 changes: 2 additions & 2 deletions framework/contracts/account/src/absacc/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,14 @@ pub mod execute {
mod test {
use super::*;

#[test]
#[coverage_helper::test]
fn auth_id_err() {
for id in 128..=u8::MAX {
assert!(AuthId::new(id, true).is_none())
}
}

#[test]
#[coverage_helper::test]
fn auth_id() {
for id in 0..0b10000000 {
let (unmasked_id, admin) = AuthId::new(id, true).unwrap().cred_id();
Expand Down
2 changes: 1 addition & 1 deletion framework/contracts/account/src/absacc/auth/secp256r1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mod tests {
use cosmwasm_std::Binary;
use p256::ecdsa::{signature::Signer, Signature, SigningKey, VerifyingKey};

#[test]
#[coverage_helper::test]
fn test_verify_signature() {
let key_serialized = "3ee21644150adb50dc4c20e330184fabf12e75ecbf31fe167885587e6ebf2255";
let key_bytes = hex::decode(key_serialized).unwrap();
Expand Down
6 changes: 3 additions & 3 deletions framework/contracts/account/src/absacc/auth/sign_arb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mod tests {
use cosmwasm_std::testing::{message_info, mock_dependencies, mock_env};
use cosmwasm_std::{Addr, Api, Binary};

#[test]
#[coverage_helper::test]
fn test_derive_addr() {
let pub_key = "AxVQixKMvKkMWMgEBn5E+QjXxFLLiOUNs3EG3vvsgaGs";
let pub_key_bytes = general_purpose::STANDARD.decode(pub_key).unwrap();
Expand All @@ -57,7 +57,7 @@ mod tests {
);
}

#[test]
#[coverage_helper::test]
fn test_verify_sign_arb() {
let pubkey = "AxVQixKMvKkMWMgEBn5E+QjXxFLLiOUNs3EG3vvsgaGs";
let pubkey_bytes = general_purpose::STANDARD.decode(pubkey).unwrap();
Expand Down Expand Up @@ -94,7 +94,7 @@ mod tests {
assert!(verification)
}

#[test]
#[coverage_helper::test]
fn test_init_sign_arb() {
let mut deps = mock_dependencies();
deps.api = deps.api.with_prefix("xion");
Expand Down
Loading

0 comments on commit 6d9cebe

Please sign in to comment.