Skip to content

Commit 1177db6

Browse files
committed
fix signer test input/output amounts
1 parent 79f0570 commit 1177db6

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

wallet/src/signer/tests/generic_tests.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ pub async fn test_sign_transaction_generic<MkS1, MkS2, S1, S2>(
391391
.unwrap();
392392
let standalone_pk_destination = Destination::PublicKey(standalone_pk.clone());
393393

394-
let coin_input_amounts: Vec<Amount> = (0..rng.random_range(2..7))
394+
let min_input_amounts = 4; // 1 utxo, 1 standalone, 1 create pool, 1 htlc
395+
let coin_input_amounts: Vec<Amount> = (0..rng.random_range(min_input_amounts..7))
395396
.map(|_| Amount::from_atoms(rng.random_range(100..1000)))
396397
.collect();
397398

@@ -426,7 +427,7 @@ pub async fn test_sign_transaction_generic<MkS1, MkS2, S1, S2>(
426427
TxOutput::ProduceBlockFromStake(random_destination(rng), decommissioned_pool_id);
427428
let utxos: Vec<TxOutput> = coin_input_amounts
428429
.iter()
429-
.skip(1)
430+
.skip(min_input_amounts - 1)
430431
.map(|a| {
431432
let dest = destination_from_account(&mut account, &mut db_tx, rng);
432433

@@ -563,8 +564,9 @@ pub async fn test_sign_transaction_generic<MkS1, MkS2, S1, S2>(
563564
};
564565

565566
let htlc_input = TxInput::from_utxo(source_id, rng.next_u32());
567+
let htlc_amount = coin_input_amounts[1];
566568
let htlc_utxo = TxOutput::Htlc(
567-
OutputValue::Coin(Amount::from_atoms(rng.random::<u32>() as u128)),
569+
OutputValue::Coin(htlc_amount),
568570
Box::new(htlc.clone()),
569571
);
570572

@@ -577,6 +579,7 @@ pub async fn test_sign_transaction_generic<MkS1, MkS2, S1, S2>(
577579
let coin_burn_amount = total_coin_input_amount.div(rng.random_range(10..20)).unwrap();
578580
let delegate_staking_amount = total_coin_input_amount.div(rng.random_range(10..20)).unwrap();
579581
let htlc_transfer_amount = total_coin_input_amount.div(rng.random_range(10..20)).unwrap();
582+
let created_order_ask = total_coin_input_amount.div(rng.random_range(10..20)).unwrap();
580583

581584
let filled_order1_id = OrderId::new(H256::random_using(rng));
582585
let filled_order2_id = OrderId::new(H256::random_using(rng));
@@ -693,8 +696,9 @@ pub async fn test_sign_transaction_generic<MkS1, MkS2, S1, S2>(
693696

694697
let created_pool_id = PoolId::new(H256::random_using(rng));
695698
let delegation_id = DelegationId::new(H256::random_using(rng));
699+
let pool_amount = coin_input_amounts[2];
696700
let pool_data = StakePoolData::new(
697-
Amount::from_atoms(rng.random_range(100..200)),
701+
pool_amount,
698702
Destination::PublicKey(dest_pub.clone()),
699703
vrf_public_key,
700704
Destination::PublicKey(dest_pub.clone()),
@@ -744,8 +748,8 @@ pub async fn test_sign_transaction_generic<MkS1, MkS2, S1, S2>(
744748

745749
let created_order_data = OrderData::new(
746750
Destination::PublicKey(dest_pub.clone()),
747-
OutputValue::Coin(Amount::from_atoms(rng.random_range(100..200))),
748751
OutputValue::TokenV1(token_id, Amount::from_atoms(rng.random_range(100..200))),
752+
OutputValue::Coin(created_order_ask),
749753
);
750754

751755
let outputs = vec![

0 commit comments

Comments
 (0)