Skip to content

Commit e18f44e

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

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

wallet/src/signer/tests/generic_tests.rs

Lines changed: 9 additions & 8 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,10 +564,8 @@ 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());
566-
let htlc_utxo = TxOutput::Htlc(
567-
OutputValue::Coin(Amount::from_atoms(rng.random::<u32>() as u128)),
568-
Box::new(htlc.clone()),
569-
);
567+
let htlc_amount = coin_input_amounts[1];
568+
let htlc_utxo = TxOutput::Htlc(OutputValue::Coin(htlc_amount), Box::new(htlc.clone()));
570569

571570
let token_id = TokenId::new(H256::random_using(rng));
572571
let token_mint_amount = Amount::from_atoms(rng.random_range(100..200));
@@ -577,6 +576,7 @@ pub async fn test_sign_transaction_generic<MkS1, MkS2, S1, S2>(
577576
let coin_burn_amount = total_coin_input_amount.div(rng.random_range(10..20)).unwrap();
578577
let delegate_staking_amount = total_coin_input_amount.div(rng.random_range(10..20)).unwrap();
579578
let htlc_transfer_amount = total_coin_input_amount.div(rng.random_range(10..20)).unwrap();
579+
let created_order_ask = total_coin_input_amount.div(rng.random_range(10..20)).unwrap();
580580

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

694694
let created_pool_id = PoolId::new(H256::random_using(rng));
695695
let delegation_id = DelegationId::new(H256::random_using(rng));
696+
let pool_amount = coin_input_amounts[2];
696697
let pool_data = StakePoolData::new(
697-
Amount::from_atoms(rng.random_range(100..200)),
698+
pool_amount,
698699
Destination::PublicKey(dest_pub.clone()),
699700
vrf_public_key,
700701
Destination::PublicKey(dest_pub.clone()),
@@ -744,8 +745,8 @@ pub async fn test_sign_transaction_generic<MkS1, MkS2, S1, S2>(
744745

745746
let created_order_data = OrderData::new(
746747
Destination::PublicKey(dest_pub.clone()),
747-
OutputValue::Coin(Amount::from_atoms(rng.random_range(100..200))),
748748
OutputValue::TokenV1(token_id, Amount::from_atoms(rng.random_range(100..200))),
749+
OutputValue::Coin(created_order_ask),
749750
);
750751

751752
let outputs = vec![

0 commit comments

Comments
 (0)