Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Add automated functional test based on ragger framework #11

Merged
merged 5 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
106 changes: 58 additions & 48 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,74 +7,84 @@ on:
- master
- develop
pull_request:
branches:
- master
- develop

jobs:
nanos-build:
name: Build app for NanoS
runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
steps:
- name: Clone
uses: actions/checkout@v2
- name: Build
run: make
- name: Upload app binary
uses: actions/upload-artifact@v2
with:
name: nanos-app
path: bin
build_application:
strategy:
matrix:
sdk:
- path: $NANOS_SDK
name: nanos
- path: $NANOX_SDK
name: nanox
- path: $NANOSP_SDK
name: nanosp

nanox-build:
name: Build app for NanoX
runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
steps:
- name: Clone
uses: actions/checkout@v2
- name: Build
run: |
make BOLOS_SDK=$NANOX_SDK
- name: Upload app binary
uses: actions/upload-artifact@v2
with:
name: nanox-app
path: bin

nanosp-build:
name: Build app for NanoS+
runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest

steps:
- name: Clone
uses: actions/checkout@v2
- name: Build
uses: actions/checkout@v3

- name: Build application
run: |
make BOLOS_SDK=$NANOSP_SDK
- name: Upload app binary
uses: actions/upload-artifact@v2
make BOLOS_SDK=${{ matrix.sdk.path }} DEBUG=1
cp bin/app.elf bin/eos_${{ matrix.sdk.name }}.elf

- name: Upload application binaries
uses: actions/upload-artifact@v3
with:
name: nanosp-app
path: bin
name: eos_binaries
path: ./bin/eos_${{ matrix.sdk.name }}.elf
if-no-files-found: error

scan_build:
job_scan_build:
name: Clang Static Analyzer
needs: build_application
runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest
steps:
- uses: actions/checkout@v2
- name: Clone
uses: actions/checkout@v3

- name: Build with Clang Static Analyzer
run: |
make clean
scan-build --use-cc=clang -analyze-headers -enable-checker security -enable-checker unix -enable-checker valist -o scan-build --status-bugs make default
- uses: actions/upload-artifact@v2

- name: Upload scan results
uses: actions/upload-artifact@v3
if: failure()
with:
name: scan-build
path: scan-build

functional_tests:
name: Functional tests
needs: build_application
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3

- name: Download all binaries
uses: actions/download-artifact@v3

- name: Gather artifacts
run: |
mkdir tests/elfs
mv *_binaries/*.elf tests/elfs

- name: Install APT dependencies
run: sudo apt-get update && sudo apt-get install -y qemu-user-static

- name: Install requirements
run: |
pip install --extra-index-url https://test.pypi.org/simple/ -r tests/functional/requirements.txt

- name: Run tests
run: pytest tests/functional/ -v
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ src/glyphs.h
coverage
fuzz/corpus/
fuzz/build/
tests/elfs/
tests/functional/snapshots-tmp/
26 changes: 26 additions & 0 deletions fuzz/generate_fuzz_ref_corpus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3

import sys
import json
import argparse

from pathlib import Path

REPO_ROOT_DIRECTORY = Path(__file__).parent
EOS_LIB_DIRECTORY = (REPO_ROOT_DIRECTORY / "../tests/functional/apps").resolve().as_posix()
sys.path.append(EOS_LIB_DIRECTORY)
from eos_transaction_builder import Transaction

parser = argparse.ArgumentParser()
parser.add_argument('--file', help="Transaction in JSON format")
args = parser.parse_args()

if args.file is None:
args.file = '../tests/corpus/transaction.json'

with open(args.file) as f:
obj = json.load(f)
signing_digest, message = Transaction().encode(obj)

with open(args.file.replace(".json", ".bin"), 'wb') as out:
out.write(message)
Loading