From 2e7062bcb33ad24912995eb97564b9d9e7a6351b Mon Sep 17 00:00:00 2001 From: Velnbur Date: Mon, 28 Oct 2024 13:31:14 +0200 Subject: [PATCH] Move values to constants --- integration-tests/src/taproot.rs | 34 ++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/integration-tests/src/taproot.rs b/integration-tests/src/taproot.rs index ac2c305..a6d330c 100644 --- a/integration-tests/src/taproot.rs +++ b/integration-tests/src/taproot.rs @@ -129,6 +129,10 @@ fn test_script_payout_spending() -> eyre::Res where S: SplitableScript, { + // Approximate amount of satoshis to fullfill the fees for all + // transactions in tests. + const APPROX_TXOUT_AMOUNT: u64 = 71_000; + let TestSetup { ctx, client, @@ -138,13 +142,13 @@ where funding_txout, funder_address, .. - } = setup_test::(71_000)?; + } = setup_test::(APPROX_TXOUT_AMOUNT)?; let operator_xonly = OPERATOR_PUBKEY.x_only_public_key().0; let assert_tx = AssertTransaction::<{ I }, { O }, S>::with_options( input_script, operator_xonly, - Amount::from_sat(70_000), + Amount::from_sat(APPROX_TXOUT_AMOUNT - 1_000), Options { payout_locktime: Height::from(1), }, @@ -165,7 +169,7 @@ where let payout_tx = assert_tx.payout_transaction( &ctx, TxOut { - value: Amount::from_sat(69_000), + value: Amount::from_sat(APPROX_TXOUT_AMOUNT - 2_000), script_pubkey: funding_txout.script_pubkey, }, OutPoint::new(atx.compute_txid(), 0), @@ -184,6 +188,10 @@ fn test_script_disprove_distorted() -> eyre:: where S: SplitableScript, { + // Approximate amount of satoshis to fullfill the fees for all + // transactions in tests. + const APPROX_TXOUT_AMOUNT: u64 = 100_000; + let TestSetup { ctx, client, @@ -193,14 +201,15 @@ where funding_txout, funder_address, .. - } = setup_test::(100_000)?; + } = setup_test::(APPROX_TXOUT_AMOUNT)?; let operator_xonly = OPERATOR_PUBKEY.x_only_public_key().0; let (assert_tx, distored_idx) = AssertTransaction::<{ I }, { O }, S>::with_options_distorted::<[u8; 32], SmallRng>( input_script, operator_xonly, - Amount::from_sat(90_000), + // remove 10% from amount to fulfill the fee + Amount::from_sat(APPROX_TXOUT_AMOUNT * 9 / 10), Options { payout_locktime: Height::from(1), }, @@ -222,7 +231,10 @@ where let disprove_txs = assert_tx.clone().disprove_transactions( &ctx, TxOut { - value: Amount::from_sat(9_000), + // take only 10% percent and leave other for the fee. + // This values is euristic and should calculated by + // ourself instead in future. + value: Amount::from_sat(APPROX_TXOUT_AMOUNT / 10), script_pubkey: funding_txout.script_pubkey, }, OutPoint::new(atx.compute_txid(), 0), @@ -247,7 +259,7 @@ where } #[test] -#[ignore = "Stack size limit exceeded"] +#[ignore = "tx-size"] fn test_u254_mul_disprove() -> eyre::Result<()> { color_eyre::install()?; tracing_subscriber::fmt().init(); @@ -271,12 +283,14 @@ fn test_u254_mul_payout() -> eyre::Result<()> { #[test] fn test_square_fibonachi() -> eyre::Result<()> { + const FIB_STEPS: usize = 1024; + color_eyre::install()?; tracing_subscriber::fmt().init(); test_script_disprove_distorted::< - { SquareFibonacciScript::<1024>::INPUT_SIZE }, - { SquareFibonacciScript::<1024>::OUTPUT_SIZE }, - SquareFibonacciScript<1024>, + { SquareFibonacciScript::::INPUT_SIZE }, + { SquareFibonacciScript::::OUTPUT_SIZE }, + SquareFibonacciScript, >() }