Add `OutPoint::fake()` helper.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
cefbaf59d5
commit
6d35583a4b
|
@ -1206,7 +1206,7 @@ pub(crate) fn shield_transparent<T: ShieldedPoolTester>() {
|
|||
st.scan_cached_blocks(h, 1);
|
||||
|
||||
let utxo = WalletTransparentOutput::from_parts(
|
||||
OutPoint::new([1u8; 32], 1),
|
||||
OutPoint::fake(),
|
||||
TxOut {
|
||||
value: NonNegativeAmount::const_from_u64(10000),
|
||||
script_pubkey: taddr.script(),
|
||||
|
|
|
@ -2919,7 +2919,7 @@ mod tests {
|
|||
|
||||
// Create a fake transparent output.
|
||||
let value = NonNegativeAmount::const_from_u64(100000);
|
||||
let outpoint = OutPoint::new([1u8; 32], 1);
|
||||
let outpoint = OutPoint::fake();
|
||||
let txout = TxOut {
|
||||
value,
|
||||
script_pubkey: taddr.script(),
|
||||
|
@ -3098,7 +3098,6 @@ mod tests {
|
|||
|
||||
// Create a fake transparent output.
|
||||
let value = NonNegativeAmount::from_u64(100000).unwrap();
|
||||
let outpoint = OutPoint::new([1u8; 32], 1);
|
||||
let txout = TxOut {
|
||||
value,
|
||||
script_pubkey: taddr.script(),
|
||||
|
@ -3106,7 +3105,7 @@ mod tests {
|
|||
|
||||
// Pretend the output was received in the chain tip.
|
||||
let height = st.wallet().chain_height().unwrap().unwrap();
|
||||
let utxo = WalletTransparentOutput::from_parts(outpoint, txout, height).unwrap();
|
||||
let utxo = WalletTransparentOutput::from_parts(OutPoint::fake(), txout, height).unwrap();
|
||||
st.wallet_mut()
|
||||
.put_received_transparent_utxo(&utxo)
|
||||
.unwrap();
|
||||
|
|
|
@ -420,7 +420,7 @@ mod tests {
|
|||
BlockHeight::from(3),
|
||||
Some(transparent::Bundle {
|
||||
vin: vec![TxIn {
|
||||
prevout: OutPoint::new([1u8; 32], 1),
|
||||
prevout: OutPoint::fake(),
|
||||
script_sig: Script(vec![]),
|
||||
sequence: 0,
|
||||
}],
|
||||
|
|
|
@ -100,6 +100,15 @@ impl OutPoint {
|
|||
OutPoint { hash, n }
|
||||
}
|
||||
|
||||
/// Constructs a fake `OutPoint` for use in tests.
|
||||
#[cfg(any(test, feature = "test-dependencies"))]
|
||||
pub const fn fake() -> Self {
|
||||
OutPoint {
|
||||
hash: [1u8; 32],
|
||||
n: 1,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read<R: Read>(mut reader: R) -> io::Result<Self> {
|
||||
let mut hash = [0u8; 32];
|
||||
reader.read_exact(&mut hash)?;
|
||||
|
|
Loading…
Reference in New Issue