|
|
@@ -37,8 +37,8 @@ fn pow_reward() -> Result<()> {
|
|
|
// Holders this test will use
|
|
|
const HOLDERS: [Holder; 3] = [Holder::Faucet, Holder::Alice, Holder::Bob];
|
|
|
|
|
|
- // Block height(slot) to verify against
|
|
|
- let mut current_height = 0;
|
|
|
+ // Block height to verify against
|
|
|
+ let mut current_block_height = 0;
|
|
|
|
|
|
// Initialize harness
|
|
|
let mut th = TestHarness::new(&["money".to_string()], false).await?;
|
|
|
@@ -48,44 +48,58 @@ fn pow_reward() -> Result<()> {
|
|
|
|
|
|
// We are going to generate some erroneous transactions to
|
|
|
// test some malicious cases.
|
|
|
- info!(target: "money", "[Malicious] =======================================");
|
|
|
- info!(target: "money", "[Malicious] Building PoW reward tx for genesis slot");
|
|
|
- info!(target: "money", "[Malicious] =======================================");
|
|
|
- let (pow_reward_tx, _) = th.pow_reward(&Holder::Alice, None, current_height, Some(0))?;
|
|
|
+ info!(target: "money", "[Malicious] ========================================");
|
|
|
+ info!(target: "money", "[Malicious] Building PoW reward tx for genesis block");
|
|
|
+ info!(target: "money", "[Malicious] ========================================");
|
|
|
+ let (pow_reward_tx, _) =
|
|
|
+ th.pow_reward(&Holder::Alice, None, current_block_height, Some(0))?;
|
|
|
|
|
|
- info!(target: "money", "[Malicious] =======================================");
|
|
|
- info!(target: "money", "[Malicious] Checking PoW reward tx for genesis slot");
|
|
|
- info!(target: "money", "[Malicious] =======================================");
|
|
|
- th.execute_erroneous_pow_reward_tx(&Holder::Alice, &pow_reward_tx.clone(), current_height)
|
|
|
- .await?;
|
|
|
+ info!(target: "money", "[Malicious] ========================================");
|
|
|
+ info!(target: "money", "[Malicious] Checking PoW reward tx for genesis block");
|
|
|
+ info!(target: "money", "[Malicious] ========================================");
|
|
|
+ th.execute_erroneous_pow_reward_tx(
|
|
|
+ &Holder::Alice,
|
|
|
+ &pow_reward_tx.clone(),
|
|
|
+ current_block_height,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
|
|
|
- current_height += 1;
|
|
|
+ current_block_height += 1;
|
|
|
|
|
|
- let alice_reward = expected_reward(current_height);
|
|
|
+ let alice_reward = expected_reward(current_block_height);
|
|
|
info!(target: "money", "[Malicious] ================================");
|
|
|
info!(target: "money", "[Malicious] Building erroneous PoW reward tx");
|
|
|
info!(target: "money", "[Malicious] ================================");
|
|
|
let (pow_reward_tx, _) =
|
|
|
- th.pow_reward(&Holder::Alice, None, current_height, Some(alice_reward + 1))?;
|
|
|
+ th.pow_reward(&Holder::Alice, None, current_block_height, Some(alice_reward + 1))?;
|
|
|
|
|
|
info!(target: "money", "[Malicious] =======================================");
|
|
|
info!(target: "money", "[Malicious] Checking erroneous amount PoW reward tx");
|
|
|
info!(target: "money", "[Malicious] =======================================");
|
|
|
- th.execute_erroneous_pow_reward_tx(&Holder::Alice, &pow_reward_tx.clone(), current_height)
|
|
|
- .await?;
|
|
|
+ th.execute_erroneous_pow_reward_tx(
|
|
|
+ &Holder::Alice,
|
|
|
+ &pow_reward_tx.clone(),
|
|
|
+ current_block_height,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
|
|
|
info!(target: "money", "[Alice] ======================");
|
|
|
info!(target: "money", "[Alice] Building PoW reward tx");
|
|
|
info!(target: "money", "[Alice] ======================");
|
|
|
let (pow_reward_tx, pow_reward_params) =
|
|
|
- th.pow_reward(&Holder::Alice, None, current_height, None)?;
|
|
|
+ th.pow_reward(&Holder::Alice, None, current_block_height, None)?;
|
|
|
|
|
|
for holder in &HOLDERS {
|
|
|
info!(target: "money", "[{holder:?}] =============================");
|
|
|
info!(target: "money", "[{holder:?}] Executing Alice PoW reward tx");
|
|
|
info!(target: "money", "[{holder:?}] =============================");
|
|
|
- th.execute_pow_reward_tx(holder, &pow_reward_tx, &pow_reward_params, current_height)
|
|
|
- .await?;
|
|
|
+ th.execute_pow_reward_tx(
|
|
|
+ holder,
|
|
|
+ &pow_reward_tx,
|
|
|
+ &pow_reward_params,
|
|
|
+ current_block_height,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
}
|
|
|
|
|
|
th.assert_trees(&HOLDERS);
|
|
|
@@ -113,8 +127,14 @@ fn pow_reward() -> Result<()> {
|
|
|
info!(target: "money", "[{holder:?}] ==============================");
|
|
|
info!(target: "money", "[{holder:?}] Executing Alice2Bob payment tx");
|
|
|
info!(target: "money", "[{holder:?}] ==============================");
|
|
|
- th.execute_transfer_tx(holder, &transfer_tx, &transfer_params, current_height, true)
|
|
|
- .await?;
|
|
|
+ th.execute_transfer_tx(
|
|
|
+ holder,
|
|
|
+ &transfer_tx,
|
|
|
+ &transfer_params,
|
|
|
+ current_block_height,
|
|
|
+ true,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
}
|
|
|
|
|
|
th.assert_trees(&HOLDERS);
|
|
|
@@ -132,14 +152,19 @@ fn pow_reward() -> Result<()> {
|
|
|
info!(target: "money", "[Alice] Building PoW reward tx for Bob");
|
|
|
info!(target: "money", "[Alice] ==============================");
|
|
|
let (pow_reward_tx, pow_reward_params) =
|
|
|
- th.pow_reward(&Holder::Alice, Some(&Holder::Bob), current_height, None)?;
|
|
|
+ th.pow_reward(&Holder::Alice, Some(&Holder::Bob), current_block_height, None)?;
|
|
|
|
|
|
for holder in &HOLDERS {
|
|
|
info!(target: "money", "[{holder:?}] =====================================");
|
|
|
info!(target: "money", "[{holder:?}] Executing Alice PoW reward tx for Bob");
|
|
|
info!(target: "money", "[{holder:?}] =====================================");
|
|
|
- th.execute_pow_reward_tx(holder, &pow_reward_tx, &pow_reward_params, current_height)
|
|
|
- .await?;
|
|
|
+ th.execute_pow_reward_tx(
|
|
|
+ holder,
|
|
|
+ &pow_reward_tx,
|
|
|
+ &pow_reward_params,
|
|
|
+ current_block_height,
|
|
|
+ )
|
|
|
+ .await?;
|
|
|
}
|
|
|
|
|
|
th.assert_trees(&HOLDERS);
|