Skip to content

Commit

Permalink
Fixed failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
4TT1L4 committed Oct 18, 2024
1 parent 67f1aae commit 29049f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions bitcoin/src/blockdata/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ pub const MAX_MONEY: u64 = 21_000_000 * COIN_VALUE;

/// Constructs and returns the coinbase (and only) transaction of the Bitcoin genesis block.
fn bitcoin_genesis_tx(network: Network) -> Transaction {
if network == Network::Bitcoin {
return bitcoin_mainnet_genesis_tx();
if network == Network::Testnet {
return bitcoin_testnet4_genesis_tx();
} else {
return bitcoin_testnet_genesis_tx();
return bitcoin_default_genesis_tx();
}

}

/// Constructs and returns the coinbase (and only) transaction of the Bitcoin genesis block.
fn bitcoin_mainnet_genesis_tx() -> Transaction {
fn bitcoin_default_genesis_tx() -> Transaction {
// Base
let mut ret = Transaction {
version: 1,
Expand Down Expand Up @@ -131,7 +131,7 @@ fn bitcoin_mainnet_genesis_tx() -> Transaction {


/// Constructs and returns the coinbase (and only) transaction of the Bitcoin genesis block.
fn bitcoin_testnet_genesis_tx() -> Transaction {
fn bitcoin_testnet4_genesis_tx() -> Transaction {
// Base
let mut ret = Transaction {
version: 1,
Expand Down Expand Up @@ -300,11 +300,11 @@ mod test {
let gen = genesis_block(Network::Testnet);
assert_eq!(gen.header.version, block::Version::ONE);
assert_eq!(gen.header.prev_blockhash, Hash::all_zeros());
assert_eq!(gen.header.merkle_root.to_string(), "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b");
assert_eq!(gen.header.time, 1296688602);
assert_eq!(gen.header.merkle_root.to_string(), "7aa0a7ae1e223414cb807e40cd57e667b718e42aaf9306db9102fe28912b7b4e");
assert_eq!(gen.header.time, 1714777860);
assert_eq!(gen.header.bits, CompactTarget::from_consensus(0x1d00ffff));
assert_eq!(gen.header.nonce, 414098458);
assert_eq!(gen.header.block_hash().to_string(), "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943");
assert_eq!(gen.header.nonce, 393743547);
assert_eq!(gen.header.block_hash().to_string(), "00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043");
}

#[test]
Expand Down
8 changes: 4 additions & 4 deletions bitcoin/src/network/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub const PROTOCOL_VERSION: u32 = 70001;
pub enum Network {
/// Mainnet Bitcoin.
Bitcoin,
/// Bitcoin's testnet network.
/// Bitcoin's testnet4 network.
Testnet,
/// Bitcoin's signet network.
Signet,
Expand Down Expand Up @@ -554,12 +554,12 @@ mod tests {
#[test]
fn serialize_test() {
assert_eq!(serialize(&Network::Bitcoin.magic()), &[0xf9, 0xbe, 0xb4, 0xd9]);
assert_eq!(serialize(&Network::Testnet.magic()), &[0x0b, 0x11, 0x09, 0x07]);
assert_eq!(serialize(&Network::Testnet.magic()), &[0x1c, 0x16, 0x3f, 0x28]);
assert_eq!(serialize(&Network::Signet.magic()), &[0x0a, 0x03, 0xcf, 0x40]);
assert_eq!(serialize(&Network::Regtest.magic()), &[0xfa, 0xbf, 0xb5, 0xda]);

assert_eq!(deserialize(&[0xf9, 0xbe, 0xb4, 0xd9]).ok(), Some(Network::Bitcoin.magic()));
assert_eq!(deserialize(&[0x0b, 0x11, 0x09, 0x07]).ok(), Some(Network::Testnet.magic()));
assert_eq!(deserialize(&[0x1c, 0x16, 0x3f, 0x28]).ok(), Some(Network::Testnet.magic()));
assert_eq!(deserialize(&[0x0a, 0x03, 0xcf, 0x40]).ok(), Some(Network::Signet.magic()));
assert_eq!(deserialize(&[0xfa, 0xbf, 0xb5, 0xda]).ok(), Some(Network::Regtest.magic()));
}
Expand Down Expand Up @@ -645,7 +645,7 @@ mod tests {
fn magic_from_str() {
let known_network_magic_strs = [
("f9beb4d9", Network::Bitcoin),
("0b110907", Network::Testnet),
("1c163f28", Network::Testnet),
("fabfb5da", Network::Regtest),
("0a03cf40", Network::Signet),
];
Expand Down

0 comments on commit 29049f5

Please sign in to comment.