diff --git a/core/src/main/java/com/google/bitcoin/core/Block.java b/core/src/main/java/com/google/bitcoin/core/Block.java index 371ed7d1..d255c323 100644 --- a/core/src/main/java/com/google/bitcoin/core/Block.java +++ b/core/src/main/java/com/google/bitcoin/core/Block.java @@ -659,7 +659,7 @@ public class Block extends Message { private void checkTimestamp() throws VerificationException { maybeParseHeader(); // Allow injection of a fake clock to allow unit testing. - long currentTime = Utils.now().getTime()/1000; + long currentTime = Utils.currentTimeMillis()/1000; if (time > currentTime + ALLOWED_TIME_DRIFT) throw new VerificationException("Block too far in future"); } @@ -1029,12 +1029,12 @@ public class Block extends Message { @VisibleForTesting public Block createNextBlock(@Nullable Address to, TransactionOutPoint prevOut) { - return createNextBlock(to, prevOut, Utils.now().getTime() / 1000, EMPTY_BYTES, Utils.toNanoCoins(50, 0)); + return createNextBlock(to, prevOut, Utils.currentTimeMillis() / 1000, EMPTY_BYTES, Utils.toNanoCoins(50, 0)); } @VisibleForTesting public Block createNextBlock(@Nullable Address to, BigInteger value) { - return createNextBlock(to, null, Utils.now().getTime() / 1000, EMPTY_BYTES, value); + return createNextBlock(to, null, Utils.currentTimeMillis() / 1000, EMPTY_BYTES, value); } @VisibleForTesting @@ -1044,7 +1044,7 @@ public class Block extends Message { @VisibleForTesting public Block createNextBlockWithCoinbase(byte[] pubKey, BigInteger coinbaseValue) { - return createNextBlock(null, null, Utils.now().getTime() / 1000, pubKey, coinbaseValue); + return createNextBlock(null, null, Utils.currentTimeMillis() / 1000, pubKey, coinbaseValue); } /** @@ -1053,7 +1053,7 @@ public class Block extends Message { */ @VisibleForTesting Block createNextBlockWithCoinbase(byte[] pubKey) { - return createNextBlock(null, null, Utils.now().getTime() / 1000, pubKey, Utils.toNanoCoins(50, 0)); + return createNextBlock(null, null, Utils.currentTimeMillis() / 1000, pubKey, Utils.toNanoCoins(50, 0)); } @VisibleForTesting diff --git a/core/src/main/java/com/google/bitcoin/core/ECKey.java b/core/src/main/java/com/google/bitcoin/core/ECKey.java index 3e4ec749..b18bbbbd 100644 --- a/core/src/main/java/com/google/bitcoin/core/ECKey.java +++ b/core/src/main/java/com/google/bitcoin/core/ECKey.java @@ -131,7 +131,7 @@ public class ECKey implements Serializable { ECPoint compressed = compressPoint(uncompressed); pub = compressed.getEncoded(); - creationTimeSeconds = Utils.now().getTime() / 1000; + creationTimeSeconds = Utils.currentTimeMillis() / 1000; } private static ECPoint compressPoint(ECPoint uncompressed) { diff --git a/core/src/main/java/com/google/bitcoin/core/Peer.java b/core/src/main/java/com/google/bitcoin/core/Peer.java index 38de48cb..5425769a 100644 --- a/core/src/main/java/com/google/bitcoin/core/Peer.java +++ b/core/src/main/java/com/google/bitcoin/core/Peer.java @@ -1268,12 +1268,12 @@ public class Peer extends PeerSocketHandler { public PendingPing(long nonce) { future = SettableFuture.create(); this.nonce = nonce; - startTimeMsec = Utils.now().getTime(); + startTimeMsec = Utils.currentTimeMillis(); } public void complete() { checkNotNull(future, "Already completed"); - Long elapsed = Utils.now().getTime() - startTimeMsec; + Long elapsed = Utils.currentTimeMillis() - startTimeMsec; Peer.this.addPingTimeData(elapsed); log.debug("{}: ping time is {} msec", Peer.this.toString(), elapsed); future.set(elapsed); diff --git a/core/src/main/java/com/google/bitcoin/core/PeerAddress.java b/core/src/main/java/com/google/bitcoin/core/PeerAddress.java index 7cd34a4b..6e424e96 100644 --- a/core/src/main/java/com/google/bitcoin/core/PeerAddress.java +++ b/core/src/main/java/com/google/bitcoin/core/PeerAddress.java @@ -113,7 +113,7 @@ public class PeerAddress extends ChildMessage { //TODO this appears to be dynamic because the client only ever sends out it's own address //so assumes itself to be up. For a fuller implementation this needs to be dynamic only if //the address refers to this client. - int secs = (int) (Utils.now().getTime() / 1000); + int secs = (int) (Utils.currentTimeMillis() / 1000); uint32ToByteStreamLE(secs, stream); } uint64ToByteStreamLE(services, stream); // nServices. diff --git a/core/src/main/java/com/google/bitcoin/core/PeerGroup.java b/core/src/main/java/com/google/bitcoin/core/PeerGroup.java index 8384ada2..34d15eaf 100644 --- a/core/src/main/java/com/google/bitcoin/core/PeerGroup.java +++ b/core/src/main/java/com/google/bitcoin/core/PeerGroup.java @@ -775,7 +775,7 @@ public class PeerGroup extends AbstractExecutionThreadService implements Transac protected Peer connectTo(PeerAddress address, boolean incrementMaxConnections) { VersionMessage ver = getVersionMessage().duplicate(); ver.bestHeight = chain == null ? 0 : chain.getBestChainHeight(); - ver.time = Utils.now().getTime() / 1000; + ver.time = Utils.currentTimeMillis() / 1000; Peer peer = new Peer(params, ver, address, chain, memoryPool); peer.addEventListener(startupListener, Threading.SAME_THREAD); diff --git a/core/src/main/java/com/google/bitcoin/core/Wallet.java b/core/src/main/java/com/google/bitcoin/core/Wallet.java index 8cd036ed..a7eb3a4d 100644 --- a/core/src/main/java/com/google/bitcoin/core/Wallet.java +++ b/core/src/main/java/com/google/bitcoin/core/Wallet.java @@ -2039,7 +2039,7 @@ public class Wallet implements Serializable, BlockChainListener, PeerFilterProvi * Same as {@link #addWatchedAddress(Address, long)} with the current time as the creation time. */ public boolean addWatchedAddress(final Address address) { - long now = Utils.now().getTime() / 1000; + long now = Utils.currentTimeMillis() / 1000; return addWatchedAddresses(Lists.newArrayList(address), now) == 1; } @@ -2577,7 +2577,7 @@ public class Wallet implements Serializable, BlockChainListener, PeerFilterProvi for (Script script : watchedScripts) earliestTime = Math.min(script.getCreationTimeSeconds(), earliestTime); if (earliestTime == Long.MAX_VALUE) - return Utils.now().getTime() / 1000; + return Utils.currentTimeMillis() / 1000; return earliestTime; } finally { lock.unlock(); diff --git a/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelClient.java b/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelClient.java index 20d4daa3..ba63119d 100644 --- a/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelClient.java +++ b/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelClient.java @@ -134,7 +134,7 @@ public class PaymentChannelClient implements IPaymentChannelClient { checkState(initiate.getExpireTimeSecs() > 0 && initiate.getMinAcceptedChannelSize() >= 0); - final long MAX_EXPIRY_TIME = Utils.now().getTime() / 1000 + MAX_TIME_WINDOW; + final long MAX_EXPIRY_TIME = Utils.currentTimeMillis() / 1000 + MAX_TIME_WINDOW; if (initiate.getExpireTimeSecs() > MAX_EXPIRY_TIME) { log.error("Server expiry time was out of our allowed bounds: {} vs {}", initiate.getExpireTimeSecs(), MAX_EXPIRY_TIME); diff --git a/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelClientState.java b/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelClientState.java index 5ed8d26b..40a68f52 100644 --- a/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelClientState.java +++ b/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelClientState.java @@ -364,7 +364,7 @@ public class PaymentChannelClientState { * storage and throwing an {@link IllegalStateException} if it is. */ public synchronized void checkNotExpired() { - if (Utils.now().getTime()/1000 > expiryTime) { + if (Utils.currentTimeMillis()/1000 > expiryTime) { state = State.EXPIRED; disconnectFromChannel(); throw new IllegalStateException("Channel expired"); diff --git a/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelServer.java b/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelServer.java index 75dabe8b..bbd8968c 100644 --- a/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelServer.java +++ b/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelServer.java @@ -219,7 +219,7 @@ public class PaymentChannelServer { myKey = new ECKey(); wallet.addKey(myKey); - expireTime = Utils.now().getTime() / 1000 + timeWindow; + expireTime = Utils.currentTimeMillis() / 1000 + timeWindow; step = InitStep.WAITING_ON_UNSIGNED_REFUND; Protos.Initiate.Builder initiateBuilder = Protos.Initiate.newBuilder() diff --git a/core/src/main/java/com/google/bitcoin/protocols/channels/StoredPaymentChannelClientStates.java b/core/src/main/java/com/google/bitcoin/protocols/channels/StoredPaymentChannelClientStates.java index 50f70f93..3d6efa2d 100644 --- a/core/src/main/java/com/google/bitcoin/protocols/channels/StoredPaymentChannelClientStates.java +++ b/core/src/main/java/com/google/bitcoin/protocols/channels/StoredPaymentChannelClientStates.java @@ -94,7 +94,7 @@ public class StoredPaymentChannelClientStates implements WalletExtension { lock.lock(); try { final Set setChannels = mapChannels.get(id); - final long nowSeconds = Utils.now().getTime() / 1000; + final long nowSeconds = Utils.currentTimeMillis() / 1000; int earliestTime = Integer.MAX_VALUE; for (StoredClientChannel channel : setChannels) { synchronized (channel) { @@ -177,7 +177,7 @@ public class StoredPaymentChannelClientStates implements WalletExtension { announcePeerGroup.broadcastTransaction(channel.refund); } // Add the difference between real time and Utils.now() so that test-cases can use a mock clock. - }, new Date(channel.expiryTimeSeconds() * 1000 + (System.currentTimeMillis() - Utils.now().getTime()))); + }, new Date(channel.expiryTimeSeconds() * 1000 + (System.currentTimeMillis() - Utils.currentTimeMillis()))); } finally { lock.unlock(); } diff --git a/core/src/main/java/com/google/bitcoin/protocols/channels/StoredPaymentChannelServerStates.java b/core/src/main/java/com/google/bitcoin/protocols/channels/StoredPaymentChannelServerStates.java index c980d4b4..681e01f0 100644 --- a/core/src/main/java/com/google/bitcoin/protocols/channels/StoredPaymentChannelServerStates.java +++ b/core/src/main/java/com/google/bitcoin/protocols/channels/StoredPaymentChannelServerStates.java @@ -119,7 +119,7 @@ public class StoredPaymentChannelServerStates implements WalletExtension { checkArgument(mapChannels.put(channel.contract.getHash(), checkNotNull(channel)) == null); // Add the difference between real time and Utils.now() so that test-cases can use a mock clock. Date autocloseTime = new Date((channel.refundTransactionUnlockTimeSecs + CHANNEL_EXPIRE_OFFSET) * 1000L - + (System.currentTimeMillis() - Utils.now().getTime())); + + (System.currentTimeMillis() - Utils.currentTimeMillis())); log.info("Scheduling channel for automatic closure at {}: {}", autocloseTime, channel); channelTimeoutHandler.schedule(new TimerTask() { @Override diff --git a/core/src/main/java/com/google/bitcoin/script/Script.java b/core/src/main/java/com/google/bitcoin/script/Script.java index 095b7812..2368c88e 100644 --- a/core/src/main/java/com/google/bitcoin/script/Script.java +++ b/core/src/main/java/com/google/bitcoin/script/Script.java @@ -72,7 +72,7 @@ public class Script { // Used from ScriptBuilder. Script(List chunks) { this.chunks = Collections.unmodifiableList(new ArrayList(chunks)); - creationTimeSeconds = Utils.now().getTime() / 1000; + creationTimeSeconds = Utils.currentTimeMillis() / 1000; } /** @@ -83,7 +83,7 @@ public class Script { public Script(byte[] programBytes) throws ScriptException { program = programBytes; parse(programBytes); - creationTimeSeconds = Utils.now().getTime() / 1000; + creationTimeSeconds = Utils.currentTimeMillis() / 1000; } public Script(byte[] programBytes, long creationTimeSeconds) throws ScriptException { diff --git a/core/src/main/java/com/google/bitcoin/utils/TestUtils.java b/core/src/main/java/com/google/bitcoin/utils/TestUtils.java index bd9ddd99..f2ce3c6e 100644 --- a/core/src/main/java/com/google/bitcoin/utils/TestUtils.java +++ b/core/src/main/java/com/google/bitcoin/utils/TestUtils.java @@ -178,7 +178,7 @@ public class TestUtils { } public static BlockPair createFakeBlock(BlockStore blockStore, Transaction... transactions) { - return createFakeBlock(blockStore, Utils.now().getTime() / 1000, transactions); + return createFakeBlock(blockStore, Utils.currentTimeMillis() / 1000, transactions); } public static Block makeSolvedTestBlock(BlockStore blockStore, Address coinsTo) throws BlockStoreException { diff --git a/core/src/test/java/com/google/bitcoin/core/BlockChainTest.java b/core/src/test/java/com/google/bitcoin/core/BlockChainTest.java index 402c7a36..af3e5281 100644 --- a/core/src/test/java/com/google/bitcoin/core/BlockChainTest.java +++ b/core/src/test/java/com/google/bitcoin/core/BlockChainTest.java @@ -181,7 +181,7 @@ public class BlockChainTest { Block prev = unitTestParams.getGenesisBlock(); Utils.setMockClock(System.currentTimeMillis()/1000); for (int i = 0; i < unitTestParams.getInterval() - 1; i++) { - Block newBlock = prev.createNextBlock(coinbaseTo, Utils.now().getTime()/1000); + Block newBlock = prev.createNextBlock(coinbaseTo, Utils.currentTimeMillis()/1000); assertTrue(chain.add(newBlock)); prev = newBlock; // The fake chain should seem to be "fast" for the purposes of difficulty calculations. @@ -189,13 +189,13 @@ public class BlockChainTest { } // Now add another block that has no difficulty adjustment, it should be rejected. try { - chain.add(prev.createNextBlock(coinbaseTo, Utils.now().getTime()/1000)); + chain.add(prev.createNextBlock(coinbaseTo, Utils.currentTimeMillis()/1000)); fail(); } catch (VerificationException e) { } // Create a new block with the right difficulty target given our blistering speed relative to the huge amount // of time it's supposed to take (set in the unit test network parameters). - Block b = prev.createNextBlock(coinbaseTo, Utils.now().getTime()/1000); + Block b = prev.createNextBlock(coinbaseTo, Utils.currentTimeMillis()/1000); b.setDifficultyTarget(0x201fFFFFL); b.solve(); assertTrue(chain.add(b)); diff --git a/core/src/test/java/com/google/bitcoin/core/FullBlockTestGenerator.java b/core/src/test/java/com/google/bitcoin/core/FullBlockTestGenerator.java index c0a31100..cd69f3a9 100644 --- a/core/src/test/java/com/google/bitcoin/core/FullBlockTestGenerator.java +++ b/core/src/test/java/com/google/bitcoin/core/FullBlockTestGenerator.java @@ -964,7 +964,7 @@ public class FullBlockTestGenerator { // Block with timestamp > 2h in the future Block b48 = createNextBlock(b44, chainHeadHeight + 16, out15, null); - b48.setTime(Utils.now().getTime() / 1000 + 60*60*3); + b48.setTime(Utils.currentTimeMillis() / 1000 + 60*60*3); b48.solve(); blocks.add(new BlockAndValidity(blockToHeightMap, b48, false, true, b44.getHash(), chainHeadHeight + 15, "b48")); diff --git a/core/src/test/java/com/google/bitcoin/core/PeerGroupTest.java b/core/src/test/java/com/google/bitcoin/core/PeerGroupTest.java index 54eb27d8..5a2fa163 100644 --- a/core/src/test/java/com/google/bitcoin/core/PeerGroupTest.java +++ b/core/src/test/java/com/google/bitcoin/core/PeerGroupTest.java @@ -338,7 +338,7 @@ public class PeerGroupTest extends TestWithPeerGroup { // Check the fast catchup time was initialized to something around the current runtime minus a week. // The wallet was already added to the peer in setup. final int WEEK = 86400 * 7; - final long now = Utils.now().getTime() / 1000; + final long now = Utils.currentTimeMillis() / 1000; assertTrue(peerGroup.getFastCatchupTimeSecs() > now - WEEK - 10000); Wallet w2 = new Wallet(params); ECKey key1 = new ECKey(); diff --git a/core/src/test/java/com/google/bitcoin/core/PeerTest.java b/core/src/test/java/com/google/bitcoin/core/PeerTest.java index 627039fe..31f56ee6 100644 --- a/core/src/test/java/com/google/bitcoin/core/PeerTest.java +++ b/core/src/test/java/com/google/bitcoin/core/PeerTest.java @@ -449,7 +449,7 @@ public class PeerTest extends TestWithNetworkConnections { Block b4 = makeSolvedTestBlock(b3); // Request headers until the last 2 blocks. - peer.setDownloadParameters((Utils.now().getTime() / 1000) - (600*2) + 1, false); + peer.setDownloadParameters((Utils.currentTimeMillis() / 1000) - (600*2) + 1, false); peer.startBlockChainDownload(); GetHeadersMessage getheaders = (GetHeadersMessage) outbound(writeTarget); List expectedLocator = new ArrayList(); diff --git a/core/src/test/java/com/google/bitcoin/protocols/channels/ChannelConnectionTest.java b/core/src/test/java/com/google/bitcoin/protocols/channels/ChannelConnectionTest.java index e64ab41e..29e75b92 100644 --- a/core/src/test/java/com/google/bitcoin/protocols/channels/ChannelConnectionTest.java +++ b/core/src/test/java/com/google/bitcoin/protocols/channels/ChannelConnectionTest.java @@ -479,7 +479,7 @@ public class ChannelConnectionTest extends TestWithWallet { server.receiveMessage(pair.clientRecorder.checkNextMsg(MessageType.CLIENT_VERSION)); client.receiveMessage(pair.serverRecorder.checkNextMsg(MessageType.SERVER_VERSION)); client.receiveMessage(Protos.TwoWayChannelMessage.newBuilder() - .setInitiate(Protos.Initiate.newBuilder().setExpireTimeSecs(Utils.now().getTime() / 1000 + 60 * 60 * 48) + .setInitiate(Protos.Initiate.newBuilder().setExpireTimeSecs(Utils.currentTimeMillis() / 1000 + 60 * 60 * 48) .setMinAcceptedChannelSize(100) .setMultisigKey(ByteString.copyFrom(new ECKey().getPubKey())) .setMinPayment(Transaction.MIN_NONDUST_OUTPUT.longValue())) @@ -504,7 +504,7 @@ public class ChannelConnectionTest extends TestWithWallet { server.receiveMessage(pair.clientRecorder.checkNextMsg(MessageType.CLIENT_VERSION)); client.receiveMessage(pair.serverRecorder.checkNextMsg(MessageType.SERVER_VERSION)); client.receiveMessage(Protos.TwoWayChannelMessage.newBuilder() - .setInitiate(Protos.Initiate.newBuilder().setExpireTimeSecs(Utils.now().getTime() / 1000) + .setInitiate(Protos.Initiate.newBuilder().setExpireTimeSecs(Utils.currentTimeMillis() / 1000) .setMinAcceptedChannelSize(Utils.COIN.add(BigInteger.ONE).longValue()) .setMultisigKey(ByteString.copyFrom(new ECKey().getPubKey())) .setMinPayment(Transaction.MIN_NONDUST_OUTPUT.longValue())) @@ -530,7 +530,7 @@ public class ChannelConnectionTest extends TestWithWallet { server.receiveMessage(pair.clientRecorder.checkNextMsg(MessageType.CLIENT_VERSION)); client.receiveMessage(pair.serverRecorder.checkNextMsg(MessageType.SERVER_VERSION)); client.receiveMessage(Protos.TwoWayChannelMessage.newBuilder() - .setInitiate(Protos.Initiate.newBuilder().setExpireTimeSecs(Utils.now().getTime() / 1000) + .setInitiate(Protos.Initiate.newBuilder().setExpireTimeSecs(Utils.currentTimeMillis() / 1000) .setMinAcceptedChannelSize(Utils.COIN.add(BigInteger.ONE).longValue()) .setMultisigKey(ByteString.copyFrom(new ECKey().getPubKey())) .setMinPayment(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.longValue())) @@ -553,7 +553,7 @@ public class ChannelConnectionTest extends TestWithWallet { client.receiveMessage(pair.serverRecorder.checkNextMsg(MessageType.SERVER_VERSION)); try { client.receiveMessage(Protos.TwoWayChannelMessage.newBuilder() - .setInitiate(Protos.Initiate.newBuilder().setExpireTimeSecs(Utils.now().getTime() / 1000) + .setInitiate(Protos.Initiate.newBuilder().setExpireTimeSecs(Utils.currentTimeMillis() / 1000) .setMinAcceptedChannelSize(Utils.CENT.longValue()) .setMultisigKey(ByteString.copyFrom(new ECKey().getPubKey())) .setMinPayment(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.longValue())) diff --git a/core/src/test/java/com/google/bitcoin/protocols/channels/PaymentChannelStateTest.java b/core/src/test/java/com/google/bitcoin/protocols/channels/PaymentChannelStateTest.java index ddb022b4..210e101b 100644 --- a/core/src/test/java/com/google/bitcoin/protocols/channels/PaymentChannelStateTest.java +++ b/core/src/test/java/com/google/bitcoin/protocols/channels/PaymentChannelStateTest.java @@ -115,7 +115,7 @@ public class PaymentChannelStateTest extends TestWithWallet { // Check it all works when things are normal (no attacks, no problems). Utils.rollMockClock(0); // Use mock clock - final long EXPIRE_TIME = Utils.now().getTime()/1000 + 60*60*24; + final long EXPIRE_TIME = Utils.currentTimeMillis()/1000 + 60*60*24; serverState = new PaymentChannelServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME); assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState()); @@ -229,7 +229,7 @@ public class PaymentChannelStateTest extends TestWithWallet { wallet.addOrUpdateExtension(stateStorage); Utils.rollMockClock(0); // Use mock clock - final long EXPIRE_TIME = Utils.now().getTime()/1000 + 60*60*24; + final long EXPIRE_TIME = Utils.currentTimeMillis()/1000 + 60*60*24; serverState = new PaymentChannelServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME); assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState()); @@ -331,7 +331,7 @@ public class PaymentChannelStateTest extends TestWithWallet { // We'll broadcast only one tx: multisig contract Utils.rollMockClock(0); // Use mock clock - final long EXPIRE_TIME = Utils.now().getTime()/1000 + 60*60*24; + final long EXPIRE_TIME = Utils.currentTimeMillis()/1000 + 60*60*24; serverState = new PaymentChannelServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME); assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState()); @@ -542,7 +542,7 @@ public class PaymentChannelStateTest extends TestWithWallet { assertEquals(Utils.CENT, wallet.getBalance()); Utils.rollMockClock(0); // Use mock clock - final long EXPIRE_TIME = Utils.now().getTime()/1000 + 60*60*24; + final long EXPIRE_TIME = Utils.currentTimeMillis()/1000 + 60*60*24; serverState = new PaymentChannelServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME); assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState()); @@ -645,7 +645,7 @@ public class PaymentChannelStateTest extends TestWithWallet { // Test that the server properly adds the necessary fee at the end (or just drops the payment if its not worth it) Utils.rollMockClock(0); // Use mock clock - final long EXPIRE_TIME = Utils.now().getTime()/1000 + 60*60*24; + final long EXPIRE_TIME = Utils.currentTimeMillis()/1000 + 60*60*24; serverState = new PaymentChannelServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME); assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState()); @@ -731,7 +731,7 @@ public class PaymentChannelStateTest extends TestWithWallet { // Start with a copy of basic().... Utils.rollMockClock(0); // Use mock clock - final long EXPIRE_TIME = Utils.now().getTime()/1000 + 60*60*24; + final long EXPIRE_TIME = Utils.currentTimeMillis()/1000 + 60*60*24; serverState = new PaymentChannelServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME); assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState());