mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-31 15:22:16 +00:00
refactor s/Utils.now().getTime()/Utils.currentTimeMillis()/g
This commit is contained in:
parent
7324798242
commit
0c2f362795
@ -659,7 +659,7 @@ public class Block extends Message {
|
|||||||
private void checkTimestamp() throws VerificationException {
|
private void checkTimestamp() throws VerificationException {
|
||||||
maybeParseHeader();
|
maybeParseHeader();
|
||||||
// Allow injection of a fake clock to allow unit testing.
|
// 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)
|
if (time > currentTime + ALLOWED_TIME_DRIFT)
|
||||||
throw new VerificationException("Block too far in future");
|
throw new VerificationException("Block too far in future");
|
||||||
}
|
}
|
||||||
@ -1029,12 +1029,12 @@ public class Block extends Message {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public Block createNextBlock(@Nullable Address to, TransactionOutPoint prevOut) {
|
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
|
@VisibleForTesting
|
||||||
public Block createNextBlock(@Nullable Address to, BigInteger value) {
|
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
|
@VisibleForTesting
|
||||||
@ -1044,7 +1044,7 @@ public class Block extends Message {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public Block createNextBlockWithCoinbase(byte[] pubKey, BigInteger coinbaseValue) {
|
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
|
@VisibleForTesting
|
||||||
Block createNextBlockWithCoinbase(byte[] pubKey) {
|
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
|
@VisibleForTesting
|
||||||
|
@ -131,7 +131,7 @@ public class ECKey implements Serializable {
|
|||||||
ECPoint compressed = compressPoint(uncompressed);
|
ECPoint compressed = compressPoint(uncompressed);
|
||||||
pub = compressed.getEncoded();
|
pub = compressed.getEncoded();
|
||||||
|
|
||||||
creationTimeSeconds = Utils.now().getTime() / 1000;
|
creationTimeSeconds = Utils.currentTimeMillis() / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ECPoint compressPoint(ECPoint uncompressed) {
|
private static ECPoint compressPoint(ECPoint uncompressed) {
|
||||||
|
@ -1268,12 +1268,12 @@ public class Peer extends PeerSocketHandler {
|
|||||||
public PendingPing(long nonce) {
|
public PendingPing(long nonce) {
|
||||||
future = SettableFuture.create();
|
future = SettableFuture.create();
|
||||||
this.nonce = nonce;
|
this.nonce = nonce;
|
||||||
startTimeMsec = Utils.now().getTime();
|
startTimeMsec = Utils.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void complete() {
|
public void complete() {
|
||||||
checkNotNull(future, "Already completed");
|
checkNotNull(future, "Already completed");
|
||||||
Long elapsed = Utils.now().getTime() - startTimeMsec;
|
Long elapsed = Utils.currentTimeMillis() - startTimeMsec;
|
||||||
Peer.this.addPingTimeData(elapsed);
|
Peer.this.addPingTimeData(elapsed);
|
||||||
log.debug("{}: ping time is {} msec", Peer.this.toString(), elapsed);
|
log.debug("{}: ping time is {} msec", Peer.this.toString(), elapsed);
|
||||||
future.set(elapsed);
|
future.set(elapsed);
|
||||||
|
@ -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
|
//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
|
//so assumes itself to be up. For a fuller implementation this needs to be dynamic only if
|
||||||
//the address refers to this client.
|
//the address refers to this client.
|
||||||
int secs = (int) (Utils.now().getTime() / 1000);
|
int secs = (int) (Utils.currentTimeMillis() / 1000);
|
||||||
uint32ToByteStreamLE(secs, stream);
|
uint32ToByteStreamLE(secs, stream);
|
||||||
}
|
}
|
||||||
uint64ToByteStreamLE(services, stream); // nServices.
|
uint64ToByteStreamLE(services, stream); // nServices.
|
||||||
|
@ -775,7 +775,7 @@ public class PeerGroup extends AbstractExecutionThreadService implements Transac
|
|||||||
protected Peer connectTo(PeerAddress address, boolean incrementMaxConnections) {
|
protected Peer connectTo(PeerAddress address, boolean incrementMaxConnections) {
|
||||||
VersionMessage ver = getVersionMessage().duplicate();
|
VersionMessage ver = getVersionMessage().duplicate();
|
||||||
ver.bestHeight = chain == null ? 0 : chain.getBestChainHeight();
|
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 peer = new Peer(params, ver, address, chain, memoryPool);
|
||||||
peer.addEventListener(startupListener, Threading.SAME_THREAD);
|
peer.addEventListener(startupListener, Threading.SAME_THREAD);
|
||||||
|
@ -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.
|
* Same as {@link #addWatchedAddress(Address, long)} with the current time as the creation time.
|
||||||
*/
|
*/
|
||||||
public boolean addWatchedAddress(final Address address) {
|
public boolean addWatchedAddress(final Address address) {
|
||||||
long now = Utils.now().getTime() / 1000;
|
long now = Utils.currentTimeMillis() / 1000;
|
||||||
return addWatchedAddresses(Lists.newArrayList(address), now) == 1;
|
return addWatchedAddresses(Lists.newArrayList(address), now) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2577,7 +2577,7 @@ public class Wallet implements Serializable, BlockChainListener, PeerFilterProvi
|
|||||||
for (Script script : watchedScripts)
|
for (Script script : watchedScripts)
|
||||||
earliestTime = Math.min(script.getCreationTimeSeconds(), earliestTime);
|
earliestTime = Math.min(script.getCreationTimeSeconds(), earliestTime);
|
||||||
if (earliestTime == Long.MAX_VALUE)
|
if (earliestTime == Long.MAX_VALUE)
|
||||||
return Utils.now().getTime() / 1000;
|
return Utils.currentTimeMillis() / 1000;
|
||||||
return earliestTime;
|
return earliestTime;
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
@ -134,7 +134,7 @@ public class PaymentChannelClient implements IPaymentChannelClient {
|
|||||||
|
|
||||||
checkState(initiate.getExpireTimeSecs() > 0 && initiate.getMinAcceptedChannelSize() >= 0);
|
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) {
|
if (initiate.getExpireTimeSecs() > MAX_EXPIRY_TIME) {
|
||||||
log.error("Server expiry time was out of our allowed bounds: {} vs {}", initiate.getExpireTimeSecs(),
|
log.error("Server expiry time was out of our allowed bounds: {} vs {}", initiate.getExpireTimeSecs(),
|
||||||
MAX_EXPIRY_TIME);
|
MAX_EXPIRY_TIME);
|
||||||
|
@ -364,7 +364,7 @@ public class PaymentChannelClientState {
|
|||||||
* storage and throwing an {@link IllegalStateException} if it is.
|
* storage and throwing an {@link IllegalStateException} if it is.
|
||||||
*/
|
*/
|
||||||
public synchronized void checkNotExpired() {
|
public synchronized void checkNotExpired() {
|
||||||
if (Utils.now().getTime()/1000 > expiryTime) {
|
if (Utils.currentTimeMillis()/1000 > expiryTime) {
|
||||||
state = State.EXPIRED;
|
state = State.EXPIRED;
|
||||||
disconnectFromChannel();
|
disconnectFromChannel();
|
||||||
throw new IllegalStateException("Channel expired");
|
throw new IllegalStateException("Channel expired");
|
||||||
|
@ -219,7 +219,7 @@ public class PaymentChannelServer {
|
|||||||
myKey = new ECKey();
|
myKey = new ECKey();
|
||||||
wallet.addKey(myKey);
|
wallet.addKey(myKey);
|
||||||
|
|
||||||
expireTime = Utils.now().getTime() / 1000 + timeWindow;
|
expireTime = Utils.currentTimeMillis() / 1000 + timeWindow;
|
||||||
step = InitStep.WAITING_ON_UNSIGNED_REFUND;
|
step = InitStep.WAITING_ON_UNSIGNED_REFUND;
|
||||||
|
|
||||||
Protos.Initiate.Builder initiateBuilder = Protos.Initiate.newBuilder()
|
Protos.Initiate.Builder initiateBuilder = Protos.Initiate.newBuilder()
|
||||||
|
@ -94,7 +94,7 @@ public class StoredPaymentChannelClientStates implements WalletExtension {
|
|||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
final Set<StoredClientChannel> setChannels = mapChannels.get(id);
|
final Set<StoredClientChannel> setChannels = mapChannels.get(id);
|
||||||
final long nowSeconds = Utils.now().getTime() / 1000;
|
final long nowSeconds = Utils.currentTimeMillis() / 1000;
|
||||||
int earliestTime = Integer.MAX_VALUE;
|
int earliestTime = Integer.MAX_VALUE;
|
||||||
for (StoredClientChannel channel : setChannels) {
|
for (StoredClientChannel channel : setChannels) {
|
||||||
synchronized (channel) {
|
synchronized (channel) {
|
||||||
@ -177,7 +177,7 @@ public class StoredPaymentChannelClientStates implements WalletExtension {
|
|||||||
announcePeerGroup.broadcastTransaction(channel.refund);
|
announcePeerGroup.broadcastTransaction(channel.refund);
|
||||||
}
|
}
|
||||||
// Add the difference between real time and Utils.now() so that test-cases can use a mock clock.
|
// 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 {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public class StoredPaymentChannelServerStates implements WalletExtension {
|
|||||||
checkArgument(mapChannels.put(channel.contract.getHash(), checkNotNull(channel)) == null);
|
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.
|
// 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
|
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);
|
log.info("Scheduling channel for automatic closure at {}: {}", autocloseTime, channel);
|
||||||
channelTimeoutHandler.schedule(new TimerTask() {
|
channelTimeoutHandler.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,7 +72,7 @@ public class Script {
|
|||||||
// Used from ScriptBuilder.
|
// Used from ScriptBuilder.
|
||||||
Script(List<ScriptChunk> chunks) {
|
Script(List<ScriptChunk> chunks) {
|
||||||
this.chunks = Collections.unmodifiableList(new ArrayList<ScriptChunk>(chunks));
|
this.chunks = Collections.unmodifiableList(new ArrayList<ScriptChunk>(chunks));
|
||||||
creationTimeSeconds = Utils.now().getTime() / 1000;
|
creationTimeSeconds = Utils.currentTimeMillis() / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,7 +83,7 @@ public class Script {
|
|||||||
public Script(byte[] programBytes) throws ScriptException {
|
public Script(byte[] programBytes) throws ScriptException {
|
||||||
program = programBytes;
|
program = programBytes;
|
||||||
parse(programBytes);
|
parse(programBytes);
|
||||||
creationTimeSeconds = Utils.now().getTime() / 1000;
|
creationTimeSeconds = Utils.currentTimeMillis() / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Script(byte[] programBytes, long creationTimeSeconds) throws ScriptException {
|
public Script(byte[] programBytes, long creationTimeSeconds) throws ScriptException {
|
||||||
|
@ -178,7 +178,7 @@ public class TestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static BlockPair createFakeBlock(BlockStore blockStore, Transaction... transactions) {
|
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 {
|
public static Block makeSolvedTestBlock(BlockStore blockStore, Address coinsTo) throws BlockStoreException {
|
||||||
|
@ -181,7 +181,7 @@ public class BlockChainTest {
|
|||||||
Block prev = unitTestParams.getGenesisBlock();
|
Block prev = unitTestParams.getGenesisBlock();
|
||||||
Utils.setMockClock(System.currentTimeMillis()/1000);
|
Utils.setMockClock(System.currentTimeMillis()/1000);
|
||||||
for (int i = 0; i < unitTestParams.getInterval() - 1; i++) {
|
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));
|
assertTrue(chain.add(newBlock));
|
||||||
prev = newBlock;
|
prev = newBlock;
|
||||||
// The fake chain should seem to be "fast" for the purposes of difficulty calculations.
|
// 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.
|
// Now add another block that has no difficulty adjustment, it should be rejected.
|
||||||
try {
|
try {
|
||||||
chain.add(prev.createNextBlock(coinbaseTo, Utils.now().getTime()/1000));
|
chain.add(prev.createNextBlock(coinbaseTo, Utils.currentTimeMillis()/1000));
|
||||||
fail();
|
fail();
|
||||||
} catch (VerificationException e) {
|
} catch (VerificationException e) {
|
||||||
}
|
}
|
||||||
// Create a new block with the right difficulty target given our blistering speed relative to the huge amount
|
// 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).
|
// 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.setDifficultyTarget(0x201fFFFFL);
|
||||||
b.solve();
|
b.solve();
|
||||||
assertTrue(chain.add(b));
|
assertTrue(chain.add(b));
|
||||||
|
@ -964,7 +964,7 @@ public class FullBlockTestGenerator {
|
|||||||
|
|
||||||
// Block with timestamp > 2h in the future
|
// Block with timestamp > 2h in the future
|
||||||
Block b48 = createNextBlock(b44, chainHeadHeight + 16, out15, null);
|
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();
|
b48.solve();
|
||||||
blocks.add(new BlockAndValidity(blockToHeightMap, b48, false, true, b44.getHash(), chainHeadHeight + 15, "b48"));
|
blocks.add(new BlockAndValidity(blockToHeightMap, b48, false, true, b44.getHash(), chainHeadHeight + 15, "b48"));
|
||||||
|
|
||||||
|
@ -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.
|
// 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.
|
// The wallet was already added to the peer in setup.
|
||||||
final int WEEK = 86400 * 7;
|
final int WEEK = 86400 * 7;
|
||||||
final long now = Utils.now().getTime() / 1000;
|
final long now = Utils.currentTimeMillis() / 1000;
|
||||||
assertTrue(peerGroup.getFastCatchupTimeSecs() > now - WEEK - 10000);
|
assertTrue(peerGroup.getFastCatchupTimeSecs() > now - WEEK - 10000);
|
||||||
Wallet w2 = new Wallet(params);
|
Wallet w2 = new Wallet(params);
|
||||||
ECKey key1 = new ECKey();
|
ECKey key1 = new ECKey();
|
||||||
|
@ -449,7 +449,7 @@ public class PeerTest extends TestWithNetworkConnections {
|
|||||||
Block b4 = makeSolvedTestBlock(b3);
|
Block b4 = makeSolvedTestBlock(b3);
|
||||||
|
|
||||||
// Request headers until the last 2 blocks.
|
// 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();
|
peer.startBlockChainDownload();
|
||||||
GetHeadersMessage getheaders = (GetHeadersMessage) outbound(writeTarget);
|
GetHeadersMessage getheaders = (GetHeadersMessage) outbound(writeTarget);
|
||||||
List<Sha256Hash> expectedLocator = new ArrayList<Sha256Hash>();
|
List<Sha256Hash> expectedLocator = new ArrayList<Sha256Hash>();
|
||||||
|
@ -479,7 +479,7 @@ public class ChannelConnectionTest extends TestWithWallet {
|
|||||||
server.receiveMessage(pair.clientRecorder.checkNextMsg(MessageType.CLIENT_VERSION));
|
server.receiveMessage(pair.clientRecorder.checkNextMsg(MessageType.CLIENT_VERSION));
|
||||||
client.receiveMessage(pair.serverRecorder.checkNextMsg(MessageType.SERVER_VERSION));
|
client.receiveMessage(pair.serverRecorder.checkNextMsg(MessageType.SERVER_VERSION));
|
||||||
client.receiveMessage(Protos.TwoWayChannelMessage.newBuilder()
|
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)
|
.setMinAcceptedChannelSize(100)
|
||||||
.setMultisigKey(ByteString.copyFrom(new ECKey().getPubKey()))
|
.setMultisigKey(ByteString.copyFrom(new ECKey().getPubKey()))
|
||||||
.setMinPayment(Transaction.MIN_NONDUST_OUTPUT.longValue()))
|
.setMinPayment(Transaction.MIN_NONDUST_OUTPUT.longValue()))
|
||||||
@ -504,7 +504,7 @@ public class ChannelConnectionTest extends TestWithWallet {
|
|||||||
server.receiveMessage(pair.clientRecorder.checkNextMsg(MessageType.CLIENT_VERSION));
|
server.receiveMessage(pair.clientRecorder.checkNextMsg(MessageType.CLIENT_VERSION));
|
||||||
client.receiveMessage(pair.serverRecorder.checkNextMsg(MessageType.SERVER_VERSION));
|
client.receiveMessage(pair.serverRecorder.checkNextMsg(MessageType.SERVER_VERSION));
|
||||||
client.receiveMessage(Protos.TwoWayChannelMessage.newBuilder()
|
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())
|
.setMinAcceptedChannelSize(Utils.COIN.add(BigInteger.ONE).longValue())
|
||||||
.setMultisigKey(ByteString.copyFrom(new ECKey().getPubKey()))
|
.setMultisigKey(ByteString.copyFrom(new ECKey().getPubKey()))
|
||||||
.setMinPayment(Transaction.MIN_NONDUST_OUTPUT.longValue()))
|
.setMinPayment(Transaction.MIN_NONDUST_OUTPUT.longValue()))
|
||||||
@ -530,7 +530,7 @@ public class ChannelConnectionTest extends TestWithWallet {
|
|||||||
server.receiveMessage(pair.clientRecorder.checkNextMsg(MessageType.CLIENT_VERSION));
|
server.receiveMessage(pair.clientRecorder.checkNextMsg(MessageType.CLIENT_VERSION));
|
||||||
client.receiveMessage(pair.serverRecorder.checkNextMsg(MessageType.SERVER_VERSION));
|
client.receiveMessage(pair.serverRecorder.checkNextMsg(MessageType.SERVER_VERSION));
|
||||||
client.receiveMessage(Protos.TwoWayChannelMessage.newBuilder()
|
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())
|
.setMinAcceptedChannelSize(Utils.COIN.add(BigInteger.ONE).longValue())
|
||||||
.setMultisigKey(ByteString.copyFrom(new ECKey().getPubKey()))
|
.setMultisigKey(ByteString.copyFrom(new ECKey().getPubKey()))
|
||||||
.setMinPayment(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.longValue()))
|
.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));
|
client.receiveMessage(pair.serverRecorder.checkNextMsg(MessageType.SERVER_VERSION));
|
||||||
try {
|
try {
|
||||||
client.receiveMessage(Protos.TwoWayChannelMessage.newBuilder()
|
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())
|
.setMinAcceptedChannelSize(Utils.CENT.longValue())
|
||||||
.setMultisigKey(ByteString.copyFrom(new ECKey().getPubKey()))
|
.setMultisigKey(ByteString.copyFrom(new ECKey().getPubKey()))
|
||||||
.setMinPayment(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.longValue()))
|
.setMinPayment(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.longValue()))
|
||||||
|
@ -115,7 +115,7 @@ public class PaymentChannelStateTest extends TestWithWallet {
|
|||||||
// Check it all works when things are normal (no attacks, no problems).
|
// Check it all works when things are normal (no attacks, no problems).
|
||||||
|
|
||||||
Utils.rollMockClock(0); // Use mock clock
|
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);
|
serverState = new PaymentChannelServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME);
|
||||||
assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState());
|
assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState());
|
||||||
@ -229,7 +229,7 @@ public class PaymentChannelStateTest extends TestWithWallet {
|
|||||||
wallet.addOrUpdateExtension(stateStorage);
|
wallet.addOrUpdateExtension(stateStorage);
|
||||||
|
|
||||||
Utils.rollMockClock(0); // Use mock clock
|
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);
|
serverState = new PaymentChannelServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME);
|
||||||
assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState());
|
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
|
// We'll broadcast only one tx: multisig contract
|
||||||
|
|
||||||
Utils.rollMockClock(0); // Use mock clock
|
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);
|
serverState = new PaymentChannelServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME);
|
||||||
assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState());
|
assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState());
|
||||||
@ -542,7 +542,7 @@ public class PaymentChannelStateTest extends TestWithWallet {
|
|||||||
assertEquals(Utils.CENT, wallet.getBalance());
|
assertEquals(Utils.CENT, wallet.getBalance());
|
||||||
|
|
||||||
Utils.rollMockClock(0); // Use mock clock
|
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);
|
serverState = new PaymentChannelServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME);
|
||||||
assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState());
|
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)
|
// 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
|
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);
|
serverState = new PaymentChannelServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME);
|
||||||
assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState());
|
assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState());
|
||||||
@ -731,7 +731,7 @@ public class PaymentChannelStateTest extends TestWithWallet {
|
|||||||
|
|
||||||
// Start with a copy of basic()....
|
// Start with a copy of basic()....
|
||||||
Utils.rollMockClock(0); // Use mock clock
|
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);
|
serverState = new PaymentChannelServerState(mockBroadcaster, serverWallet, serverKey, EXPIRE_TIME);
|
||||||
assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState());
|
assertEquals(PaymentChannelServerState.State.WAITING_FOR_REFUND_TRANSACTION, serverState.getState());
|
||||||
|
Loading…
Reference in New Issue
Block a user