Skip to content

Commit

Permalink
Merge branch 'tomas/ledger-wallet-test'
Browse files Browse the repository at this point in the history
* origin/tomas/ledger-wallet-test:
  fix rust doc warn
  ci: add e2e test run with device automation
  genesis/hardware/README: update with notes on automation
  test/ledger/pos: add HW wallet automation
  tests: add hw wallet hw_wallet_automation helper
  • Loading branch information
Fraccaman committed Sep 10, 2024
2 parents ee65771 + 1ece97d commit 21c9997
Show file tree
Hide file tree
Showing 10 changed files with 714 additions and 5 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -649,3 +649,97 @@ jobs:
files: integration-cov/lcov.info, unit-cov/lcov.info, wasm-cov/lcov.info
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

test-e2e-with-device-automation:
runs-on: [self-hosted, 4vcpu-8ram-ubuntu22-namada-x86]
container:
image: ghcr.io/heliaxdev/namada-ci:namada-main
if: github.event.pull_request.draft == false || contains(github.head_ref, 'mergify/merge-queue') || contains(github.ref_name, 'mergify/merge-queue')
needs: [build-wasm, build-binaries]
timeout-minutes: 50

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: Cache cargo
id: cache
uses: runs-on/cache@v4
env:
RUNS_ON_S3_BUCKET_CACHE: ${{ env.CACHE_BUCKET }}
with:
path: /usr/local/cargo
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}
- name: Start sccache server
id: sccache
run: sccache --start-server
- name: Download wasm artifacts
uses: actions/download-artifact@v4
with:
name: wasm-${{ github.event.pull_request.head.sha|| github.sha }}
path: wasm
- name: Download wasm-for-tests artifacts
uses: actions/download-artifact@v4
with:
name: wasm-for-tests-${{ github.event.pull_request.head.sha|| github.sha }}
path: wasm_for_tests
- name: Download namada binaries
uses: actions/download-artifact@v4
with:
name: binaries-${{ github.event.pull_request.head.sha || github.sha }}
path: ./target/release/
- name: Download Hermes
run: |
HERMES_VERSION=$(cat .github/workflows/scripts/hermes.txt)
echo "Using hermes version: ${HERMES_VERSION}"
curl -o hermes.zip -LO https://github.com/heliaxdev/hermes/releases/download/v${HERMES_VERSION}/hermes-v${HERMES_VERSION}-x86_64-unknown-linux-gnu.zip
unzip hermes.zip
mv hermes /usr/local/bin
- name: Change permissions
run: |
chmod +x target/release/namada
chmod +x target/release/namadaw
chmod +x target/release/namadan
chmod +x target/release/namadac
chmod +x /usr/local/bin/hermes
- name: Run e2e tests with device automation
id: e2e
run: cargo +${{ env.NIGHTLY }} test --lib "e2e::ledger_tests::pos_bonds" -- --exact
env:
NAMADA_DEVICE_AUTOMATION: "true"
NAMADA_DEVICE_TRANSPORT: "tcp"
NAMADA_E2E_USE_DEVICE: "true"
NAMADA_E2E_USE_PREBUILT_BINARIES: "true"
NAMADA_E2E_KEEP_TEMP: "true"
NAMADA_TM_STDOUT: "false"
NAMADA_LOG_COLOR: "false"
NAMADA_LOG: "info"
RUSTFLAGS: "-C linker=clang -C debug_assertions=true -C link-arg=-fuse-ld=/usr/local/bin/mold"
- name: Upload e2e logs
if: success() || steps.e2e.conclusion == 'failure' || steps.e2e.conclusion == 'success'
uses: actions/upload-artifact@v4
with:
name: logs-e2e-with-automation-${{ github.event.pull_request.head.sha || github.sha }}
path: |
/tmp/.*/logs/
/tmp/.*/setup/validator-*/logs/
/tmp/.*/setup/validator-*/e2e-test.*/*.toml
if-no-files-found: error
include-hidden-files: true
retention-days: 5
- name: Clean cargo cache
if: steps.cache.outputs.cache-hit != 'true'
run: cargo cache --autoclean-expensive
- name: Stop sccache
if: always() && steps.sccache.conclusion == 'success'
run: sccache --stop-server || true
22 changes: 22 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ rpassword = "5.0.1"
serde = {version = "1.0.125", features = ["derive"]}
serde_bytes = "0.11.5"
serde_json = "1.0.62"
serde_tuple = "0.5.0"
sha2 = "0.9.3"
sha2-const = "0.1.2"
signal-hook = "0.3.9"
Expand Down
2 changes: 1 addition & 1 deletion crates/shielded_token/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn reveal_nullifiers(
/// Appends the note commitments of the provided transaction to the merkle tree
/// and updates the anchor
/// NOTE: this function is public as a temporary workaround because of an issue
/// when running it in WASM (https://github.com/anoma/masp/issues/73)
/// when running it in WASM (<https://github.com/anoma/masp/issues/73>)
pub fn update_note_commitment_tree(
ctx: &mut (impl StorageRead + StorageWrite),
transaction: &Transaction,
Expand Down
1 change: 1 addition & 0 deletions crates/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ prost.workspace = true
regex.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_tuple.workspace = true
sha2.workspace = true
tempfile.workspace = true
test-log.workspace = true
Expand Down
32 changes: 31 additions & 1 deletion crates/tests/src/e2e/ledger_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use crate::strings::{
LEDGER_SHUTDOWN, LEDGER_STARTED, NON_VALIDATOR_NODE, TX_APPLIED_SUCCESS,
TX_REJECTED, VALIDATOR_NODE,
};
use crate::{run, run_as, LastSignState};
use crate::{hw_wallet_automation, run, run_as, LastSignState};

const ENV_VAR_NAMADA_SEED_NODES: &str = "NAMADA_SEED_NODES";

Expand Down Expand Up @@ -540,6 +540,32 @@ fn pos_bonds() -> Result<()> {
None,
);

// If used, keep Speculos alive for duration of the test
let mut speculos: Option<std::process::Child> = None;
if hw_wallet_automation::uses_automation() {
// Gen automation for Speculos
let automation = hw_wallet_automation::gen_automation_e2e_pos_bonds();
let json = serde_json::to_vec_pretty(&automation).unwrap();
let path = test.test_dir.path().join("automation.json");
std::fs::write(&path, json).unwrap();

// Start Speculos with the automation
speculos = Some(
Command::new("speculos")
.args([
"app_s2.elf",
"--seed",
hw_wallet_automation::SEED,
"--automation",
&format!("file:{}", path.to_string_lossy()),
"--log-level",
"automation:DEBUG",
])
.spawn()
.unwrap(),
);
}

// 1. Run the ledger node
let _bg_validator_0 =
start_namada_ledger_node_wait_wasm(&test, Some(0), Some(40))?
Expand Down Expand Up @@ -740,6 +766,10 @@ fn pos_bonds() -> Result<()> {
client.exp_string(TX_APPLIED_SUCCESS)?;
client.assert_success();

if let Some(mut process) = speculos {
process.kill().unwrap()
}

Ok(())
}

Expand Down
Loading

0 comments on commit 21c9997

Please sign in to comment.