Skip to content

Commit

Permalink
tests: Add automated functional test based on ragger framework
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Chapron committed Nov 14, 2022
1 parent 7803bcc commit 7a2c32e
Show file tree
Hide file tree
Showing 598 changed files with 1,117 additions and 804 deletions.
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: solana_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
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

0 comments on commit 7a2c32e

Please sign in to comment.