Skip to content

Commit

Permalink
test(faucet): test multiple faucets
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi committed Jun 12, 2024
1 parent 2c08cc7 commit 24d730a
Showing 1 changed file with 110 additions and 0 deletions.
110 changes: 110 additions & 0 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,116 @@ jobs:
exit 1
fi
faucet_test:
if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
name: Faucet test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2

- name: install ripgrep
shell: bash
run: sudo apt-get install -y ripgrep

- name: Build binaries
run: cargo build --release --bin safenode --bin safe
timeout-minutes: 30

- name: Build faucet binary
run: cargo build --release --bin faucet --features gifting
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/sn-local-testnet-action@main
with:
action: start
interval: 2000
node-path: target/release/safenode
faucet-path: target/release/faucet
platform: ubuntu-latest
build: true

- name: Check we're _not_ warned about using default genesis
run: |
if rg "USING DEFAULT" "${{ matrix.safe_path }}"/*/*/logs; then
exit 1
fi
shell: bash

- name: Move built binaries and clear out target dir
shell: bash
run: |
mv target/release/faucet ~/faucet
mv target/release/safe ~/safe
rm -rf target
- name: Check SAFE_PEERS was set
shell: bash
run: |
if [[ -z "$SAFE_PEERS" ]]; then
echo "The SAFE_PEERS variable has not been set"
exit 1
else
echo "SAFE_PEERS has been set to $SAFE_PEERS"
fi
- name: Create and fund a wallet first time
run: |
~/faucet --log-output-dest=data-dir send 100000000 $(~/safe --log-output-dest=data-dir wallet address | tail -n 1) | tail -n 1 > first.txt
cat first.txt
env:
SN_LOG: "all"
timeout-minutes: 5

- name: Create and fund a wallet second time
run: |
ls -l /home/runner/.local/share
ls -l /home/runner/.local/share/safe
rm -rf /home/runner/.local/share/safe/test_faucet
rm -rf /home/runner/.local/share/safe/test_genesis
rm -rf /home/runner/.local/share/safe/client
~/faucet --log-output-dest=data-dir send 100000000 $(~/safe --log-output-dest=data-dir wallet address | tail -n 1) | tail -n 1 > second.txt
cat second.txt
if rg 'Error' ./second.txt; then
echo "Duplicated faucet rejected"
else
echo "Duplicated faucet not rejected!"
exit 1
fi
env:
SN_LOG: "all"
timeout-minutes: 5

- name: Create and fund a wallet third time with different keypair
run: |
ls -l /home/runner/.local/share
ls -l /home/runner/.local/share/safe
rm -rf /home/runner/.local/share/safe/test_faucet
rm -rf /home/runner/.local/share/safe/test_genesis
rm -rf /home/runner/.local/share/safe/client
if GENESIS_PK=a9925296499299fdbf4412509d342a92e015f5b996e9acd1d2ab7f2326e3ad05934326efdc345345a95e973ac1bb6637 GENESIS_SK=40f6bbc870355c68138ac70b450b6425af02b49874df3f141b7018378ceaac66 ~/faucet --log-output-dest=data-dir send 100000000 $(~/safe --log-output-dest=data-dir wallet address | tail -n 1) | tail -n 1 > second.txt; then
echo "Faucet with different key not rejected!"
cat third.txt
exit 1
else
echo "Faucet with different key rejected"
fi
env:
SN_LOG: "all"
timeout-minutes: 5

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/sn-local-testnet-action@main
with:
action: stop
platform: ubuntu-latest
log_file_prefix: safe_test_logs_faucet

large_file_upload_test:
if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
name: Large file upload
Expand Down

0 comments on commit 24d730a

Please sign in to comment.