forked from Qortal/qortal
Fix unit tests
This commit is contained in:
parent
ecdf8212ea
commit
4b02b7a14f
@ -24,7 +24,7 @@ public class AccountUtils {
|
|||||||
PrivateKeyAccount recipientAccount = Common.getTestAccount(repository, recipient);
|
PrivateKeyAccount recipientAccount = Common.getTestAccount(repository, recipient);
|
||||||
|
|
||||||
byte[] reference = sendingAccount.getLastReference();
|
byte[] reference = sendingAccount.getLastReference();
|
||||||
long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1000;
|
long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1;
|
||||||
|
|
||||||
TransactionData transactionData = new PaymentTransactionData(timestamp, txGroupId, reference, sendingAccount.getPublicKey(), recipientAccount.getAddress(), amount, fee);
|
TransactionData transactionData = new PaymentTransactionData(timestamp, txGroupId, reference, sendingAccount.getPublicKey(), recipientAccount.getAddress(), amount, fee);
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ public class AccountUtils {
|
|||||||
PrivateKeyAccount recipientAccount = Common.getTestAccount(repository, recipient);
|
PrivateKeyAccount recipientAccount = Common.getTestAccount(repository, recipient);
|
||||||
|
|
||||||
byte[] reference = forgingAccount.getLastReference();
|
byte[] reference = forgingAccount.getLastReference();
|
||||||
long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1000;
|
long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1;
|
||||||
|
|
||||||
byte[] proxyPrivateKey = forgingAccount.getSharedSecret(recipientAccount.getPublicKey());
|
byte[] proxyPrivateKey = forgingAccount.getSharedSecret(recipientAccount.getPublicKey());
|
||||||
PrivateKeyAccount proxyAccount = new PrivateKeyAccount(null, proxyPrivateKey);
|
PrivateKeyAccount proxyAccount = new PrivateKeyAccount(null, proxyPrivateKey);
|
||||||
@ -52,7 +52,7 @@ public class AccountUtils {
|
|||||||
PrivateKeyAccount forgingAccount = Common.getTestAccount(repository, forger);
|
PrivateKeyAccount forgingAccount = Common.getTestAccount(repository, forger);
|
||||||
|
|
||||||
byte[] reference = forgingAccount.getLastReference();
|
byte[] reference = forgingAccount.getLastReference();
|
||||||
long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1000;
|
long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1;
|
||||||
|
|
||||||
return new EnableForgingTransactionData(timestamp, txGroupId, reference, forgingAccount.getPublicKey(), Crypto.toAddress(recipientPublicKey), fee);
|
return new EnableForgingTransactionData(timestamp, txGroupId, reference, forgingAccount.getPublicKey(), Crypto.toAddress(recipientPublicKey), fee);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class AssetUtils {
|
|||||||
PrivateKeyAccount account = Common.getTestAccount(repository, issuerAccountName);
|
PrivateKeyAccount account = Common.getTestAccount(repository, issuerAccountName);
|
||||||
|
|
||||||
byte[] reference = account.getLastReference();
|
byte[] reference = account.getLastReference();
|
||||||
long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1000;
|
long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1;
|
||||||
|
|
||||||
TransactionData transactionData = new IssueAssetTransactionData(timestamp, AssetUtils.txGroupId, reference, account.getPublicKey(), account.getAddress(), assetName, "desc", quantity, isDivisible, "{}", AssetUtils.fee);
|
TransactionData transactionData = new IssueAssetTransactionData(timestamp, AssetUtils.txGroupId, reference, account.getPublicKey(), account.getAddress(), assetName, "desc", quantity, isDivisible, "{}", AssetUtils.fee);
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ public class AssetUtils {
|
|||||||
PrivateKeyAccount toAccount = Common.getTestAccount(repository, toAccountName);
|
PrivateKeyAccount toAccount = Common.getTestAccount(repository, toAccountName);
|
||||||
|
|
||||||
byte[] reference = fromAccount.getLastReference();
|
byte[] reference = fromAccount.getLastReference();
|
||||||
long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1000;
|
long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1;
|
||||||
|
|
||||||
TransactionData transactionData = new TransferAssetTransactionData(timestamp, AssetUtils.txGroupId, reference, fromAccount.getPublicKey(), toAccount.getAddress(), amount, assetId, AssetUtils.fee);
|
TransactionData transactionData = new TransferAssetTransactionData(timestamp, AssetUtils.txGroupId, reference, fromAccount.getPublicKey(), toAccount.getAddress(), amount, assetId, AssetUtils.fee);
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ public class AssetUtils {
|
|||||||
PrivateKeyAccount account = Common.getTestAccount(repository, accountName);
|
PrivateKeyAccount account = Common.getTestAccount(repository, accountName);
|
||||||
|
|
||||||
byte[] reference = account.getLastReference();
|
byte[] reference = account.getLastReference();
|
||||||
long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1000;
|
long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1;
|
||||||
|
|
||||||
TransactionData transactionData = new CreateAssetOrderTransactionData(timestamp, txGroupId, reference, account.getPublicKey(), haveAssetId, wantAssetId, amount, price, fee);
|
TransactionData transactionData = new CreateAssetOrderTransactionData(timestamp, txGroupId, reference, account.getPublicKey(), haveAssetId, wantAssetId, amount, price, fee);
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ public class AssetUtils {
|
|||||||
PrivateKeyAccount account = Common.getTestAccount(repository, accountName);
|
PrivateKeyAccount account = Common.getTestAccount(repository, accountName);
|
||||||
|
|
||||||
byte[] reference = account.getLastReference();
|
byte[] reference = account.getLastReference();
|
||||||
long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1000;
|
long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1;
|
||||||
|
|
||||||
TransactionData transactionData = new CancelAssetOrderTransactionData(timestamp, txGroupId, reference, account.getPublicKey(), orderId, fee);
|
TransactionData transactionData = new CancelAssetOrderTransactionData(timestamp, txGroupId, reference, account.getPublicKey(), orderId, fee);
|
||||||
|
|
||||||
|
@ -20,6 +20,12 @@ public class TransactionUtils {
|
|||||||
// Add to unconfirmed
|
// Add to unconfirmed
|
||||||
assertTrue("Transaction's signature should be valid", transaction.isSignatureValid());
|
assertTrue("Transaction's signature should be valid", transaction.isSignatureValid());
|
||||||
|
|
||||||
|
// We might need to wait until transaction's timestamp is valid for the block we're about to generate
|
||||||
|
try {
|
||||||
|
Thread.sleep(1L);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
|
||||||
ValidationResult result = transaction.isValidUnconfirmed();
|
ValidationResult result = transaction.isValidUnconfirmed();
|
||||||
assertEquals("Transaction invalid", ValidationResult.OK, result);
|
assertEquals("Transaction invalid", ValidationResult.OK, result);
|
||||||
|
|
||||||
@ -28,7 +34,8 @@ public class TransactionUtils {
|
|||||||
repository.saveChanges();
|
repository.saveChanges();
|
||||||
|
|
||||||
// Generate block
|
// Generate block
|
||||||
BlockGenerator.generateTestingBlock(repository, signingAccount);
|
PrivateKeyAccount generatorAccount = Common.getTestAccount(repository, "alice");
|
||||||
|
BlockGenerator.generateTestingBlock(repository, generatorAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -80,9 +80,6 @@ public class RewardTests extends Common {
|
|||||||
final BigDecimal share = new BigDecimal("12.8");
|
final BigDecimal share = new BigDecimal("12.8");
|
||||||
|
|
||||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
// Bob needs to make a transaction so his public key is known
|
|
||||||
AccountUtils.pay(repository, "bob", "chloe", new BigDecimal("1.4444").setScale(8));
|
|
||||||
|
|
||||||
byte[] proxyPrivateKey = AccountUtils.proxyForging(repository, "alice", "bob", share);
|
byte[] proxyPrivateKey = AccountUtils.proxyForging(repository, "alice", "bob", share);
|
||||||
PrivateKeyAccount proxyAccount = new PrivateKeyAccount(repository, proxyPrivateKey);
|
PrivateKeyAccount proxyAccount = new PrivateKeyAccount(repository, proxyPrivateKey);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user