diff --git a/base_layer/core/src/base_node/sync/rpc/tests.rs b/base_layer/core/src/base_node/sync/rpc/tests.rs index 288bfd1b9d..0dce959789 100644 --- a/base_layer/core/src/base_node/sync/rpc/tests.rs +++ b/base_layer/core/src/base_node/sync/rpc/tests.rs @@ -157,8 +157,10 @@ mod sync_utxos { let (_, chain) = create_main_chain(&db, block_specs!(["A->GB"], ["B->A"])); let block = chain.get("B").unwrap(); + let total_outputs = block.block().header.output_mmr_size; + let start = total_outputs - 2; let msg = SyncUtxosRequest { - start: 3500, + start, end_header_hash: block.hash().clone(), include_pruned_utxos: true, include_deleted_bitmaps: false, @@ -170,6 +172,6 @@ mod sync_utxos { .collect::>() .await; - assert!(utxo_indexes.iter().all(|index| (3500..=4002).contains(index))); + assert!(utxo_indexes.iter().all(|index| (start..=start + 2).contains(index))); } } diff --git a/base_layer/core/src/chain_storage/tests/blockchain_database.rs b/base_layer/core/src/chain_storage/tests/blockchain_database.rs index 3a72ea901d..d54c598ff2 100644 --- a/base_layer/core/src/chain_storage/tests/blockchain_database.rs +++ b/base_layer/core/src/chain_storage/tests/blockchain_database.rs @@ -526,11 +526,12 @@ mod fetch_total_size_stats { #[test] fn it_measures_the_number_of_entries() { let db = setup(); + let genesis_output_count = db.fetch_header(0).unwrap().unwrap().output_mmr_size; let _block_and_outputs = add_many_chained_blocks(2, &db); let stats = db.fetch_total_size_stats().unwrap(); assert_eq!( stats.sizes().iter().find(|s| s.name == "utxos_db").unwrap().num_entries, - 4003 + genesis_output_count + 2 ); } } @@ -580,7 +581,7 @@ mod fetch_header_containing_utxo_mmr { fn it_returns_genesis() { let db = setup(); let genesis = db.fetch_block(0).unwrap(); - assert_eq!(genesis.block().body.outputs().len(), 4001); + assert!(!genesis.block().body.outputs().is_empty()); let mut mmr_position = 0; genesis.block().body.outputs().iter().for_each(|_| { let header = db.fetch_header_containing_utxo_mmr(mmr_position).unwrap(); diff --git a/base_layer/core/src/consensus/consensus_constants.rs b/base_layer/core/src/consensus/consensus_constants.rs index a76a371f02..109cc1270c 100644 --- a/base_layer/core/src/consensus/consensus_constants.rs +++ b/base_layer/core/src/consensus/consensus_constants.rs @@ -296,7 +296,7 @@ impl ConsensusConstants { vec![ConsensusConstants { effective_from_height: 0, coinbase_lock_height: 2, - blockchain_version: 1, + blockchain_version: 2, valid_blockchain_version_range: 0..=3, future_time_limit: 540, difficulty_block_window, diff --git a/base_layer/core/src/transactions/transaction_components/transaction_output.rs b/base_layer/core/src/transactions/transaction_components/transaction_output.rs index 2355a7ac4d..37ff26d6db 100644 --- a/base_layer/core/src/transactions/transaction_components/transaction_output.rs +++ b/base_layer/core/src/transactions/transaction_components/transaction_output.rs @@ -275,7 +275,7 @@ impl TransactionOutput { encrypted_value: &EncryptedValue, minimum_value_promise: MicroTari, ) -> [u8; 32] { - let common = DomainSeparatedConsensusHasher::::new("metadata_signature_challenge") + let common = DomainSeparatedConsensusHasher::::new("metadata_signature") .chain(public_commitment_nonce) .chain(script) .chain(features) diff --git a/base_layer/core/tests/node_comms_interface.rs b/base_layer/core/tests/node_comms_interface.rs index 4eb4a5b780..ad2d204c9d 100644 --- a/base_layer/core/tests/node_comms_interface.rs +++ b/base_layer/core/tests/node_comms_interface.rs @@ -323,8 +323,7 @@ async fn inbound_fetch_blocks() { #[allow(clippy::too_many_lines)] async fn inbound_fetch_blocks_before_horizon_height() { let factories = CryptoFactories::default(); - let network = Network::LocalNet; - let consensus_manager = ConsensusManager::builder(network).build(); + let consensus_manager = ConsensusManager::builder(Network::Dibbler).build(); let block0 = consensus_manager.get_genesis_block(); let validators = Validators::new( MockValidator::new(true), diff --git a/base_layer/tari_mining_helper_ffi/src/lib.rs b/base_layer/tari_mining_helper_ffi/src/lib.rs index 2983407340..d440511ca8 100644 --- a/base_layer/tari_mining_helper_ffi/src/lib.rs +++ b/base_layer/tari_mining_helper_ffi/src/lib.rs @@ -371,8 +371,8 @@ mod tests { #[test] fn detect_change_in_consensus_encoding() { - const NONCE: u64 = 7157305302409646947; - const DIFFICULTY: Difficulty = Difficulty::from_u64(6126); + const NONCE: u64 = 8624065455907397555; + const DIFFICULTY: Difficulty = Difficulty::from_u64(11786); // Use this to generate new NONCE and DIFFICULTY // Use ONLY if you know encoding has changed // let (difficulty, nonce) = generate_nonce_with_min_difficulty(MIN_DIFFICULTY).unwrap(); diff --git a/comms/core/src/utils/multiaddr.rs b/comms/core/src/utils/multiaddr.rs index bc1b3669db..cb8fe79ad4 100644 --- a/comms/core/src/utils/multiaddr.rs +++ b/comms/core/src/utils/multiaddr.rs @@ -89,15 +89,15 @@ mod test { #[test] fn multiaddr_to_socketaddr_ok() { - fn expect_success(addr: &str, expected_ip: &str) { + fn expect_success(addr: &str, expected_ips: &[&str]) { let addr = Multiaddr::from_str(addr).unwrap(); let sock_addr = super::multiaddr_to_socketaddr(&addr).unwrap(); - assert_eq!(sock_addr.ip().to_string(), expected_ip); + assert!(expected_ips.iter().any(|ip| *ip == sock_addr.ip().to_string())); } - expect_success("/ip4/254.0.1.2/tcp/1234", "254.0.1.2"); - expect_success("/ip6/::1/tcp/1234", "::1"); - expect_success("/dns4/taridns.dyn-ip.me/tcp/1234", "127.0.0.1"); + expect_success("/ip4/254.0.1.2/tcp/1234", &["254.0.1.2"]); + expect_success("/ip6/::1/tcp/1234", &["::1"]); + expect_success("/dns4/localhost/tcp/1234", &["::1", "127.0.0.1"]); } #[test] diff --git a/integration_tests/helpers/transactionBuilder.js b/integration_tests/helpers/transactionBuilder.js index 7fb1f8f865..282076e80d 100644 --- a/integration_tests/helpers/transactionBuilder.js +++ b/integration_tests/helpers/transactionBuilder.js @@ -95,18 +95,17 @@ class TransactionBuilder { covenant, encryptedValue ) { - const buf_nonce = Buffer.from(publicNonce, "hex"); - const script_offset_public_key = Buffer.from(scriptOffsetPublicKey, "hex"); + const publicCommitmentNonce = Buffer.from(publicNonce, "hex"); + const sender_offset_public_key = Buffer.from(scriptOffsetPublicKey, "hex"); const features_buffer = this.featuresToConsensusBytes(features); - // base_layer/core/src/transactions/transaction/transaction_output.rs let hash = new DomainHasher( "com.tari.base_layer.core.transactions.v0.metadata_signature" ) - .chain(buf_nonce) + .chain(publicCommitmentNonce) .chain(this.toLengthEncoded(script)) .chain(features_buffer) - .chain(script_offset_public_key) + .chain(sender_offset_public_key) .chain(commitment) .chain(this.toLengthEncoded(covenant)) .chain(encryptedValue)