1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#![allow(dead_code)]
use crate::crypto::{
    AnchorDataHash, AuxiliaryDataHash, GenesisDelegateHash, GenesisHash, PoolMetadataHash, ScriptDataHash, ScriptHash, VRFKeyHash,
};
use crate::{
    to_bignum, Address, BaseAddress, Bip32PrivateKey, Credential, DataHash, Ed25519KeyHash,
    Ed25519Signature, NetworkInfo, PolicyID, TransactionHash, TransactionIndex, TransactionInput,
    TransactionOutput, Value, Vkey, AssetName,
};
use crate::address::RewardAddress;

pub(crate) fn fake_bytes_32(x: u8) -> Vec<u8> {
    vec![
        x, 239, 181, 120, 142, 135, 19, 200, 68, 223, 211, 43, 46, 145, 222, 30, 48, 159, 239, 255,
        213, 85, 248, 39, 204, 158, 225, 100, 1, 2, 3, 4,
    ]
}

pub(crate) fn fake_data_hash(x: u8) -> DataHash {
    DataHash::from_bytes(fake_bytes_32(x)).unwrap()
}

pub(crate) fn fake_anchor_data_hash(x: u8) -> AnchorDataHash {
    AnchorDataHash::from_bytes(fake_bytes_32(x)).unwrap()
}

pub(crate) fn fake_auxiliary_data_hash(x: u8) -> AuxiliaryDataHash {
    AuxiliaryDataHash::from_bytes(fake_bytes_32(x)).unwrap()
}

pub(crate) fn fake_pool_metadata_hash(x: u8) -> PoolMetadataHash {
    PoolMetadataHash::from_bytes(fake_bytes_32(x)).unwrap()
}

pub(crate) fn fake_genesis_hash(x: u8) -> GenesisHash {
    GenesisHash::from_bytes((&fake_bytes_32(x)[0..28]).to_vec()).unwrap()
}

pub(crate) fn fake_genesis_delegate_hash(x: u8) -> GenesisDelegateHash {
    GenesisDelegateHash::from_bytes((&fake_bytes_32(x)[0..28]).to_vec()).unwrap()
}

pub(crate) fn fake_vrf_key_hash(x: u8) -> VRFKeyHash {
    VRFKeyHash::from_bytes(fake_bytes_32(x)).unwrap()
}

pub(crate) fn fake_key_hash(x: u8) -> Ed25519KeyHash {
    Ed25519KeyHash::from_bytes((&fake_bytes_32(x)[0..28]).to_vec()).unwrap()
}

pub(crate) fn fake_script_hash(x: u8) -> ScriptHash {
    ScriptHash::from_bytes((&fake_bytes_32(x)[0..28]).to_vec()).unwrap()
}

pub(crate) fn fake_script_data_hash(x: u8) -> ScriptDataHash {
    ScriptDataHash::from_bytes(fake_bytes_32(x)).unwrap()
}

pub(crate) fn fake_base_address(x: u8) -> Address {
    BaseAddress::new(
        NetworkInfo::testnet().network_id(),
        &Credential::from_keyhash(&fake_key_hash(x)),
        &Credential::from_keyhash(&fake_key_hash(0)),
    )
    .to_address()
}

pub(crate) fn fake_reward_address(x: u8) -> RewardAddress {
    RewardAddress::new(
        NetworkInfo::testnet().network_id(),
        &Credential::from_keyhash(&fake_key_hash(x)),
    )
}

pub(crate) fn fake_tx_hash(input_hash_byte: u8) -> TransactionHash {
    TransactionHash::from([input_hash_byte; 32])
}

pub(crate) fn fake_tx_input(input_hash_byte: u8) -> TransactionInput {
    fake_tx_input2(input_hash_byte, 0)
}

pub(crate) fn fake_tx_input2(input_hash_byte: u8, idx: TransactionIndex) -> TransactionInput {
    TransactionInput::new(&fake_tx_hash(input_hash_byte), idx)
}

pub(crate) fn fake_value() -> Value {
    fake_value2(1_000_000)
}

pub(crate) fn fake_value2(v: u64) -> Value {
    Value::new(&to_bignum(v))
}

pub(crate) fn fake_tx_output(input_hash_byte: u8) -> TransactionOutput {
    TransactionOutput::new(&fake_base_address(input_hash_byte), &fake_value())
}

pub(crate) fn fake_tx_output2(input_hash_byte: u8, val: u64) -> TransactionOutput {
    TransactionOutput::new(&fake_base_address(input_hash_byte), &fake_value2(val))
}

pub(crate) fn fake_vkey() -> Vkey {
    Vkey::new(
        &Bip32PrivateKey::generate_ed25519_bip32()
            .unwrap()
            .to_public()
            .to_raw_key(),
    )
}

pub(crate) fn fake_signature(x: u8) -> Ed25519Signature {
    Ed25519Signature::from_bytes([x; 64].to_vec()).unwrap()
}

pub(crate) fn fake_policy_id(x: u8) -> PolicyID {
    PolicyID::from([x; 28])
}

pub(crate) fn fake_asset_name(x: u8) -> AssetName {
    AssetName([x; 32].to_vec())
}