mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-23 22:46:56 +01:00
Replace use of Utils.currentTimeMillis() with Utils.currentTimeSeconds() where appropriate.
This commit is contained in:
parent
66289d6f39
commit
a00f751a56
3 changed files with 10 additions and 6 deletions
|
@ -427,12 +427,16 @@ public class Utils {
|
|||
return mockTime != null ? mockTime : new Date();
|
||||
}
|
||||
|
||||
// TODO: Replace usages of this where the result is / 1000 with currentTimeSeconds.
|
||||
/** Returns the current time in milliseconds since the epoch, or a mocked out equivalent. */
|
||||
/**
|
||||
* Returns the current time in milliseconds since the epoch, or a mocked out equivalent.
|
||||
*/
|
||||
public static long currentTimeMillis() {
|
||||
return mockTime != null ? mockTime.getTime() : System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current time in seconds since the epoch, or a mocked out equivalent.
|
||||
*/
|
||||
public static long currentTimeSeconds() {
|
||||
return currentTimeMillis() / 1000;
|
||||
}
|
||||
|
|
|
@ -990,7 +990,7 @@ public class Wallet extends BaseTaggableObject
|
|||
* Same as {@link #addWatchedAddress(Address, long)} with the current time as the creation time.
|
||||
*/
|
||||
public boolean addWatchedAddress(final Address address) {
|
||||
long now = Utils.currentTimeMillis() / 1000;
|
||||
long now = Utils.currentTimeSeconds();
|
||||
return addWatchedAddresses(Lists.newArrayList(address), now) == 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -351,7 +351,7 @@ public class PaymentChannelStateTest extends TestWithWallet {
|
|||
wallet.addOrUpdateExtension(stateStorage);
|
||||
|
||||
Utils.setMockClock(); // Use mock clock
|
||||
final long EXPIRE_TIME = Utils.currentTimeMillis()/1000 + 60*60*24;
|
||||
final long EXPIRE_TIME = Utils.currentTimeSeconds() + 60*60*24;
|
||||
|
||||
serverState = makeServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME);
|
||||
assertEquals(getInitialServerState(), serverState.getState());
|
||||
|
@ -702,7 +702,7 @@ public class PaymentChannelStateTest extends TestWithWallet {
|
|||
assertEquals(CENT.add(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE), wallet.getBalance());
|
||||
|
||||
Utils.setMockClock(); // Use mock clock
|
||||
final long EXPIRE_TIME = Utils.currentTimeMillis()/1000 + 60*60*24;
|
||||
final long EXPIRE_TIME = Utils.currentTimeSeconds() + 60*60*24;
|
||||
|
||||
serverState = makeServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME);
|
||||
assertEquals(getInitialServerState(), serverState.getState());
|
||||
|
@ -815,7 +815,7 @@ public class PaymentChannelStateTest extends TestWithWallet {
|
|||
Context.propagate(new Context(UNITTEST, 100, Coin.ZERO, true));
|
||||
|
||||
Utils.setMockClock(); // Use mock clock
|
||||
final long EXPIRE_TIME = Utils.currentTimeMillis()/1000 + 60*60*24;
|
||||
final long EXPIRE_TIME = Utils.currentTimeSeconds() + 60*60*24;
|
||||
|
||||
serverState = makeServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME);
|
||||
assertEquals(getInitialServerState(), serverState.getState());
|
||||
|
|
Loading…
Add table
Reference in a new issue