Просмотр исходного кода

contract: Fix test compilation.

parazyd 3 лет назад
Родитель
Сommit
ae6a2b7707

+ 1 - 1
src/contract/consensus/Cargo.toml

@@ -25,7 +25,7 @@ rand = { version = "0.8.5", optional = true }
 
 # These are used just for the integration tests
 [dev-dependencies]
-async-std = {version = "1.12.0", features = ["attributes"]}
+smol = "1.3.0"
 bs58 = "0.5.0"
 darkfi = {path = "../../../", features = ["tx", "blockchain"]}
 darkfi-money-contract = { path = "../money", features = ["client", "no-entrypoint"] }

+ 1 - 1
src/contract/dao/Cargo.toml

@@ -25,7 +25,7 @@ rand = { version = "0.8.5", optional = true }
 
 # These are used just for the integration tests
 [dev-dependencies]
-async-std = {version = "1.12.0", features = ["attributes"]}
+smol = "1.3.0"
 darkfi = {path = "../../../", features = ["tx", "blockchain"]}
 darkfi-money-contract = {path = "../money", features = ["client", "no-entrypoint"]}
 simplelog = "0.12.1"

+ 1 - 1
src/contract/money/Cargo.toml

@@ -24,7 +24,7 @@ rand = { version = "0.8.5", optional = true }
 
 # These are used just for the integration tests
 [dev-dependencies]
-async-std = {version = "1.12.0", features = ["attributes"]}
+smol = "1.3.0"
 darkfi = {path = "../../../", features = ["tx", "blockchain"]}
 simplelog = "0.12.1"
 sled = "0.34.7"

+ 47 - 43
src/contract/money/tests/integration.rs

@@ -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(())
+    })
 }