Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi committed Jun 12, 2024
1 parent e784ad2 commit 3a3df6c
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 98 deletions.
193 changes: 99 additions & 94 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,105 @@ 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
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
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
cat third.txt
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 Expand Up @@ -1074,97 +1173,3 @@ jobs:
action: stop
log_file_prefix: safe_test_logs_heavy_replicate_bench
platform: ubuntu-latest

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

# The test currently fails because the GH runner runs out of disk space. So we clear out the target dir here.
# Might be related to additional deps used in the codebase.
- 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 to pay for files storage
run: |
~/faucet --log-output-dest=data-dir send 100000000 $(~/safe --log-output-dest=data-dir wallet address | tail -n 1) | tail -n 1
env:
SN_LOG: "all"
timeout-minutes: 5

- name: Create and fund a wallet to pay for files storage
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
env:
SN_LOG: "all"
timeout-minutes: 5
/home/runner/.local/share/safe

- name: Start a client to upload
run: ~/safe --log-output-dest=data-dir files upload "ubuntu-14.04.6-desktop-i386.iso" --retry-strategy quick
env:
SN_LOG: "all"
timeout-minutes: 30

- 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_large_file_upload
build: true
2 changes: 1 addition & 1 deletion sn_client/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ impl Client {
let cash_note_addr = SpendAddress::from_unique_pubkey(&unique_pubkey);
let network_address = NetworkAddress::from_spend_address(cash_note_addr);

trace!("Sending spend {unique_pubkey:?} to the network via put_record, with addr of {cash_note_addr:?}");
info!("Sending spend {unique_pubkey:?} to the network via put_record, with addr of {cash_note_addr:?}");
let key = network_address.to_record_key();
let record_kind = RecordKind::Spend;
let record = Record {
Expand Down
17 changes: 14 additions & 3 deletions sn_transfers/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use super::wallet::HotWallet;

use crate::{
wallet::Result as WalletResult, CashNote, DerivationIndex, Input, MainPubkey, MainSecretKey,
NanoTokens, Output, SignedSpend, SpendReason, Transaction, TransactionBuilder,
NanoTokens, Output, SignedSpend, SpendAddress, SpendReason, Transaction, TransactionBuilder,
TransferError as CashNoteError, UniquePubkey,
};

Expand Down Expand Up @@ -153,10 +153,21 @@ pub fn is_genesis_parent_tx(parent_tx: &Transaction) -> bool {
/// Return if provided Spend is genesis spend.
pub fn is_genesis_spend(spend: &SignedSpend) -> bool {
let bytes = spend.spend.to_bytes_for_signing();
spend.spend.unique_pubkey == *GENESIS_SPEND_UNIQUE_KEY
let is_genesis = spend.spend.unique_pubkey == *GENESIS_SPEND_UNIQUE_KEY
&& GENESIS_SPEND_UNIQUE_KEY.verify(&spend.derived_key_sig, bytes)
&& is_genesis_parent_tx(&spend.spend.parent_tx)
&& spend.spend.amount == NanoTokens::from(GENESIS_CASHNOTE_AMOUNT)
&& spend.spend.amount == NanoTokens::from(GENESIS_CASHNOTE_AMOUNT);
if is_genesis {
info!(
"Spend {:?} is a genesis spend.",
SpendAddress::from_unique_pubkey(&spend.spend.unique_pubkey)
);
info!(
"inputs: {:?}, outputs: {:?}",
spend.spend.spent_tx.inputs, spend.spend.spent_tx.outputs
);
}
is_genesis
}

pub fn load_genesis_wallet() -> Result<HotWallet, Error> {
Expand Down

0 comments on commit 3a3df6c

Please sign in to comment.