Skip to content

Commit

Permalink
Refactor and improve tests (solana-labs#121)
Browse files Browse the repository at this point in the history
- use Reserve, LendingMarket, Obligation types directly instead of TestReserve, TestLendingMarket, TestObligation
- more helper functions
- check account state after every successful program call
- check _all_ token accounts and mint accounts after every successful program call
  • Loading branch information
0xripleys authored Jan 25, 2023
1 parent affb6e4 commit 7e2aca3
Show file tree
Hide file tree
Showing 30 changed files with 5,065 additions and 6,504 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ jobs:

- name: Set env vars
run: |
source ci/rust-version.sh nightly
echo "RUST_NIGHTLY=$rust_nightly" >> $GITHUB_ENV
source ci/rust-version.sh
echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV
source ci/solana-version.sh
echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_NIGHTLY }}
toolchain: ${{ env.RUST_STABLE }}
override: true
profile: minimal

Expand All @@ -149,7 +149,7 @@ jobs:
~/.cargo/registry
~/.cargo/git
# target # Removed due to build dependency caching conflicts
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_NIGHTLY }}
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE }}

- name: Install dependencies
run: |
Expand All @@ -158,9 +158,9 @@ jobs:
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: run test coverage
run: ./coverage.sh token-lending
run: ./coverage.sh

- name: Codecov
uses: codecov/codecov-action@v3.1.0
with:
file: target/cov/cobertura.xml
directory: target/coverage/
148 changes: 31 additions & 117 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions ci/cargo-test-bpf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ run_dir=$(pwd)
if [[ -d $run_dir/program ]]; then
# Build/test just one BPF program
cd $run_dir/program
cargo +"$rust_stable" test-bpf -- --nocapture
RUST_LOG="error" cargo +"$rust_stable" test-bpf -j 1 -- --nocapture
else
# Build/test all BPF programs
for directory in $(ls -d $run_dir/*/); do
cd $directory
cargo +"$rust_stable" test-bpf -- --nocapture
RUST_LOG="error" cargo +"$rust_stable" test-bpf -j 1 -- --nocapture
done
fi
1 change: 1 addition & 0 deletions ci/install-program-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ cargo install honggfuzz --version=0.5.52 --force || true
cargo +"$rust_stable" install grcov --force

cargo +"$rust_stable" build-bpf --version
rustup component add llvm-tools-preview
4 changes: 2 additions & 2 deletions ci/rust-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
if [[ -n $RUST_STABLE_VERSION ]]; then
stable_version="$RUST_STABLE_VERSION"
else
stable_version=1.63.0
stable_version=1.65.0
fi

if [[ -n $RUST_NIGHTLY_VERSION ]]; then
nightly_version="$RUST_NIGHTLY_VERSION"
else
nightly_version=2022-01-30
nightly_version=2022-04-01
fi


Expand Down
Loading

0 comments on commit 7e2aca3

Please sign in to comment.