|
|
@@ -34,64 +34,68 @@ use darkfi::Result;
|
|
|
use darkfi_contract_test_harness::{init_logger, Holder, TestHarness};
|
|
|
use log::info;
|
|
|
|
|
|
-#[async_std::test]
|
|
|
-async fn money_integration() -> Result<()> {
|
|
|
- init_logger();
|
|
|
+fn money_integration() -> Result<()> {
|
|
|
+ smol::block_on(async {
|
|
|
+ init_logger();
|
|
|
|
|
|
- // Holders this test will use
|
|
|
- const HOLDERS: [Holder; 3] = [Holder::Faucet, Holder::Alice, Holder::Bob];
|
|
|
+ // Holders this test will use
|
|
|
+ const HOLDERS: [Holder; 3] = [Holder::Faucet, Holder::Alice, Holder::Bob];
|
|
|
|
|
|
- // Some numbers we want to assert
|
|
|
- const ALICE_NATIVE_AIRDROP: u64 = 10000000000; // 100 DRK
|
|
|
- const BOB_SUPPLY: u64 = 2000000000; // 10 BOB
|
|
|
+ // Some numbers we want to assert
|
|
|
+ const ALICE_NATIVE_AIRDROP: u64 = 10000000000; // 100 DRK
|
|
|
+ const BOB_SUPPLY: u64 = 2000000000; // 10 BOB
|
|
|
|
|
|
- // Slot to verify against
|
|
|
- let current_slot = 0;
|
|
|
+ // Slot to verify against
|
|
|
+ let current_slot = 0;
|
|
|
|
|
|
- // Initialize harness
|
|
|
- let mut th = TestHarness::new(&["money".to_string()]).await?;
|
|
|
+ // Initialize harness
|
|
|
+ let mut th = TestHarness::new(&["money".to_string()]).await?;
|
|
|
|
|
|
- info!("[Faucet] Building Alice airdrop tx");
|
|
|
- let (airdrop_tx, airdrop_params) =
|
|
|
- th.airdrop_native(ALICE_NATIVE_AIRDROP, &Holder::Alice, None, None, None, None)?;
|
|
|
+ info!("[Faucet] Building Alice airdrop tx");
|
|
|
+ let (airdrop_tx, airdrop_params) =
|
|
|
+ th.airdrop_native(ALICE_NATIVE_AIRDROP, &Holder::Alice, None, None, None, None)?;
|
|
|
|
|
|
- for holder in &HOLDERS {
|
|
|
- info!("[{holder:?}] Executing Alice airdrop tx");
|
|
|
- th.execute_airdrop_native_tx(holder, &airdrop_tx, &airdrop_params, current_slot).await?;
|
|
|
- }
|
|
|
+ for holder in &HOLDERS {
|
|
|
+ info!("[{holder:?}] Executing Alice airdrop tx");
|
|
|
+ th.execute_airdrop_native_tx(holder, &airdrop_tx, &airdrop_params, current_slot)
|
|
|
+ .await?;
|
|
|
+ }
|
|
|
|
|
|
- th.assert_trees(&HOLDERS);
|
|
|
+ th.assert_trees(&HOLDERS);
|
|
|
|
|
|
- // Alice gathers her new coin
|
|
|
- th.gather_owncoin(&Holder::Alice, &airdrop_params.outputs[0], None)?;
|
|
|
+ // Alice gathers her new coin
|
|
|
+ th.gather_owncoin(&Holder::Alice, &airdrop_params.outputs[0], None)?;
|
|
|
|
|
|
- info!("[Bob] Building BOB token mint tx");
|
|
|
- let (token_mint_tx, token_mint_params) =
|
|
|
- th.token_mint(BOB_SUPPLY, &Holder::Bob, &Holder::Bob, None, None)?;
|
|
|
+ info!("[Bob] Building BOB token mint tx");
|
|
|
+ let (token_mint_tx, token_mint_params) =
|
|
|
+ th.token_mint(BOB_SUPPLY, &Holder::Bob, &Holder::Bob, None, None)?;
|
|
|
|
|
|
- for holder in &HOLDERS {
|
|
|
- info!("[{holder:?}] Executing BOB token mint tx");
|
|
|
- th.execute_token_mint_tx(holder, &token_mint_tx, &token_mint_params, current_slot).await?;
|
|
|
- }
|
|
|
+ for holder in &HOLDERS {
|
|
|
+ info!("[{holder:?}] Executing BOB token mint tx");
|
|
|
+ th.execute_token_mint_tx(holder, &token_mint_tx, &token_mint_params, current_slot)
|
|
|
+ .await?;
|
|
|
+ }
|
|
|
|
|
|
- th.assert_trees(&HOLDERS);
|
|
|
+ th.assert_trees(&HOLDERS);
|
|
|
|
|
|
- // Bob gathers his new coin
|
|
|
- th.gather_owncoin(&Holder::Bob, &token_mint_params.output, None)?;
|
|
|
+ // Bob gathers his new coin
|
|
|
+ th.gather_owncoin(&Holder::Bob, &token_mint_params.output, None)?;
|
|
|
|
|
|
- info!("[Bob] Building BOB token freeze tx");
|
|
|
- let (token_frz_tx, token_frz_params) = th.token_freeze(&Holder::Bob)?;
|
|
|
+ info!("[Bob] Building BOB token freeze tx");
|
|
|
+ let (token_frz_tx, token_frz_params) = th.token_freeze(&Holder::Bob)?;
|
|
|
|
|
|
- for holder in &HOLDERS {
|
|
|
- info!("[{holder:?}] Executing BOB token freeze tx");
|
|
|
- th.execute_token_freeze_tx(holder, &token_frz_tx, &token_frz_params, current_slot).await?;
|
|
|
- }
|
|
|
+ for holder in &HOLDERS {
|
|
|
+ info!("[{holder:?}] Executing BOB token freeze tx");
|
|
|
+ th.execute_token_freeze_tx(holder, &token_frz_tx, &token_frz_params, current_slot)
|
|
|
+ .await?;
|
|
|
+ }
|
|
|
|
|
|
- th.assert_trees(&HOLDERS);
|
|
|
+ th.assert_trees(&HOLDERS);
|
|
|
|
|
|
- // Statistics
|
|
|
- th.statistics();
|
|
|
+ // Statistics
|
|
|
+ th.statistics();
|
|
|
|
|
|
- // Thanks for reading
|
|
|
- Ok(())
|
|
|
+ // Thanks for reading
|
|
|
+ Ok(())
|
|
|
+ })
|
|
|
}
|