Skip to content
Commit 160b4d38 authored by Kangping Dong's avatar Kangping Dong
Browse files

[Thread] fix OperationalDatasetTimestamp#toTlvValue is not loss-less

OperationalDatasetTimestamp is saving the timestamp as an Instant
object, and this has the problem that when the dataset timestamp is
written to a TLV, it's going to loss precision as the nanoseconds
of the Instant is converted to "Ticks". This results in bug that
the dataset timestamp doesn't equal to the same value when it's
converted back from a TLV:

```
var timestamp1 = OperationalDatasetTimestamp.fromInstant(Instant.ofEpochSecond(100, 999938900));
byte[] tlv = timestamp1.toTlvValue();
timestamp2 = OperationalDatasetTimestamp.fromTlvValue(tlv);

assertThat(timestamp2).isEqualTo(timestamp1); // This fails!!!
```

Bug: 308408536
Test: atest ThreadNetworkUnitTests CtsThreadNetworkTestCases
Change-Id: I81b482a05337b6d1150edaa28b860034592a4347
parent 9f76411b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment