Skip to content

Commit

Permalink
chore: minor improvements to some log msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
bochaco committed Oct 10, 2023
1 parent c715dc8 commit 364dca4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ jobs:
- uses: Swatinem/rust-cache@v2

- name: Build safe bins
run: cargo build --release --features local-discovery,network-royalties-notif --bin safenode --bin faucet
run: cargo build --release --features=local-discovery,network-royalties-notif --bin safenode --bin faucet
timeout-minutes: 30

- name: Build testing executable
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ jobs:
continue-on-error: true

- name: Build safe bins
run: cargo build --release --features local-discovery,network-royalties-notif --bin safenode --bin faucet
run: cargo build --release --features=local-discovery,network-royalties-notif --bin safenode --bin faucet
timeout-minutes: 30

- name: Build testing executable
Expand Down
18 changes: 9 additions & 9 deletions sn_node/src/put_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,14 @@ impl Node {
payment: Vec<Transfer>,
) -> Result<(), ProtocolError> {
let pretty_key = PrettyPrintRecordKey::from(address.to_record_key());
trace!("Validating record payment for {pretty_key:?}");
trace!("Validating record payment for {pretty_key}");

// load wallet
let mut wallet = LocalWallet::load_from(&self.network.root_dir_path)
.map_err(|err| ProtocolError::FailedToStorePaymentIntoNodeWallet(err.to_string()))?;

// unpack transfer
trace!("Unpacking incoming Transfers for record {pretty_key:?}");
trace!("Unpacking incoming Transfers for record {pretty_key}");
let (cash_notes, transfer_for_us) = self
.cash_notes_from_payment(&payment, &wallet, pretty_key.clone())
.await?;
Expand All @@ -444,28 +444,28 @@ impl Node {
))?;
}
if received_fee < current_store_cost {
trace!("Payment insufficient for record {pretty_key:?}");
trace!("Payment insufficient for record {pretty_key}");
return Err(ProtocolError::PaymentProofInsufficientAmount {
paid: received_fee,
expected: current_store_cost,
});
}
trace!("Payment sufficient for record {pretty_key:?}");
trace!("Payment sufficient for record {pretty_key}");

// publish a notification over gossipsub topic TRANSFER_NOTIF_TOPIC for each cash-note received.
match transfer_for_us.to_hex() {
Ok(transfer_hex) => {
let topic = TRANSFER_NOTIF_TOPIC.to_string();
for cash_note in cash_notes.iter() {
let pk = cash_note.unique_pubkey().to_bytes();
let mut msg: Vec<u8> = pk.to_vec();
let pk = cash_note.unique_pubkey();
let mut msg: Vec<u8> = pk.to_bytes().to_vec();
msg.extend(transfer_hex.as_bytes());
if let Err(err) = self.network.publish_on_topic(topic.clone(), msg) {
debug!("Failed to publish a transfer notification over gossipsub: {err:?}");
debug!("Failed to publish a transfer notification over gossipsub for record {pretty_key} and beneficiary {pk:?}: {err:?}");
}
}
}
Err(err) => debug!("Failed to serialise transfer data to publish a notification over gossipsub: {err:?}"),
Err(err) => debug!("Failed to serialise transfer data to publish a notification over gossipsub for record {pretty_key}: {err:?}"),
}

// deposit the CashNotes in our wallet
Expand All @@ -478,7 +478,7 @@ impl Node {
.reward_wallet_balance
.set(wallet.balance().as_nano() as i64);

info!("Payment of {received_fee:?} nanos accepted for record {pretty_key:?}");
info!("Payment of {received_fee:?} nanos accepted for record {pretty_key}");

Ok(())
}
Expand Down
8 changes: 5 additions & 3 deletions sn_node/tests/nodes_rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use assert_fs::TempDir;
use eyre::{eyre, Result};
use tokio::{
task::JoinHandle,
time::{sleep, timeout, Duration},
time::{sleep, Duration},
};
use tokio_stream::StreamExt;
use tonic::Request;
Expand Down Expand Up @@ -138,8 +138,9 @@ async fn nodes_rewards_for_chunks_notifs_over_gossipsub() -> Result<()> {
let handle = spawn_transfer_notifs_listener("https://127.0.0.1:12001".to_string());

files_api.upload_with_payments(content_bytes, true).await?;
println!("Random chunks stored");

let count = timeout(Duration::from_millis(5000), async { handle.await? }).await??;
let count = handle.await??;
println!("Number of notifications received by node: {count}");
assert_eq!(count, CLOSE_GROUP_SIZE, "Not enough notifications received");

Expand Down Expand Up @@ -175,8 +176,9 @@ async fn nodes_rewards_for_register_notifs_over_gossipsub() -> Result<()> {
let _register = client
.create_register(register_addr, &mut wallet_client, false)
.await?;
println!("Random Register created");

let count = timeout(Duration::from_millis(5000), async { handle.await? }).await??;
let count = handle.await??;
println!("Number of notifications received by node: {count}");
assert_eq!(count, CLOSE_GROUP_SIZE, "Not enough notifications received");

Expand Down

0 comments on commit 364dca4

Please sign in to comment.