From 1b232e4de230dc4922937fea2b489c7409ca2408 Mon Sep 17 00:00:00 2001 From: Gustavo Inacio Date: Mon, 26 Feb 2024 20:29:09 +0000 Subject: [PATCH] fix!: update rav attributes to camel case Signed-off-by: Gustavo Inacio --- tap_aggregator/src/aggregator.rs | 24 +++++++++---------- tap_aggregator/src/server.rs | 6 ++--- tap_core/src/receipt_aggregate_voucher.rs | 16 ++++++------- tap_core/src/tap_manager/manager.rs | 6 ++--- tap_core/src/tap_manager/test/manager_test.rs | 8 +++---- tap_integration_tests/tests/showcase.rs | 2 +- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/tap_aggregator/src/aggregator.rs b/tap_aggregator/src/aggregator.rs index 7d83e95b..22afa6e2 100644 --- a/tap_aggregator/src/aggregator.rs +++ b/tap_aggregator/src/aggregator.rs @@ -55,7 +55,7 @@ pub async fn check_and_aggregate_receipts( // Check that the rav has the correct allocation id if let Some(previous_rav) = &previous_rav { - let prev_id = previous_rav.message.allocation_id; + let prev_id = previous_rav.message.allocationId; if prev_id != allocation_id { return Err(tap_core::Error::RavAllocationIdMismatch { prev_id: format!("{prev_id:#X}"), @@ -117,9 +117,9 @@ fn check_receipt_timestamps( if let Some(previous_rav) = &previous_rav { for receipt in receipts.iter() { let receipt = &receipt.message; - if previous_rav.message.timestamp_ns >= receipt.timestamp_ns { + if previous_rav.message.timestampNs >= receipt.timestamp_ns { return Err(tap_core::Error::ReceiptTimestampLowerThanRav { - rav_ts: previous_rav.message.timestamp_ns, + rav_ts: previous_rav.message.timestampNs, receipt_ts: receipt.timestamp_ns, } .into()); @@ -256,9 +256,9 @@ mod tests { let rav = EIP712SignedMessage::new( &domain_separator, tap_core::receipt_aggregate_voucher::ReceiptAggregateVoucher { - allocation_id: allocation_ids[0], - timestamp_ns: receipt_timestamp_range.clone().min().unwrap() - 1, - value_aggregate: 42, + allocationId: allocation_ids[0], + timestampNs: receipt_timestamp_range.clone().min().unwrap() - 1, + valueAggregate: 42, }, &keys.0, ) @@ -271,9 +271,9 @@ mod tests { let rav = EIP712SignedMessage::new( &domain_separator, tap_core::receipt_aggregate_voucher::ReceiptAggregateVoucher { - allocation_id: allocation_ids[0], - timestamp_ns: receipt_timestamp_range.clone().min().unwrap(), - value_aggregate: 42, + allocationId: allocation_ids[0], + timestampNs: receipt_timestamp_range.clone().min().unwrap(), + valueAggregate: 42, }, &keys.0, ) @@ -286,9 +286,9 @@ mod tests { let rav = EIP712SignedMessage::new( &domain_separator, tap_core::receipt_aggregate_voucher::ReceiptAggregateVoucher { - allocation_id: allocation_ids[0], - timestamp_ns: receipt_timestamp_range.clone().max().unwrap() + 1, - value_aggregate: 42, + allocationId: allocation_ids[0], + timestampNs: receipt_timestamp_range.clone().max().unwrap() + 1, + valueAggregate: 42, }, &keys.0, ) diff --git a/tap_aggregator/src/server.rs b/tap_aggregator/src/server.rs index d4b89047..aea28468 100644 --- a/tap_aggregator/src/server.rs +++ b/tap_aggregator/src/server.rs @@ -431,9 +431,9 @@ mod tests { ReceiptAggregateVoucher::aggregate_receipts(allocation_ids[0], &receipts, None) .unwrap(); - assert!(remote_rav.message.allocation_id == local_rav.allocation_id); - assert!(remote_rav.message.timestamp_ns == local_rav.timestamp_ns); - assert!(remote_rav.message.value_aggregate == local_rav.value_aggregate); + assert!(remote_rav.message.allocationId == local_rav.allocationId); + assert!(remote_rav.message.timestampNs == local_rav.timestampNs); + assert!(remote_rav.message.valueAggregate == local_rav.valueAggregate); assert!(remote_rav.recover_signer(&domain_separator).unwrap() == keys_main.address); diff --git a/tap_core/src/receipt_aggregate_voucher.rs b/tap_core/src/receipt_aggregate_voucher.rs index 4b7f21c2..14304d54 100644 --- a/tap_core/src/receipt_aggregate_voucher.rs +++ b/tap_core/src/receipt_aggregate_voucher.rs @@ -22,12 +22,12 @@ sol! { #[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] struct ReceiptAggregateVoucher { /// Unique allocation id this RAV belongs to - address allocation_id; + address allocationId; /// Unix Epoch timestamp in nanoseconds (Truncated to 64-bits) /// corresponding to max timestamp from receipt batch aggregated - uint64 timestamp_ns; + uint64 timestampNs; /// Aggregated GRT value from receipt batch and any previous RAV provided (truncate to lower bits) - uint128 value_aggregate; + uint128 valueAggregate; } } @@ -49,8 +49,8 @@ impl ReceiptAggregateVoucher { let mut value_aggregate = 0u128; if let Some(prev_rav) = previous_rav { - timestamp_max = prev_rav.message.timestamp_ns; - value_aggregate = prev_rav.message.value_aggregate; + timestamp_max = prev_rav.message.timestampNs; + value_aggregate = prev_rav.message.valueAggregate; } for receipt in receipts { @@ -62,9 +62,9 @@ impl ReceiptAggregateVoucher { } Ok(Self { - allocation_id, - timestamp_ns: timestamp_max, - value_aggregate, + allocationId: allocation_id, + timestampNs: timestamp_max, + valueAggregate: value_aggregate, }) } } diff --git a/tap_core/src/tap_manager/manager.rs b/tap_core/src/tap_manager/manager.rs index c0f6a345..78ac2412 100644 --- a/tap_core/src/tap_manager/manager.rs +++ b/tap_core/src/tap_manager/manager.rs @@ -198,7 +198,7 @@ where let previous_rav = self.get_previous_rav().await?; let min_timestamp_ns = previous_rav .as_ref() - .map(|rav| rav.message.timestamp_ns + 1) + .map(|rav| rav.message.timestampNs + 1) .unwrap_or(0); let (valid_receipts, invalid_receipts) = self @@ -208,7 +208,7 @@ where let expected_rav = Self::generate_expected_rav(&valid_receipts, previous_rav.clone())?; self.receipt_auditor - .update_min_timestamp_ns(expected_rav.timestamp_ns) + .update_min_timestamp_ns(expected_rav.timestampNs) .await; let valid_receipts = valid_receipts .into_iter() @@ -260,7 +260,7 @@ where match self.get_previous_rav().await? { Some(last_rav) => { self.executor - .remove_receipts_in_timestamp_range(..=last_rav.message.timestamp_ns) + .remove_receipts_in_timestamp_range(..=last_rav.message.timestampNs) .await .map_err(|err| Error::AdapterError { source_error: anyhow::Error::new(err), diff --git a/tap_core/src/tap_manager/test/manager_test.rs b/tap_core/src/tap_manager/test/manager_test.rs index 09d04d99..dc04882c 100644 --- a/tap_core/src/tap_manager/test/manager_test.rs +++ b/tap_core/src/tap_manager/test/manager_test.rs @@ -286,7 +286,7 @@ mod manager_unit_test { assert_eq!(rav_request.invalid_receipts.len(), 0); // accumulated value is correct assert_eq!( - rav_request.expected_rav.value_aggregate, + rav_request.expected_rav.valueAggregate, expected_accumulated_value ); // no previous rav @@ -335,7 +335,7 @@ mod manager_unit_test { assert_eq!(rav_request.invalid_receipts.len(), 0); // accumulated value is correct assert_eq!( - rav_request.expected_rav.value_aggregate, + rav_request.expected_rav.valueAggregate, expected_accumulated_value ); // Verify there is a previous rav @@ -415,7 +415,7 @@ mod manager_unit_test { assert_eq!(rav_request_1.invalid_receipts.len(), 0); // accumulated value is correct assert_eq!( - rav_request_1.expected_rav.value_aggregate, + rav_request_1.expected_rav.valueAggregate, expected_accumulated_value ); // no previous rav @@ -481,7 +481,7 @@ mod manager_unit_test { assert_eq!(rav_request_2.invalid_receipts.len(), 0); // accumulated value is correct assert_eq!( - rav_request_2.expected_rav.value_aggregate, + rav_request_2.expected_rav.valueAggregate, expected_accumulated_value ); // Verify there is a previous rav diff --git a/tap_integration_tests/tests/showcase.rs b/tap_integration_tests/tests/showcase.rs index 66a5342a..9121270a 100644 --- a/tap_integration_tests/tests/showcase.rs +++ b/tap_integration_tests/tests/showcase.rs @@ -876,7 +876,7 @@ async fn test_tap_aggregator_rav_timestamp_cuttoff( for (receipt, _) in first_batch.iter().chain(second_batch.iter()) { expected_value += receipt.message.value; } - assert!(expected_value == second_rav_response.data.message.value_aggregate); + assert!(expected_value == second_rav_response.data.message.valueAggregate); sender_handle.stop()?; Ok(())