|
6 | 6 | use std::time::Duration; |
7 | 7 |
|
8 | 8 | use anyhow::Context; |
| 9 | +use hex; |
9 | 10 | use miden_objects::account::AccountId; |
10 | 11 | use miden_objects::testing::account_id::ACCOUNT_ID_SENDER; |
11 | 12 | use reqwest::Client; |
@@ -162,7 +163,11 @@ async fn perform_faucet_test( |
162 | 163 |
|
163 | 164 | // Step 1: Request PoW challenge |
164 | 165 | let pow_url = faucet_url.join("/pow")?; |
165 | | - let response = client.get(pow_url).query(&[("account_id", &account_id)]).send().await?; |
| 166 | + let response = client |
| 167 | + .get(pow_url) |
| 168 | + .query(&[("account_id", &account_id), ("amount", &MINT_AMOUNT.to_string())]) |
| 169 | + .send() |
| 170 | + .await?; |
166 | 171 |
|
167 | 172 | let response_text = response.text().await?; |
168 | 173 | debug!("Faucet PoW response: {}", response_text); |
@@ -216,17 +221,14 @@ async fn perform_faucet_test( |
216 | 221 | /// |
217 | 222 | /// The nonce that solves the challenge, or an error if no solution is found within reasonable |
218 | 223 | /// bounds. |
| 224 | +#[instrument(target = COMPONENT, name = "solve-pow-challenge", skip_all, ret(level = "debug"))] |
219 | 225 | fn solve_pow_challenge(challenge: &str, target: u64) -> anyhow::Result<u64> { |
220 | | - debug!( |
221 | | - "Solving PoW challenge: challenge={}, target={} (~{} bits)", |
222 | | - challenge, |
223 | | - target, |
224 | | - target.leading_zeros(), |
225 | | - ); |
| 226 | + let challenge_bytes = hex::decode(challenge).context("Failed to decode challenge from hex")?; |
| 227 | + |
226 | 228 | // Try up to 100 million nonces. |
227 | 229 | for nonce in 0..MAX_CHALLENGE_ATTEMPTS { |
228 | 230 | let mut hasher = Sha256::new(); |
229 | | - hasher.update(challenge.as_bytes()); |
| 231 | + hasher.update(&challenge_bytes); |
230 | 232 | hasher.update(nonce.to_be_bytes()); |
231 | 233 | let hash_result = hasher.finalize(); |
232 | 234 |
|
|
0 commit comments