diff --git a/applications/minotari_console_wallet/src/automation/commands.rs b/applications/minotari_console_wallet/src/automation/commands.rs index ed20171dde..3647acdc8d 100644 --- a/applications/minotari_console_wallet/src/automation/commands.rs +++ b/applications/minotari_console_wallet/src/automation/commands.rs @@ -1117,7 +1117,7 @@ async fn get_tip_height(wallet: &WalletSqlite) -> Option { .await .ok() .and_then(|t| t.metadata) - .and_then(|m| m.height_of_longest_chain), + .map(|m| m.height_of_longest_chain), None => None, } } diff --git a/base_layer/core/src/base_node/chain_metadata_service/service.rs b/base_layer/core/src/base_node/chain_metadata_service/service.rs index dc33240737..e00791605f 100644 --- a/base_layer/core/src/base_node/chain_metadata_service/service.rs +++ b/base_layer/core/src/base_node/chain_metadata_service/service.rs @@ -244,14 +244,14 @@ mod test { fn create_sample_proto_chain_metadata() -> proto::ChainMetadata { let diff: u128 = 1; proto::ChainMetadata { - height_of_longest_chain: Some(1), + height_of_longest_chain: 1, best_block: Some(vec![ 0, 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, ]), pruned_height: 0, accumulated_difficulty: diff.to_be_bytes().to_vec(), - timestamp: Some(0), + timestamp: 0, } } @@ -278,7 +278,7 @@ mod test { let (mut service, liveness_mock_state, mut base_node_receiver, _) = setup(); let mut proto_chain_metadata = create_sample_proto_chain_metadata(); - proto_chain_metadata.height_of_longest_chain = Some(123); + proto_chain_metadata.height_of_longest_chain = 123; let chain_metadata = proto_chain_metadata.clone().try_into().unwrap(); task::spawn(async move { @@ -297,7 +297,7 @@ mod test { unpack_enum!(LivenessRequest::SetMetadataEntry(metadata_key, data) = last_call); assert_eq!(metadata_key, MetadataKey::ChainMetadata); let chain_metadata = proto::ChainMetadata::decode(data.as_slice()).unwrap(); - assert_eq!(chain_metadata.height_of_longest_chain, Some(123)); + assert_eq!(chain_metadata.height_of_longest_chain, 123); } #[tokio::test] async fn handle_liveness_event_ok() { @@ -320,7 +320,7 @@ mod test { assert_eq!(*metadata.node_id(), node_id); assert_eq!( metadata.claimed_chain_metadata().height_of_longest_chain(), - proto_chain_metadata.height_of_longest_chain.unwrap() + proto_chain_metadata.height_of_longest_chain ); } diff --git a/base_layer/core/src/base_node/proto/chain_metadata.proto b/base_layer/core/src/base_node/proto/chain_metadata.proto index 6acde5f455..84dbf4c334 100644 --- a/base_layer/core/src/base_node/proto/chain_metadata.proto +++ b/base_layer/core/src/base_node/proto/chain_metadata.proto @@ -9,7 +9,7 @@ package tari.base_node; message ChainMetadata { // The current chain height, or the block number of the longest valid chain, or `None` if there is no chain - google.protobuf.UInt64Value height_of_longest_chain = 1; + uint64 height_of_longest_chain = 1; // The block hash of the current tip of the longest valid chain, or `None` for an empty chain google.protobuf.BytesValue best_block = 2; // The current geometric mean of the pow of the chain tip, or `None` if there is no chain @@ -20,5 +20,5 @@ message ChainMetadata { // Archival nodes wil always have an `pruned_height` of zero. uint64 pruned_height = 6; // Timestamp of the last block in the chain, or `None` if there is no chain - google.protobuf.UInt64Value timestamp = 7; + uint64 timestamp = 7; } diff --git a/base_layer/core/src/base_node/proto/chain_metadata.rs b/base_layer/core/src/base_node/proto/chain_metadata.rs index 7a84a66c75..14b0c0a3cd 100644 --- a/base_layer/core/src/base_node/proto/chain_metadata.rs +++ b/base_layer/core/src/base_node/proto/chain_metadata.rs @@ -45,9 +45,11 @@ impl TryFrom for ChainMetadata { let mut acc_diff = [0; ACC_DIFFICULTY_ARRAY_LEN]; acc_diff.copy_from_slice(&metadata.accumulated_difficulty[0..ACC_DIFFICULTY_ARRAY_LEN]); let accumulated_difficulty = u128::from_be_bytes(acc_diff); - let height_of_longest_chain = metadata - .height_of_longest_chain - .ok_or_else(|| "Height of longest chain is missing".to_string())?; + let height_of_longest_chain = metadata.height_of_longest_chain; + if height_of_longest_chain == 0 { + return Err("Height of longest chain is missing".to_string()); + } + let pruning_horizon = if metadata.pruned_height == 0 { metadata.pruned_height } else { @@ -64,7 +66,7 @@ impl TryFrom for ChainMetadata { pruning_horizon, metadata.pruned_height, accumulated_difficulty, - metadata.timestamp.unwrap_or_default(), + metadata.timestamp, )) } } @@ -73,17 +75,17 @@ impl From for proto::ChainMetadata { fn from(metadata: ChainMetadata) -> Self { let accumulated_difficulty = metadata.accumulated_difficulty().to_be_bytes().to_vec(); Self { - height_of_longest_chain: Some(metadata.height_of_longest_chain()), + height_of_longest_chain: metadata.height_of_longest_chain(), best_block: Some(metadata.best_block().to_vec()), pruned_height: metadata.pruned_height(), accumulated_difficulty, - timestamp: Some(metadata.timestamp()), + timestamp: metadata.timestamp(), } } } impl proto::ChainMetadata { pub fn height_of_longest_chain(&self) -> u64 { - self.height_of_longest_chain.unwrap_or(0) + self.height_of_longest_chain } } diff --git a/base_layer/core/src/base_node/proto/wallet_rpc.proto b/base_layer/core/src/base_node/proto/wallet_rpc.proto index 2578f34b65..b48a24cc02 100644 --- a/base_layer/core/src/base_node/proto/wallet_rpc.proto +++ b/base_layer/core/src/base_node/proto/wallet_rpc.proto @@ -39,7 +39,7 @@ message TxQueryResponse { uint64 confirmations = 3; bool is_synced = 4; uint64 height_of_longest_chain = 5; - google.protobuf.UInt64Value mined_timestamp = 6; + uint64 mined_timestamp = 6; } message TxQueryBatchResponse { @@ -48,7 +48,7 @@ message TxQueryBatchResponse { google.protobuf.BytesValue block_hash = 3; uint64 confirmations = 4; uint64 block_height = 5; - google.protobuf.UInt64Value mined_timestamp = 6; + uint64 mined_timestamp = 6; } message TxQueryBatchResponses { @@ -56,7 +56,7 @@ message TxQueryBatchResponses { bool is_synced = 2; google.protobuf.BytesValue tip_hash = 3; uint64 height_of_longest_chain = 4; - google.protobuf.UInt64Value tip_mined_timestamp = 5; + uint64 tip_mined_timestamp = 5; } message FetchMatchingUtxos { diff --git a/base_layer/core/src/base_node/proto/wallet_rpc.rs b/base_layer/core/src/base_node/proto/wallet_rpc.rs index be9729e401..e96198c019 100644 --- a/base_layer/core/src/base_node/proto/wallet_rpc.rs +++ b/base_layer/core/src/base_node/proto/wallet_rpc.rs @@ -198,6 +198,12 @@ impl TryFrom for TxQueryResponse { }, None => None, }; + + let mined_timestamp = match proto_response.mined_timestamp { + 0 => None, + t => Some(t), + }; + Ok(Self { location: TxLocation::try_from( proto::TxLocation::from_i32(proto_response.location) @@ -207,7 +213,7 @@ impl TryFrom for TxQueryResponse { confirmations: proto_response.confirmations, is_synced: proto_response.is_synced, height_of_longest_chain: proto_response.height_of_longest_chain, - mined_timestamp: proto_response.mined_timestamp, + mined_timestamp, }) } } @@ -220,7 +226,7 @@ impl From for proto::TxQueryResponse { confirmations: response.confirmations, is_synced: response.is_synced, height_of_longest_chain: response.height_of_longest_chain, - mined_timestamp: response.mined_timestamp, + mined_timestamp: response.mined_timestamp.unwrap_or_default(), } } } @@ -236,6 +242,10 @@ impl TryFrom for TxQueryBatchResponse { }, None => None, }; + let mined_timestamp = match proto_response.mined_timestamp { + 0 => None, + t => Some(t), + }; Ok(Self { signature: Signature::try_from( proto_response @@ -249,7 +259,7 @@ impl TryFrom for TxQueryBatchResponse { block_hash: hash, block_height: proto_response.block_height, confirmations: proto_response.confirmations, - mined_timestamp: proto_response.mined_timestamp, + mined_timestamp, }) } } diff --git a/base_layer/core/src/base_node/rpc/service.rs b/base_layer/core/src/base_node/rpc/service.rs index 8624c1da4d..da80e24a19 100644 --- a/base_layer/core/src/base_node/rpc/service.rs +++ b/base_layer/core/src/base_node/rpc/service.rs @@ -129,7 +129,7 @@ impl BaseNodeWalletRpcService { confirmations, is_synced, height_of_longest_chain: chain_metadata.height_of_longest_chain(), - mined_timestamp: Some(header.timestamp.as_u64()), + mined_timestamp: header.timestamp.as_u64(), }; return Ok(response); }, @@ -150,7 +150,7 @@ impl BaseNodeWalletRpcService { confirmations: 0, is_synced, height_of_longest_chain: chain_metadata.height_of_longest_chain(), - mined_timestamp: None, + mined_timestamp: 0, }, TxStorageResponse::ReorgPool | TxStorageResponse::NotStoredOrphan | @@ -165,7 +165,7 @@ impl BaseNodeWalletRpcService { confirmations: 0, is_synced, height_of_longest_chain: chain_metadata.height_of_longest_chain(), - mined_timestamp: None, + mined_timestamp: 0, }, }; Ok(mempool_response) @@ -320,7 +320,7 @@ impl BaseNodeWalletService for BaseNodeWalletRpc is_synced, tip_hash: Some(metadata.best_block().to_vec()), height_of_longest_chain: metadata.height_of_longest_chain(), - tip_mined_timestamp: Some(metadata.timestamp()), + tip_mined_timestamp: metadata.timestamp(), })) } diff --git a/base_layer/wallet/src/transaction_service/protocols/transaction_validation_protocol.rs b/base_layer/wallet/src/transaction_service/protocols/transaction_validation_protocol.rs index 235f778e90..86ff6ee34c 100644 --- a/base_layer/wallet/src/transaction_service/protocols/transaction_validation_protocol.rs +++ b/base_layer/wallet/src/transaction_service/protocols/transaction_validation_protocol.rs @@ -345,15 +345,20 @@ where .tip_hash .ok_or_else(|| TransactionServiceError::ProtobufConversionError("Missing `tip_hash` field".to_string()))? .try_into()?; + + if batch_response.tip_mined_timestamp == 0 { + return Err(TransactionServiceError::ProtobufConversionError( + "Missing `tip_hash` field".to_string(), + )); + } + Ok(( mined, unmined, Some(( batch_response.height_of_longest_chain, tip, - batch_response.tip_mined_timestamp.ok_or_else(|| { - TransactionServiceError::ProtobufConversionError("Missing `tip_hash` field".to_string()) - })?, + batch_response.tip_mined_timestamp, )), )) } diff --git a/base_layer/wallet/tests/support/comms_rpc.rs b/base_layer/wallet/tests/support/comms_rpc.rs index 4a06a1e491..a21647a891 100644 --- a/base_layer/wallet/tests/support/comms_rpc.rs +++ b/base_layer/wallet/tests/support/comms_rpc.rs @@ -144,15 +144,15 @@ impl BaseNodeWalletRpcMockState { tip_hash: Some(vec![]), is_synced: true, height_of_longest_chain: 0, - tip_mined_timestamp: Some(0), + tip_mined_timestamp: 0, })), tip_info_response: Arc::new(Mutex::new(TipInfoResponse { metadata: Some(ChainMetadataProto { - height_of_longest_chain: Some(std::i64::MAX as u64), + height_of_longest_chain: std::i64::MAX as u64, best_block: Some(Vec::new()), accumulated_difficulty: Vec::new(), pruned_height: 0, - timestamp: Some(0), + timestamp: 0, }), is_synced: true, })), @@ -931,11 +931,11 @@ mod test { assert_eq!(calls.len(), 1); let chain_metadata = ChainMetadata { - height_of_longest_chain: Some(444), + height_of_longest_chain: 444, best_block: Some(Vec::new()), accumulated_difficulty: Vec::new(), pruned_height: 0, - timestamp: Some(0), + timestamp: 0, }; service_state.set_tip_info_response(TipInfoResponse { metadata: Some(chain_metadata), diff --git a/base_layer/wallet/tests/transaction_service_tests/service.rs b/base_layer/wallet/tests/transaction_service_tests/service.rs index a057900ced..c8acc57fcb 100644 --- a/base_layer/wallet/tests/transaction_service_tests/service.rs +++ b/base_layer/wallet/tests/transaction_service_tests/service.rs @@ -3780,7 +3780,7 @@ async fn test_coinbase_generation_and_monitoring() { block_hash: None, confirmations: 0, block_height: 0, - mined_timestamp: None, + mined_timestamp: 0, }, TxQueryBatchResponseProto { signature: Some(SignatureProto::from( @@ -3790,7 +3790,7 @@ async fn test_coinbase_generation_and_monitoring() { block_hash: Some(block_headers.get(&1).unwrap().hash().to_vec()), confirmations: 0, block_height: 1, - mined_timestamp: Some(0), + mined_timestamp: 0, }, ]; let batch_query_response = TxQueryBatchResponsesProto { @@ -3798,7 +3798,7 @@ async fn test_coinbase_generation_and_monitoring() { is_synced: true, tip_hash: Some(block_headers.get(&1).unwrap().hash().to_vec()), height_of_longest_chain: 1, - tip_mined_timestamp: Some(0), + tip_mined_timestamp: 0, }; alice_ts_interface @@ -3841,7 +3841,7 @@ async fn test_coinbase_generation_and_monitoring() { block_hash: Some(block_headers.get(&4).unwrap().hash().to_vec()), confirmations: 3, block_height: 4, - mined_timestamp: Some(0), + mined_timestamp: 0, }); let batch_query_response = TxQueryBatchResponsesProto { @@ -3849,7 +3849,7 @@ async fn test_coinbase_generation_and_monitoring() { is_synced: true, tip_hash: Some(block_headers.get(&4).unwrap().hash().to_vec()), height_of_longest_chain: 4, - tip_mined_timestamp: Some(0), + tip_mined_timestamp: 0, }; alice_ts_interface .base_node_rpc_mock_state @@ -3924,7 +3924,7 @@ async fn test_coinbase_abandoned() { block_hash: None, confirmations: 0, block_height: 0, - mined_timestamp: None, + mined_timestamp: 0, }]; let batch_query_response = TxQueryBatchResponsesProto { @@ -3932,7 +3932,7 @@ async fn test_coinbase_abandoned() { is_synced: true, tip_hash: Some([5u8; 32].to_vec()), height_of_longest_chain: block_height_a + TransactionServiceConfig::default().num_confirmations_required + 1, - tip_mined_timestamp: Some(0), + tip_mined_timestamp: 0, }; alice_ts_interface @@ -4049,7 +4049,7 @@ async fn test_coinbase_abandoned() { block_hash: None, confirmations: 0, block_height: 0, - mined_timestamp: None, + mined_timestamp: 0, }, TxQueryBatchResponseProto { signature: Some(SignatureProto::from(tx2.first_kernel_excess_sig().unwrap().clone())), @@ -4057,7 +4057,7 @@ async fn test_coinbase_abandoned() { block_hash: Some([11u8; 32].to_vec()), confirmations: 2, block_height: block_height_b, - mined_timestamp: Some(0), + mined_timestamp: 0, }, ]; @@ -4066,7 +4066,7 @@ async fn test_coinbase_abandoned() { is_synced: true, tip_hash: Some([13u8; 32].to_vec()), height_of_longest_chain: block_height_b + 2, - tip_mined_timestamp: Some(0), + tip_mined_timestamp: 0, }; alice_ts_interface @@ -4135,7 +4135,7 @@ async fn test_coinbase_abandoned() { block_hash: None, confirmations: 0, block_height: 0, - mined_timestamp: None, + mined_timestamp: 0, }, TxQueryBatchResponseProto { signature: Some(SignatureProto::from(tx2.first_kernel_excess_sig().unwrap().clone())), @@ -4143,7 +4143,7 @@ async fn test_coinbase_abandoned() { block_hash: None, confirmations: 0, block_height: 0, - mined_timestamp: None, + mined_timestamp: 0, }, ]; @@ -4152,7 +4152,7 @@ async fn test_coinbase_abandoned() { is_synced: true, tip_hash: Some([12u8; 32].to_vec()), height_of_longest_chain: block_height_b + TransactionServiceConfig::default().num_confirmations_required + 1, - tip_mined_timestamp: Some(0), + tip_mined_timestamp: 0, }; alice_ts_interface @@ -4252,7 +4252,7 @@ async fn test_coinbase_abandoned() { block_hash: None, confirmations: 0, block_height: 0, - mined_timestamp: None, + mined_timestamp: 0, }, TxQueryBatchResponseProto { signature: Some(SignatureProto::from(tx2.first_kernel_excess_sig().unwrap().clone())), @@ -4260,7 +4260,7 @@ async fn test_coinbase_abandoned() { block_hash: Some(block_headers.get(&10).unwrap().hash().to_vec()), confirmations: 5, block_height: 10, - mined_timestamp: Some(0), + mined_timestamp: 0, }, ]; @@ -4269,7 +4269,7 @@ async fn test_coinbase_abandoned() { is_synced: true, tip_hash: Some([20u8; 32].to_vec()), height_of_longest_chain: 20, - tip_mined_timestamp: Some(0), + tip_mined_timestamp: 0, }; alice_ts_interface diff --git a/base_layer/wallet/tests/transaction_service_tests/transaction_protocols.rs b/base_layer/wallet/tests/transaction_service_tests/transaction_protocols.rs index dbd0bb3d8d..0afc2cf3db 100644 --- a/base_layer/wallet/tests/transaction_service_tests/transaction_protocols.rs +++ b/base_layer/wallet/tests/transaction_service_tests/transaction_protocols.rs @@ -788,7 +788,7 @@ async fn tx_validation_protocol_tx_becomes_mined_unconfirmed_then_confirmed() { block_hash: Some([1u8; 32].to_vec()), confirmations: 0, block_height: 1, - mined_timestamp: Some(0), + mined_timestamp: 0, }]; let mut batch_query_response = TxQueryBatchResponsesProto { @@ -796,7 +796,7 @@ async fn tx_validation_protocol_tx_becomes_mined_unconfirmed_then_confirmed() { is_synced: true, tip_hash: Some([1u8; 32].to_vec()), height_of_longest_chain: 1, - tip_mined_timestamp: Some(0), + tip_mined_timestamp: 0, }; rpc_service_state.set_transaction_query_batch_responses(batch_query_response.clone()); @@ -862,7 +862,7 @@ async fn tx_validation_protocol_tx_becomes_mined_unconfirmed_then_confirmed() { block_hash: Some([5u8; 32].to_vec()), confirmations: 4, block_height: 5, - mined_timestamp: Some(0), + mined_timestamp: 0, }]; let batch_query_response = TxQueryBatchResponsesProto { @@ -870,7 +870,7 @@ async fn tx_validation_protocol_tx_becomes_mined_unconfirmed_then_confirmed() { is_synced: true, tip_hash: Some([5u8; 32].to_vec()), height_of_longest_chain: 5, - tip_mined_timestamp: Some(0), + tip_mined_timestamp: 0, }; rpc_service_state.set_transaction_query_batch_responses(batch_query_response.clone()); @@ -945,7 +945,7 @@ async fn tx_revalidation() { block_hash: Some([5u8; 32].to_vec()), confirmations: 4, block_height: 5, - mined_timestamp: Some(0), + mined_timestamp: 0, }]; let batch_query_response = TxQueryBatchResponsesProto { @@ -953,7 +953,7 @@ async fn tx_revalidation() { is_synced: true, tip_hash: Some([5u8; 32].to_vec()), height_of_longest_chain: 5, - tip_mined_timestamp: Some(0), + tip_mined_timestamp: 0, }; rpc_service_state.set_transaction_query_batch_responses(batch_query_response.clone()); @@ -987,7 +987,7 @@ async fn tx_revalidation() { block_hash: Some([5u8; 32].to_vec()), confirmations: 8, block_height: 10, - mined_timestamp: Some(0), + mined_timestamp: 0, }]; let batch_query_response = TxQueryBatchResponsesProto { @@ -995,7 +995,7 @@ async fn tx_revalidation() { is_synced: true, tip_hash: Some([5u8; 32].to_vec()), height_of_longest_chain: 10, - tip_mined_timestamp: Some(0), + tip_mined_timestamp: 0, }; rpc_service_state.set_transaction_query_batch_responses(batch_query_response.clone()); @@ -1107,7 +1107,7 @@ async fn tx_validation_protocol_reorg() { block_hash: Some(block_headers.get(&5).unwrap().hash().to_vec()), confirmations: 5, block_height: 5, - mined_timestamp: Some(0), + mined_timestamp: 0, }, TxQueryBatchResponseProto { signature: Some(SignatureProto::from( @@ -1117,7 +1117,7 @@ async fn tx_validation_protocol_reorg() { block_hash: Some(block_headers.get(&6).unwrap().hash().to_vec()), confirmations: 4, block_height: 6, - mined_timestamp: Some(0), + mined_timestamp: 0, }, TxQueryBatchResponseProto { signature: Some(SignatureProto::from( @@ -1127,7 +1127,7 @@ async fn tx_validation_protocol_reorg() { block_hash: Some(block_headers.get(&7).unwrap().hash().to_vec()), confirmations: 3, block_height: 7, - mined_timestamp: Some(0), + mined_timestamp: 0, }, TxQueryBatchResponseProto { signature: Some(SignatureProto::from( @@ -1137,7 +1137,7 @@ async fn tx_validation_protocol_reorg() { block_hash: Some(block_headers.get(&8).unwrap().hash().to_vec()), confirmations: 2, block_height: 8, - mined_timestamp: Some(0), + mined_timestamp: 0, }, TxQueryBatchResponseProto { signature: Some(SignatureProto::from( @@ -1147,7 +1147,7 @@ async fn tx_validation_protocol_reorg() { block_hash: Some(block_headers.get(&8).unwrap().hash().to_vec()), confirmations: 2, block_height: 8, - mined_timestamp: Some(0), + mined_timestamp: 0, }, TxQueryBatchResponseProto { signature: Some(SignatureProto::from( @@ -1157,7 +1157,7 @@ async fn tx_validation_protocol_reorg() { block_hash: Some(block_headers.get(&9).unwrap().hash().to_vec()), confirmations: 1, block_height: 9, - mined_timestamp: Some(0), + mined_timestamp: 0, }, TxQueryBatchResponseProto { signature: Some(SignatureProto::from( @@ -1167,7 +1167,7 @@ async fn tx_validation_protocol_reorg() { block_hash: Some(block_headers.get(&9).unwrap().hash().to_vec()), confirmations: 1, block_height: 9, - mined_timestamp: Some(0), + mined_timestamp: 0, }, ]; @@ -1176,7 +1176,7 @@ async fn tx_validation_protocol_reorg() { is_synced: true, tip_hash: Some(block_headers.get(&10).unwrap().hash().to_vec()), height_of_longest_chain: 10, - tip_mined_timestamp: Some(0), + tip_mined_timestamp: 0, }; rpc_service_state.set_transaction_query_batch_responses(batch_query_response.clone()); @@ -1228,7 +1228,7 @@ async fn tx_validation_protocol_reorg() { block_hash: Some(block_headers.get(&5).unwrap().hash().to_vec()), confirmations: 4, block_height: 5, - mined_timestamp: Some(0), + mined_timestamp: 0, }, TxQueryBatchResponseProto { signature: Some(SignatureProto::from( @@ -1238,7 +1238,7 @@ async fn tx_validation_protocol_reorg() { block_hash: Some(block_headers.get(&6).unwrap().hash().to_vec()), confirmations: 3, block_height: 6, - mined_timestamp: Some(0), + mined_timestamp: 0, }, TxQueryBatchResponseProto { signature: Some(SignatureProto::from( @@ -1248,7 +1248,7 @@ async fn tx_validation_protocol_reorg() { block_hash: Some(block_headers.get(&7).unwrap().hash().to_vec()), confirmations: 2, block_height: 7, - mined_timestamp: Some(0), + mined_timestamp: 0, }, TxQueryBatchResponseProto { signature: Some(SignatureProto::from( @@ -1258,7 +1258,7 @@ async fn tx_validation_protocol_reorg() { block_hash: None, confirmations: 0, block_height: 0, - mined_timestamp: None, + mined_timestamp: 0, }, TxQueryBatchResponseProto { signature: Some(SignatureProto::from( @@ -1268,7 +1268,7 @@ async fn tx_validation_protocol_reorg() { block_hash: Some(block_headers.get(&8).unwrap().hash().to_vec()), confirmations: 1, block_height: 8, - mined_timestamp: Some(0), + mined_timestamp: 0, }, TxQueryBatchResponseProto { signature: Some(SignatureProto::from( @@ -1278,7 +1278,7 @@ async fn tx_validation_protocol_reorg() { block_hash: None, confirmations: 0, block_height: 0, - mined_timestamp: None, + mined_timestamp: 0, }, ]; @@ -1287,7 +1287,7 @@ async fn tx_validation_protocol_reorg() { is_synced: true, tip_hash: Some(block_headers.get(&8).unwrap().hash().to_vec()), height_of_longest_chain: 8, - tip_mined_timestamp: Some(0), + tip_mined_timestamp: 0, }; rpc_service_state.set_transaction_query_batch_responses(batch_query_response.clone()); diff --git a/base_layer/wallet/tests/utxo_scanner/mod.rs b/base_layer/wallet/tests/utxo_scanner/mod.rs index e4b3f289a2..64df5910a0 100644 --- a/base_layer/wallet/tests/utxo_scanner/mod.rs +++ b/base_layer/wallet/tests/utxo_scanner/mod.rs @@ -313,11 +313,11 @@ async fn test_utxo_scanner_recovery() { test_interface.rpc_service_state.set_blocks(block_headers.clone()); let chain_metadata = ChainMetadata { - height_of_longest_chain: Some(NUM_BLOCKS - 1), + height_of_longest_chain: NUM_BLOCKS - 1, best_block: Some(block_headers.get(&(NUM_BLOCKS - 1)).unwrap().clone().hash().to_vec()), accumulated_difficulty: Vec::new(), pruned_height: 0, - timestamp: Some(0), + timestamp: 0, }; test_interface.rpc_service_state.set_tip_info_response(TipInfoResponse { metadata: Some(chain_metadata), @@ -412,11 +412,11 @@ async fn test_utxo_scanner_recovery_with_restart() { test_interface.rpc_service_state.set_blocks(block_headers.clone()); let chain_metadata = ChainMetadata { - height_of_longest_chain: Some(NUM_BLOCKS - 1), + height_of_longest_chain: NUM_BLOCKS - 1, best_block: Some(block_headers.get(&(NUM_BLOCKS - 1)).unwrap().clone().hash().to_vec()), accumulated_difficulty: Vec::new(), pruned_height: 0, - timestamp: Some(0), + timestamp: 0, }; test_interface.rpc_service_state.set_tip_info_response(TipInfoResponse { metadata: Some(chain_metadata.clone()), @@ -578,11 +578,11 @@ async fn test_utxo_scanner_recovery_with_restart_and_reorg() { test_interface.rpc_service_state.set_blocks(block_headers.clone()); let chain_metadata = ChainMetadata { - height_of_longest_chain: Some(NUM_BLOCKS - 1), + height_of_longest_chain: NUM_BLOCKS - 1, best_block: Some(block_headers.get(&(NUM_BLOCKS - 1)).unwrap().clone().hash().to_vec()), accumulated_difficulty: Vec::new(), pruned_height: 0, - timestamp: Some(0), + timestamp: 0, }; test_interface.rpc_service_state.set_tip_info_response(TipInfoResponse { metadata: Some(chain_metadata.clone()), @@ -651,11 +651,11 @@ async fn test_utxo_scanner_recovery_with_restart_and_reorg() { .set_utxos_by_block(utxos_by_block.clone()); test_interface2.rpc_service_state.set_blocks(block_headers.clone()); let chain_metadata = ChainMetadata { - height_of_longest_chain: Some(9), + height_of_longest_chain: 9, best_block: Some(block_headers.get(&9).unwrap().clone().hash().to_vec()), accumulated_difficulty: Vec::new(), pruned_height: 0, - timestamp: Some(0), + timestamp: 0, }; test_interface2 .rpc_service_state @@ -776,7 +776,7 @@ async fn test_utxo_scanner_scanned_block_cache_clearing() { test_interface.rpc_service_state.set_blocks(block_headers.clone()); let chain_metadata = ChainMetadata { - height_of_longest_chain: Some(800 + NUM_BLOCKS - 1), + height_of_longest_chain: 800 + NUM_BLOCKS - 1, best_block: Some( block_headers .get(&(800 + NUM_BLOCKS - 1)) @@ -787,7 +787,7 @@ async fn test_utxo_scanner_scanned_block_cache_clearing() { ), accumulated_difficulty: Vec::new(), pruned_height: 0, - timestamp: Some(0), + timestamp: 0, }; test_interface.rpc_service_state.set_tip_info_response(TipInfoResponse { metadata: Some(chain_metadata), @@ -880,11 +880,11 @@ async fn test_utxo_scanner_one_sided_payments() { test_interface.rpc_service_state.set_blocks(block_headers.clone()); let chain_metadata = ChainMetadata { - height_of_longest_chain: Some(NUM_BLOCKS - 1), + height_of_longest_chain: NUM_BLOCKS - 1, best_block: Some(block_headers.get(&(NUM_BLOCKS - 1)).unwrap().clone().hash().to_vec()), accumulated_difficulty: Vec::new(), pruned_height: 0, - timestamp: Some(0), + timestamp: 0, }; test_interface.rpc_service_state.set_tip_info_response(TipInfoResponse { metadata: Some(chain_metadata), @@ -1000,11 +1000,11 @@ async fn test_utxo_scanner_one_sided_payments() { .set_one_sided_payment_message("new one-sided message".to_string()); let chain_metadata = ChainMetadata { - height_of_longest_chain: Some(NUM_BLOCKS), + height_of_longest_chain: NUM_BLOCKS, best_block: Some(block_headers.get(&(NUM_BLOCKS)).unwrap().clone().hash().to_vec()), accumulated_difficulty: Vec::new(), pruned_height: 0, - timestamp: Some(0), + timestamp: 0, }; test_interface.rpc_service_state.set_tip_info_response(TipInfoResponse { @@ -1087,11 +1087,11 @@ async fn test_birthday_timestamp_over_chain() { test_interface.rpc_service_state.set_blocks(block_headers.clone()); let chain_metadata = ChainMetadata { - height_of_longest_chain: Some(NUM_BLOCKS - 1), + height_of_longest_chain: NUM_BLOCKS - 1, best_block: Some(block_headers.get(&(NUM_BLOCKS - 1)).unwrap().clone().hash().to_vec()), accumulated_difficulty: Vec::new(), pruned_height: 0, - timestamp: Some(0), + timestamp: 0, }; test_interface.rpc_service_state.set_tip_info_response(TipInfoResponse { metadata: Some(chain_metadata),