From a12ecdf39c228fede0fe8e6d8969ace40289cdf7 Mon Sep 17 00:00:00 2001 From: Alan Szepieniec Date: Sat, 12 Oct 2024 22:11:43 +0200 Subject: [PATCH] test: Fix test `block_template_is_valid` Configuration `tx_proving_capability` defaults to estimating using heuristics. On some machines, this heuristic resolves to `ProofCollection`, in which case transactions are produced that cannot be merged. The fix is to override this setting using the function with more fine-grained arguments, `create_transaction_with_prover_capability` and feed it `TxProvingCapability::SingleProof`. This results in transactions whose validity is supported by `SingleProof`s rather than `ProofCollection`s, which the miner *can* merge. When the test is run on a machine not capable of producing a `SingleProof`, it must rely on a proof server. --- src/mine_loop.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/mine_loop.rs b/src/mine_loop.rs index ad4834fe..fff43e63 100644 --- a/src/mine_loop.rs +++ b/src/mine_loop.rs @@ -545,7 +545,7 @@ mod mine_loop_tests { #[traced_test] #[tokio::test] - async fn block_template_is_valid_test() -> Result<()> { + async fn block_template_is_valid_test() { // Verify that a block template made with transaction from the mempool is a valid block let network = Network::Main; let mut alice = mock_genesis_global_state(network, 2, WalletSecret::devnet_wallet()).await; @@ -611,20 +611,24 @@ mod mine_loop_tests { .wallet_state .wallet_secret .nth_generation_spending_key_for_tests(0); + let output_to_alice = TxOutput::offchain_native_currency( + NeptuneCoins::new(4), + rng.gen(), + alice_key.to_address().into(), + ); + // About ProveCapability::SingleProof: + // The thing being tested is that the block template *for the _miner_* + // is valid. The miner is assumed capable of producing `SingleProof`s. let (tx_by_preminer, _maybe_change_output) = alice .lock_guard() .await - .create_transaction( - vec![TxOutput::offchain_native_currency( - NeptuneCoins::new(4), - rng.gen(), - alice_key.to_address().into(), - )] - .into(), + .create_transaction_with_prover_capability( + vec![output_to_alice].into(), alice_key.into(), UtxoNotificationMedium::OffChain, NeptuneCoins::new(1), in_seven_months, + TxProvingCapability::SingleProof, ) .await .unwrap(); @@ -663,8 +667,6 @@ mod mine_loop_tests { .is_valid(&genesis_block, in_seven_months + Timestamp::seconds(2)), "Block template created by miner with non-empty mempool must be valid" ); - - Ok(()) } /// This test mines a single block at height 1 on the regtest network