Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/aleph-types/src/message/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ mod tests {
&address!("0xa1B3bb7d2332383D96b7796B908fB7f7F3c2Be10")
);
assert_eq!(&message.content.time, &Timestamp::from(1762518461.4893668));
assert_eq!(message.sent_at(), &message.content.time);

// Check aggregate content fields
let aggregate_content = match message.content() {
Expand Down
13 changes: 13 additions & 0 deletions crates/aleph-types/src/message/base_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@ impl Message {
pub fn owner(&self) -> &Address {
&self.content.address
}

/// Returns the time at which the message was sent.
/// Notes:
/// * This value is signed by the sender and should not be trusted accordingly.
/// * We prefer `content.time` over `time` as `time` is not part of the signed payload.
pub fn sent_at(&self) -> &Timestamp {
&self.content.time
}

/// Returns the earliest confirmation time of the message.
pub fn confirmed_at(&self) -> Option<&Timestamp> {
self.confirmations.first().and_then(|c| c.time.as_ref())
}
}

// Custom deserializer that uses message_type to efficiently deserialize content
Expand Down
1 change: 1 addition & 0 deletions crates/aleph-types/src/message/forget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ mod tests {
&address!("0xB68B9D4f3771c246233823ed1D3Add451055F9Ef")
);
assert_eq!(&message.content.time, &Timestamp::from(1762515432.413));
assert_eq!(message.sent_at(), &message.content.time);

// Check aggregate content fields
let forget_content = match message.content() {
Expand Down
9 changes: 7 additions & 2 deletions crates/aleph-types/src/message/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ mod test {
&address!("0x238224C744F4b90b4494516e074D2676ECfC6803")
);
assert_eq!(&message.content.time, &Timestamp::from(1762349117.833176));
assert_eq!(message.sent_at(), &message.content.time);

// Check instance content fields
let instance_content = match message.content() {
Expand Down Expand Up @@ -162,15 +163,19 @@ mod test {
);

assert!(message.confirmed());
assert_eq!(
message.confirmed_at(),
message.confirmations[0].time.as_ref()
);
assert_eq!(
message.confirmations,
vec![MessageConfirmation {
chain: Chain::Ethereum,
height: 23733404,
hash: "0xda1dd1676b5f08cef019172a7b31de303c86aafe8cb209916cf5ffa2bc5871dc"
.to_string(),
time: None,
publisher: None,
time: Some(Timestamp::from(1762349117.833245)),
publisher: Some(address!("0x23eC28598DCeB2f7082Cc3a9D670592DfEd6e0dC")),
}]
);
}
Expand Down
2 changes: 2 additions & 0 deletions crates/aleph-types/src/message/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ mod tests {
&address!("0xB68B9D4f3771c246233823ed1D3Add451055F9Ef")
);
assert_eq!(&message.content.time, &Timestamp::from(1762515431.653));
assert_eq!(message.sent_at(), &message.content.time);

// Check aggregate content fields
let post_content = match message.content() {
Expand Down Expand Up @@ -147,6 +148,7 @@ mod tests {
&address!("0xB68B9D4f3771c246233823ed1D3Add451055F9Ef")
);
assert_eq!(&message.content.time, &Timestamp::from(1762515432.375));
assert_eq!(message.sent_at(), &message.content.time);

// Check aggregate content fields
let post_content = match message.content() {
Expand Down
2 changes: 2 additions & 0 deletions crates/aleph-types/src/message/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ mod tests {
&Address::from("0x9C2FD74F9CA2B7C4941690316B0Ebc35ce55c885".to_string())
);
assert_eq!(&message.content.time, &Timestamp::from(1757026128.773));
assert_eq!(message.sent_at(), &message.content.time);

// Check program content fields
let program_content = match message.content() {
Expand Down Expand Up @@ -214,6 +215,7 @@ mod tests {

// No confirmation on this fixture
assert!(!message.confirmed());
assert!(message.confirmed_at().is_none());
assert!(message.confirmations.is_empty());
}

Expand Down
1 change: 1 addition & 0 deletions crates/aleph-types/src/message/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ mod tests {
&Address::from("0x238224C744F4b90b4494516e074D2676ECfC6803".to_string())
);
assert_eq!(&message.content.time, &Timestamp::from(1761047957.7483068));
assert_eq!(message.sent_at(), &message.content.time);

// Check STORE-specific fields
match message.content() {
Expand Down
4 changes: 3 additions & 1 deletion fixtures/messages/instance/instance-gpu-payg.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
{
"chain": "ETH",
"height": 23733404,
"hash": "0xda1dd1676b5f08cef019172a7b31de303c86aafe8cb209916cf5ffa2bc5871dc"
"hash": "0xda1dd1676b5f08cef019172a7b31de303c86aafe8cb209916cf5ffa2bc5871dc",
"time": 1762349117.833245,
"publisher": "0x23eC28598DCeB2f7082Cc3a9D670592DfEd6e0dC"
}
]
}