Skip to content

Commit

Permalink
Merge pull request #4162 from anoma/mergify/bp/maint-libs-0.46/pr-4140
Browse files Browse the repository at this point in the history
Add Ledger app unit tests to the Namada CI (backport #4140)
  • Loading branch information
mergify[bot] authored Dec 11, 2024
2 parents 8a15225 + ab6b4a6 commit a41c025
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/CI/4140-ledger-namada-unit-tests-ci.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Add Ledger app unit tests to the Namada CI.
([\#4140](https://github.com/anoma/namada/pull/4140))
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ env:
AWS_REGION: us-west-2
NIGHTLY: nightly-2024-09-08
NAMADA_MASP_PARAMS_DIR: /masp/.masp-params
LEDGER_APP_VERSION: "1.0.6-ci-patch"

jobs:
changelog:
Expand Down Expand Up @@ -651,6 +652,45 @@ jobs:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

test-ledger-app:
timeout-minutes: 30
runs-on: [self-hosted, 4vcpu-8ram-ubuntu22-namada-x86]

steps:
- name: Checkout repo
uses: actions/checkout@v4
if: ${{ github.event_name != 'pull_request_target' }}
- name: Checkout PR
uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request_target' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Configure AWS
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE }}
- name: Checkout ledger-namada
run: |
echo "Using Namada Ledger App version: v${LEDGER_APP_VERSION}"
git clone 'https://github.com/heliaxdev/ledger-namada' ../ledger-namada
cd ../ledger-namada
git checkout "v$LEDGER_APP_VERSION"
git submodule update --init --recursive
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
make deps
- name: Generate test vectors
run: |
# The path where the Ledger app test suite will locate test vectors
TESTVEC_PATH="../ledger-namada/tests/testvectors.json"
TESTDBG_PATH="../ledger-namada/tests/testdebugs.txt"
sudo apt-get install -y protobuf-compiler
cargo run --example generate-txs -- $TESTVEC_PATH $TESTDBG_PATH
- name: Check test vectors
run: |
cd ../ledger-namada
make cpp_test
test-e2e-with-device-automation:
runs-on: [self-hosted, 4vcpu-8ram-ubuntu22-namada-x86]
container:
Expand Down
4 changes: 2 additions & 2 deletions crates/ibc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1284,8 +1284,8 @@ pub mod testing {

prop_compose! {
/// Generate an arbitrary IBC token ID vector
pub fn arb_ibc_token_ids()(token_ids in collection::vec(arb_ibc_token_id(), 1..10)) -> TokenIds {
TokenIds(token_ids)
pub fn arb_ibc_token_ids()(token_ids in collection::vec(arb_ibc_token_id().prop_map(|x| x.to_string()), 1..10)) -> TokenIds {
TokenIds::try_from(token_ids).expect("generated invalid IBC token ID vector")
}
}

Expand Down
50 changes: 25 additions & 25 deletions crates/sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1085,11 +1085,11 @@ pub mod testing {

prop_compose! {
/// Generate an arbitrary header
pub fn arb_header()(
pub fn arb_header(cmt_count: impl Into<SizeRange>,)(
chain_id in arb_chain_id(),
expiration in option::of(arb_date_time_utc()),
timestamp in arb_date_time_utc(),
batch in arb_tx_commitments(1..10),
batch in arb_tx_commitments(cmt_count),
atomic in proptest::bool::ANY,
tx_type in arb_tx_type(),
) -> Header {
Expand Down Expand Up @@ -1123,7 +1123,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary masp transfer transaction
pub fn arb_transfer_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
code_hash in arb_hash(),
(transfer, aux) in arb_transfer(),
Expand Down Expand Up @@ -1156,7 +1156,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary bond transaction
pub fn arb_bond_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
bond in arb_bond(),
code_hash in arb_hash(),
Expand All @@ -1172,7 +1172,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary bond transaction
pub fn arb_unbond_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
unbond in arb_bond(),
code_hash in arb_hash(),
Expand All @@ -1188,7 +1188,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary account initialization transaction
pub fn arb_init_account_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
mut init_account in arb_init_account(),
extra_data in arb_code(),
Expand All @@ -1207,7 +1207,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary account initialization transaction
pub fn arb_become_validator_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
become_validator in arb_become_validator(),
code_hash in arb_hash(),
Expand All @@ -1223,7 +1223,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary proposal initialization transaction
pub fn arb_init_proposal_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
mut init_proposal in arb_init_proposal(),
content_extra_data in arb_code(),
Expand Down Expand Up @@ -1272,7 +1272,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary vote proposal transaction
pub fn arb_vote_proposal_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
vote_proposal in arb_vote_proposal(),
code_hash in arb_hash(),
Expand All @@ -1288,7 +1288,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary reveal public key transaction
pub fn arb_reveal_pk_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
pk in arb_common_pk(),
code_hash in arb_hash(),
Expand All @@ -1304,7 +1304,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary account initialization transaction
pub fn arb_update_account_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
mut update_account in arb_update_account(),
extra_data in arb_code(),
Expand All @@ -1325,7 +1325,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary reveal public key transaction
pub fn arb_withdraw_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
withdraw in arb_withdraw(),
code_hash in arb_hash(),
Expand All @@ -1341,7 +1341,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary claim rewards transaction
pub fn arb_claim_rewards_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
claim_rewards in arb_withdraw(),
code_hash in arb_hash(),
Expand All @@ -1357,7 +1357,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary commission change transaction
pub fn arb_commission_change_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
commission_change in arb_commission_change(),
code_hash in arb_hash(),
Expand All @@ -1373,7 +1373,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary commission change transaction
pub fn arb_metadata_change_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
metadata_change in arb_metadata_change(),
code_hash in arb_hash(),
Expand All @@ -1389,7 +1389,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary unjail validator transaction
pub fn arb_unjail_validator_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
address in arb_non_internal_address(),
code_hash in arb_hash(),
Expand All @@ -1405,7 +1405,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary deactivate validator transaction
pub fn arb_deactivate_validator_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
address in arb_non_internal_address(),
code_hash in arb_hash(),
Expand All @@ -1421,7 +1421,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary reactivate validator transaction
pub fn arb_reactivate_validator_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
address in arb_non_internal_address(),
code_hash in arb_hash(),
Expand All @@ -1437,7 +1437,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary consensus key change transaction
pub fn arb_consensus_key_change_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
consensus_key_change in arb_consensus_key_change(),
code_hash in arb_hash(),
Expand All @@ -1453,7 +1453,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary redelegation transaction
pub fn arb_redelegation_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
redelegation in arb_redelegation(),
code_hash in arb_hash(),
Expand All @@ -1469,7 +1469,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary redelegation transaction
pub fn arb_update_steward_commission_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
update_steward_commission in arb_update_steward_commission(),
code_hash in arb_hash(),
Expand All @@ -1485,7 +1485,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary redelegation transaction
pub fn arb_resign_steward_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
steward in arb_non_internal_address(),
code_hash in arb_hash(),
Expand All @@ -1501,7 +1501,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary pending transfer transaction
pub fn arb_pending_transfer_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
pending_transfer in arb_pending_transfer(),
code_hash in arb_hash(),
Expand Down Expand Up @@ -1534,7 +1534,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary IBC any transaction
pub fn arb_ibc_msg_transfer_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
(msg_transfer, aux) in arb_msg_transfer(),
code_hash in arb_hash(),
Expand Down Expand Up @@ -1584,7 +1584,7 @@ pub mod testing {
prop_compose! {
/// Generate an arbitrary IBC any transaction
pub fn arb_ibc_msg_nft_transfer_tx()(
mut header in arb_header(),
mut header in arb_header(0),
wrapper in arb_wrapper_tx(),
(msg_transfer, aux) in arb_msg_nft_transfer(),
code_hash in arb_hash(),
Expand Down
Loading

0 comments on commit a41c025

Please sign in to comment.