[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
Loading
Please register or sign in to comment