Skip to content

Commit 49bfe80

Browse files
committed
Precise value comparison on last_tx_timestamp tests
1 parent ce2872a commit 49bfe80

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

sui/packages/ntt/tests/ntt_tests.move

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,12 +1529,21 @@ module ntt::ntt_tests {
15291529

15301530
let inbound_last_tx_after = inbound.last_tx_timestamp();
15311531

1532-
// Outbound and inbound rate limit comparisons
1533-
assert!(inbound_last_tx_after != inbound_last_tx_before);
1534-
assert!(inbound_last_tx_after > inbound_last_tx_before);
1535-
assert!(outbound_last_tx_after != outbound_last_tx_before);
1536-
assert!(outbound_last_tx_after > outbound_last_tx_before);
1537-
assert!(outbound_last_tx_after == inbound_last_tx_after);
1532+
// The transfer records the current clock time as last_tx_timestamp for
1533+
// both the inbound and outbound rate limiters. The clock is not advanced
1534+
// between the snapshots, so `before + time == after` holds exactly.
1535+
let time = clock.timestamp_ms();
1536+
1537+
// Both limiters started at 0 (set during setup at clock time 0).
1538+
assert!(inbound_last_tx_before == 0);
1539+
assert!(outbound_last_tx_before == 0);
1540+
1541+
// Inbound and outbound timestamps advance to exactly the transfer time.
1542+
assert!(inbound_last_tx_after == inbound_last_tx_before + time);
1543+
assert!(outbound_last_tx_after == outbound_last_tx_before + time);
1544+
1545+
// Both limiters are updated to the same timestamp.
1546+
assert!(outbound_last_tx_after == inbound_last_tx_after);
15381547

15391548
let message = *state.borrow_outbox().borrow(outbox_key).borrow_data();
15401549

0 commit comments

Comments
 (0)