From a570b6eff4fadebcaff6040d97048d0da6e5f5c9 Mon Sep 17 00:00:00 2001 From: Gustavo Inacio Date: Mon, 26 Feb 2024 18:13:10 +0000 Subject: [PATCH] fix!: use rav struct camel case solidity needs compatibility and the contracts use camelCase --- 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 5348415c..4be5716f 100644 --- a/tap_aggregator/src/aggregator.rs +++ b/tap_aggregator/src/aggregator.rs @@ -51,7 +51,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}"), @@ -99,9 +99,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()); @@ -241,9 +241,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, ) @@ -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(), - value_aggregate: 42, + allocationId: allocation_ids[0], + timestampNs: receipt_timestamp_range.clone().min().unwrap(), + 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().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 f8f769d8..14efbd09 100644 --- a/tap_aggregator/src/server.rs +++ b/tap_aggregator/src/server.rs @@ -395,9 +395,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.1); 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 3cb89d15..ef86bf06 100644 --- a/tap_core/src/tap_manager/manager.rs +++ b/tap_core/src/tap_manager/manager.rs @@ -155,7 +155,7 @@ impl< match self.get_previous_rav().await? { Some(last_rav) => { self.receipt_storage_adapter - .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), @@ -184,7 +184,7 @@ impl< 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 @@ -194,7 +194,7 @@ impl< 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; Ok(RAVRequest { diff --git a/tap_core/src/tap_manager/test/manager_test.rs b/tap_core/src/tap_manager/test/manager_test.rs index da0043bd..832d1f3c 100644 --- a/tap_core/src/tap_manager/test/manager_test.rs +++ b/tap_core/src/tap_manager/test/manager_test.rs @@ -316,7 +316,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 @@ -365,7 +365,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 @@ -456,7 +456,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 @@ -522,7 +522,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 6a08d279..b888550f 100644 --- a/tap_integration_tests/tests/showcase.rs +++ b/tap_integration_tests/tests/showcase.rs @@ -927,7 +927,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(())