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

src/contract/money: added tests filtering in make

aggstam 3 лет назад
Родитель
Сommit
2b350a9e5d
2 измененных файлов с 54 добавлено и 1 удалено
  1. 4 1
      src/contract/money/Makefile
  2. 50 0
      src/contract/money/tests/tx_verification.rs

+ 4 - 1
src/contract/money/Makefile

@@ -19,6 +19,9 @@ ZKAS_BIN = $(ZKAS_SRC:=.bin)
 # Contract WASM binaries
 WASM_BIN = money_contract.wasm
 
+# Filter test to run
+FILTER = 'tx_faucet_verification'
+
 all: $(ZKAS_BIN) $(WASM_BIN)
 
 $(ZKAS_BIN): $(ZKAS_SRC)
@@ -35,7 +38,7 @@ test-transfer: all
 	$(CARGO) test --release --features=no-entrypoint,client --package darkfi-money-contract --test transfer
 	
 test-tx-verification: all
-	$(CARGO) test --release --features=no-entrypoint,client --package darkfi-money-contract --test tx_verification
+	$(CARGO) test --release --features=no-entrypoint,client --package darkfi-money-contract --test tx_verification $(FILTER)
 
 test: test-otc test-transfer test-tx-verification
 

+ 50 - 0
src/contract/money/tests/tx_verification.rs

@@ -253,3 +253,53 @@ async fn tx_faucet_verification() -> Result<()> {
 
     Ok(())
 }
+
+/// Check Alice to Alice N transactions with same amount verification performance
+#[async_std::test]
+async fn tx_alice_to_alice_verification() -> Result<()> {
+    init_logger()?;
+
+    // Test configuration
+    let _n = 10;
+
+    // We initialize the faucet that will generate the airdrop transaction.
+    let (
+        faucet_state,
+        faucet_kp,
+        faucet_merkle_tree,
+        contract_id,
+        mint_zkbin,
+        mint_pk,
+        burn_zkbin,
+        burn_pk,
+    ) = init_faucet().await?;
+
+    // Generating airdrop transaction
+    info!("Generating faucet airdrop transaction");
+    let alice_kp = Keypair::random(&mut OsRng);
+    let token_id = TokenId::from(pallas::Base::random(&mut OsRng));
+    let amount = decode_base10("42.69", 8, true)?;
+    let tx = generate_airdrop_tx(
+        &faucet_kp,
+        &faucet_merkle_tree,
+        &alice_kp.public,
+        token_id,
+        amount,
+        contract_id,
+        &mint_zkbin,
+        &mint_pk,
+        &burn_zkbin,
+        &burn_pk,
+    )?;
+
+    // Verifying airdrop transactions
+    info!("Verifying faucet airdrop transaction...");
+    let init = Timestamp::current_time();
+    faucet_state.read().await.verify_transactions(&[tx], true).await?;
+    let verification_elapsed_time = init.elapsed();
+
+    info!("Processing time of faucet airdrop transaction(in sec):");
+    info!("\tVerification -> {}", verification_elapsed_time);
+
+    Ok(())
+}