From 09fc6448186872d1addf64e3202ae5fbdb60bbed Mon Sep 17 00:00:00 2001 From: rwwwx Date: Tue, 13 Aug 2024 13:24:20 +0300 Subject: [PATCH] ci fix --- .github/workflows/ci-tests.yml | 56 +++++++++++++++++++ .../tests/program_test/solana.rs | 6 ++ 2 files changed, 62 insertions(+) create mode 100644 .github/workflows/ci-tests.yml diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml new file mode 100644 index 00000000..77961ec3 --- /dev/null +++ b/.github/workflows/ci-tests.yml @@ -0,0 +1,56 @@ +name: Tests + +on: + push: + branches: + - main + pull_request: + +env: + CARGO_TERM_COLOR: always + SOLANA_VERSION: "1.14.12" + RUST_STABLE_VERSION: "1.66.1" + +defaults: + run: + working-directory: ./ + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install Linux dependencies + run: sudo apt-get update && sudo apt-get install -y pkg-config build-essential libudev-dev + + - name: Install stable Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: ${{ env.RUST_STABLE_VERSION }} + cache: true + + - name: Cache Solana binaries + uses: actions/cache@v2 + with: + path: ~/.cache/solana + key: ${{ runner.os }}-${{ env.RUST_STABLE_VERSION }} + + - name: Install Solana + run: | + sh -c "$(curl -sSfL https://release.solana.com/v${{ env.SOLANA_VERSION }}/install)" + echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH + export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH" + solana --version + echo "Generating keypair..." + solana-keygen new -o "$HOME/.config/solana/id.json" --no-passphrase --silent + + - name: Switch toolchain + run: | + rustup override set ${{ env.RUST_STABLE_VERSION }} + solana-install init ${{ env.SOLANA_VERSION }} + + - name: Run tests + run: cargo test-bpf diff --git a/programs/voter-stake-registry/tests/program_test/solana.rs b/programs/voter-stake-registry/tests/program_test/solana.rs index 5051d1a7..5d3f6cc2 100644 --- a/programs/voter-stake-registry/tests/program_test/solana.rs +++ b/programs/voter-stake-registry/tests/program_test/solana.rs @@ -46,6 +46,12 @@ impl SolanaCookie { transaction.sign(&all_signers, context.last_blockhash); + context.last_blockhash = context + .banks_client + .get_latest_blockhash() + .await + .expect("Cannot get latest blockhash!"); + context .banks_client .process_transaction_with_commitment(