|
|
@@ -36,34 +36,34 @@ fn pow_reward() -> Result<()> {
|
|
|
init_logger();
|
|
|
|
|
|
// Holders this test will use
|
|
|
- const HOLDERS: [Holder; 3] = [Holder::Faucet, Holder::Alice, Holder::Bob];
|
|
|
+ const HOLDERS: [Holder; 2] = [Holder::Alice, Holder::Bob];
|
|
|
|
|
|
// Block height to verify against
|
|
|
let mut current_block_height = 0;
|
|
|
|
|
|
// Initialize harness
|
|
|
- let mut th = TestHarness::new(&["money".to_string()], false).await?;
|
|
|
-
|
|
|
- let mut alice_owncoins = vec![];
|
|
|
- let mut bob_owncoins = vec![];
|
|
|
+ let mut th = TestHarness::new(&HOLDERS, false).await?;
|
|
|
|
|
|
// 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 block");
|
|
|
info!(target: "money", "[Malicious] ========================================");
|
|
|
- let (pow_reward_tx, _) =
|
|
|
- th.pow_reward(&Holder::Alice, None, current_block_height, Some(0))?;
|
|
|
+ let (pow_reward_tx, pow_reward_params) =
|
|
|
+ th.pow_reward(&Holder::Alice, None, Some(0)).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?;
|
|
|
+ assert!(th
|
|
|
+ .execute_pow_reward_tx(
|
|
|
+ &Holder::Alice,
|
|
|
+ &pow_reward_tx,
|
|
|
+ &pow_reward_params,
|
|
|
+ current_block_height,
|
|
|
+ )
|
|
|
+ .await
|
|
|
+ .is_err());
|
|
|
|
|
|
current_block_height += 1;
|
|
|
|
|
|
@@ -71,25 +71,28 @@ fn pow_reward() -> Result<()> {
|
|
|
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_block_height, Some(alice_reward + 1))?;
|
|
|
+ let (pow_reward_tx, pow_reward_params) =
|
|
|
+ th.pow_reward(&Holder::Alice, None, Some(alice_reward + 1)).await?;
|
|
|
|
|
|
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_block_height,
|
|
|
- )
|
|
|
- .await?;
|
|
|
+ assert!(th
|
|
|
+ .execute_pow_reward_tx(
|
|
|
+ &Holder::Alice,
|
|
|
+ &pow_reward_tx,
|
|
|
+ &pow_reward_params,
|
|
|
+ current_block_height,
|
|
|
+ )
|
|
|
+ .await
|
|
|
+ .is_err());
|
|
|
|
|
|
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_block_height, None)?;
|
|
|
+ //let (pow_reward_tx, pow_reward_params) = th.pow_reward(&Holder::Alice, None, None).await?;
|
|
|
|
|
|
+ /*
|
|
|
for holder in &HOLDERS {
|
|
|
info!(target: "money", "[{holder:?}] =============================");
|
|
|
info!(target: "money", "[{holder:?}] Executing Alice PoW reward tx");
|
|
|
@@ -184,9 +187,7 @@ fn pow_reward() -> Result<()> {
|
|
|
assert!(alice_owncoins[0].note.value == alice_reward - alice_send);
|
|
|
assert!(bob_owncoins[0].note.value == alice_send);
|
|
|
assert!(bob_owncoins[1].note.value == alice_reward);
|
|
|
-
|
|
|
- // Statistics
|
|
|
- th.statistics();
|
|
|
+ */
|
|
|
|
|
|
// Thanks for reading
|
|
|
Ok(())
|