mirror of
https://github.com/Qortal/qortal.git
synced 2025-07-23 04:36:50 +00:00
More work on block rewards in relation to account level/legacy qora held.
Rename Asset.QORA to Asset.QORT so we can also have Asset.LEGACY_QORA as another hard-coded asset. Add "is unspendable" aspect to assets where only the asset owner can transfer/pay asset to other people. Asset trading is barred regardless, as is use of asset for ATs. Added "initial level" to account data in preparation for accounts levelling up from generating blocks. Added distribution/removal of block reward based on legacy-QORA held. Removed "previous level" from ACCOUNT_LEVEL transactions as they're only ever valid in genesis block and so previous level is never needed.
This commit is contained in:
@@ -78,14 +78,14 @@ public class RepositoryTests extends Common {
|
||||
try (final Repository repository2 = RepositoryManager.getRepository()) {
|
||||
// Update account in 2
|
||||
Account account2 = Common.getTestAccount(repository2, "alice");
|
||||
account2.setConfirmedBalance(Asset.QORA, BigDecimal.valueOf(1234L));
|
||||
account2.setConfirmedBalance(Asset.QORT, BigDecimal.valueOf(1234L));
|
||||
repository2.saveChanges();
|
||||
}
|
||||
|
||||
repository1.discardChanges();
|
||||
|
||||
// Update account in 1
|
||||
account1.setConfirmedBalance(Asset.QORA, BigDecimal.valueOf(5678L));
|
||||
account1.setConfirmedBalance(Asset.QORT, BigDecimal.valueOf(5678L));
|
||||
repository1.saveChanges();
|
||||
}
|
||||
}
|
||||
|
@@ -105,18 +105,18 @@ public class TransactionTests extends Common {
|
||||
|
||||
// Create test generator account
|
||||
generator = new PrivateKeyAccount(repository, generatorSeed);
|
||||
accountRepository.setLastReference(new AccountData(generator.getAddress(), generatorSeed, generator.getPublicKey(), Group.NO_GROUP, 0, null, 0));
|
||||
accountRepository.save(new AccountBalanceData(generator.getAddress(), Asset.QORA, initialGeneratorBalance));
|
||||
accountRepository.setLastReference(new AccountData(generator.getAddress(), generatorSeed, generator.getPublicKey(), Group.NO_GROUP, 0, null, 0, 0));
|
||||
accountRepository.save(new AccountBalanceData(generator.getAddress(), Asset.QORT, initialGeneratorBalance));
|
||||
|
||||
// Create test sender account
|
||||
sender = new PrivateKeyAccount(repository, senderSeed);
|
||||
|
||||
// Mock account
|
||||
reference = senderSeed;
|
||||
accountRepository.setLastReference(new AccountData(sender.getAddress(), reference, sender.getPublicKey(), Group.NO_GROUP, 0, null, 0));
|
||||
accountRepository.setLastReference(new AccountData(sender.getAddress(), reference, sender.getPublicKey(), Group.NO_GROUP, 0, null, 0, 0));
|
||||
|
||||
// Mock balance
|
||||
accountRepository.save(new AccountBalanceData(sender.getAddress(), Asset.QORA, initialSenderBalance));
|
||||
accountRepository.save(new AccountBalanceData(sender.getAddress(), Asset.QORT, initialSenderBalance));
|
||||
|
||||
repository.saveChanges();
|
||||
}
|
||||
@@ -170,17 +170,17 @@ public class TransactionTests extends Common {
|
||||
|
||||
// Check sender's balance
|
||||
BigDecimal expectedBalance = initialSenderBalance.subtract(amount).subtract(fee);
|
||||
BigDecimal actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORA).getBalance();
|
||||
BigDecimal actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Sender's new balance incorrect", expectedBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Fee should be in generator's balance
|
||||
expectedBalance = initialGeneratorBalance.add(fee);
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Generator's new balance incorrect", expectedBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Amount should be in recipient's balance
|
||||
expectedBalance = amount;
|
||||
actualBalance = accountRepository.getBalance(recipient.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(recipient.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Recipient's new balance incorrect", expectedBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Check recipient's reference
|
||||
@@ -192,11 +192,11 @@ public class TransactionTests extends Common {
|
||||
repository.saveChanges();
|
||||
|
||||
// Check sender's balance
|
||||
actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Sender's reverted balance incorrect", initialSenderBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Check generator's balance
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Generator's new balance incorrect", initialGeneratorBalance.compareTo(actualBalance) == 0);
|
||||
}
|
||||
|
||||
@@ -230,12 +230,12 @@ public class TransactionTests extends Common {
|
||||
|
||||
// Check sender's balance
|
||||
BigDecimal expectedBalance = initialSenderBalance.subtract(fee);
|
||||
BigDecimal actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORA).getBalance();
|
||||
BigDecimal actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Sender's new balance incorrect", expectedBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Fee should be in generator's balance
|
||||
expectedBalance = initialGeneratorBalance.add(fee);
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Generator's new balance incorrect", expectedBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Check name was registered
|
||||
@@ -494,12 +494,12 @@ public class TransactionTests extends Common {
|
||||
|
||||
// Check sender's balance
|
||||
BigDecimal expectedBalance = initialSenderBalance.subtract(fee);
|
||||
BigDecimal actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORA).getBalance();
|
||||
BigDecimal actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Sender's new balance incorrect", expectedBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Fee should be in generator's balance
|
||||
expectedBalance = initialGeneratorBalance.add(fee);
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Generator's new balance incorrect", expectedBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Check poll was created
|
||||
@@ -598,9 +598,10 @@ public class TransactionTests extends Common {
|
||||
BigDecimal fee = BigDecimal.ONE;
|
||||
long timestamp = parentBlockData.getTimestamp() + 1_000;
|
||||
String data = (timestamp >= BlockChain.getInstance().getQoraV2Timestamp()) ? "{}" : null;
|
||||
boolean isUnspendable = false;
|
||||
|
||||
BaseTransactionData baseTransactionData = new BaseTransactionData(timestamp, Group.NO_GROUP, reference, sender.getPublicKey(), fee, null);
|
||||
IssueAssetTransactionData issueAssetTransactionData = new IssueAssetTransactionData(baseTransactionData, sender.getAddress(), assetName, description, quantity, isDivisible, data);
|
||||
IssueAssetTransactionData issueAssetTransactionData = new IssueAssetTransactionData(baseTransactionData, sender.getAddress(), assetName, description, quantity, isDivisible, data, isUnspendable);
|
||||
|
||||
Transaction issueAssetTransaction = new IssueAssetTransaction(repository, issueAssetTransactionData);
|
||||
issueAssetTransaction.sign(sender);
|
||||
@@ -618,19 +619,19 @@ public class TransactionTests extends Common {
|
||||
|
||||
// Check sender's balance
|
||||
BigDecimal expectedBalance = initialSenderBalance.subtract(fee);
|
||||
BigDecimal actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORA).getBalance();
|
||||
BigDecimal actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Sender's new balance incorrect", expectedBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Fee should be in generator's balance
|
||||
expectedBalance = initialGeneratorBalance.add(fee);
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Generator's new balance incorrect", expectedBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Check we now have an assetId
|
||||
Long assetId = issueAssetTransactionData.getAssetId();
|
||||
assertNotNull(assetId);
|
||||
// Should NOT collide with Asset.QORA
|
||||
assertFalse(assetId == Asset.QORA);
|
||||
assertFalse(assetId == Asset.QORT);
|
||||
|
||||
// Check asset now exists
|
||||
AssetRepository assetRepo = this.repository.getAssetRepository();
|
||||
@@ -647,11 +648,11 @@ public class TransactionTests extends Common {
|
||||
repository.saveChanges();
|
||||
|
||||
// Check sender's balance
|
||||
actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Sender's reverted balance incorrect", initialSenderBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Check generator's balance
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Generator's reverted balance incorrect", initialGeneratorBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Check asset no longer exists
|
||||
@@ -678,8 +679,8 @@ public class TransactionTests extends Common {
|
||||
AssetRepository assetRepo = this.repository.getAssetRepository();
|
||||
AssetData originalAssetData = assetRepo.fromAssetName(assetName);
|
||||
long assetId = originalAssetData.getAssetId();
|
||||
BigDecimal originalSenderBalance = sender.getConfirmedBalance(Asset.QORA);
|
||||
BigDecimal originalGeneratorBalance = generator.getConfirmedBalance(Asset.QORA);
|
||||
BigDecimal originalSenderBalance = sender.getConfirmedBalance(Asset.QORT);
|
||||
BigDecimal originalGeneratorBalance = generator.getConfirmedBalance(Asset.QORT);
|
||||
|
||||
// Transfer asset to new recipient
|
||||
Account recipient = new PublicKeyAccount(repository, recipientSeed);
|
||||
@@ -706,12 +707,12 @@ public class TransactionTests extends Common {
|
||||
|
||||
// Check sender's balance
|
||||
BigDecimal expectedBalance = originalSenderBalance.subtract(fee);
|
||||
BigDecimal actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORA).getBalance();
|
||||
BigDecimal actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Sender's new balance incorrect", expectedBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Fee should be in generator's balance
|
||||
expectedBalance = originalGeneratorBalance.add(fee);
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Generator's new balance incorrect", expectedBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Check asset balances
|
||||
@@ -729,11 +730,11 @@ public class TransactionTests extends Common {
|
||||
repository.saveChanges();
|
||||
|
||||
// Check sender's balance
|
||||
actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Sender's reverted balance incorrect", originalSenderBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Check generator's balance
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Generator's reverted balance incorrect", originalGeneratorBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Check asset balances
|
||||
@@ -781,7 +782,7 @@ public class TransactionTests extends Common {
|
||||
parentBlockData = block.getBlockData();
|
||||
|
||||
// Order: buyer has 10 QORA and wants to buy "test asset" at a price of 50 "test asset" per QORA.
|
||||
long haveAssetId = Asset.QORA;
|
||||
long haveAssetId = Asset.QORT;
|
||||
BigDecimal amount = BigDecimal.valueOf(10).setScale(8);
|
||||
long wantAssetId = assetId;
|
||||
BigDecimal price = BigDecimal.valueOf(50).setScale(8);
|
||||
@@ -852,7 +853,7 @@ public class TransactionTests extends Common {
|
||||
PrivateKeyAccount buyer = new PrivateKeyAccount(repository, recipientSeed);
|
||||
|
||||
// Fetch orders
|
||||
long haveAssetId = Asset.QORA;
|
||||
long haveAssetId = Asset.QORT;
|
||||
long wantAssetId = assetId;
|
||||
List<OrderData> orders = assetRepo.getOpenOrders(haveAssetId, wantAssetId);
|
||||
|
||||
@@ -917,7 +918,7 @@ public class TransactionTests extends Common {
|
||||
PrivateKeyAccount buyer = new PrivateKeyAccount(repository, recipientSeed);
|
||||
|
||||
// Fetch orders
|
||||
long originalHaveAssetId = Asset.QORA;
|
||||
long originalHaveAssetId = Asset.QORT;
|
||||
long originalWantAssetId = assetId;
|
||||
List<OrderData> orders = assetRepo.getOpenOrders(originalHaveAssetId, originalWantAssetId);
|
||||
|
||||
@@ -937,7 +938,7 @@ public class TransactionTests extends Common {
|
||||
// This order should be a partial match for original order, and at a better price than asked
|
||||
long haveAssetId = assetId;
|
||||
BigDecimal amount = BigDecimal.valueOf(40).setScale(8);
|
||||
long wantAssetId = Asset.QORA;
|
||||
long wantAssetId = Asset.QORT;
|
||||
BigDecimal price = BigDecimal.ONE.setScale(8).divide(BigDecimal.valueOf(60).setScale(8), RoundingMode.DOWN);
|
||||
BigDecimal fee = BigDecimal.ONE;
|
||||
long timestamp = parentBlockData.getTimestamp() + 1_000;
|
||||
@@ -1041,7 +1042,7 @@ public class TransactionTests extends Common {
|
||||
byte[] seed = recipientSeed.clone();
|
||||
seed[0] += i;
|
||||
Account recipient = new PublicKeyAccount(repository, seed);
|
||||
long assetId = Asset.QORA;
|
||||
long assetId = Asset.QORT;
|
||||
|
||||
BigDecimal amount = BigDecimal.valueOf(1_000L + i).setScale(8);
|
||||
expectedSenderBalance = expectedSenderBalance.subtract(amount);
|
||||
@@ -1069,12 +1070,12 @@ public class TransactionTests extends Common {
|
||||
repository.saveChanges();
|
||||
|
||||
// Check sender's balance
|
||||
BigDecimal actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORA).getBalance();
|
||||
BigDecimal actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Sender's new balance incorrect", expectedSenderBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Fee should be in generator's balance
|
||||
BigDecimal expectedBalance = initialGeneratorBalance.add(fee);
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Generator's new balance incorrect", expectedBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Check recipients
|
||||
@@ -1087,7 +1088,7 @@ public class TransactionTests extends Common {
|
||||
|
||||
// Amount should be in recipient's balance
|
||||
expectedBalance = paymentData.getAmount();
|
||||
actualBalance = accountRepository.getBalance(recipient.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(recipient.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Recipient's new balance incorrect", expectedBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
}
|
||||
@@ -1097,11 +1098,11 @@ public class TransactionTests extends Common {
|
||||
repository.saveChanges();
|
||||
|
||||
// Check sender's balance
|
||||
actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Sender's reverted balance incorrect", initialSenderBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Check generator's balance
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Generator's new balance incorrect", initialGeneratorBalance.compareTo(actualBalance) == 0);
|
||||
}
|
||||
|
||||
@@ -1121,7 +1122,7 @@ public class TransactionTests extends Common {
|
||||
|
||||
BaseTransactionData baseTransactionData = new BaseTransactionData(timestamp, Group.NO_GROUP, reference, sender.getPublicKey(), fee, null);
|
||||
MessageTransactionData messageTransactionData = new MessageTransactionData(baseTransactionData, version,
|
||||
recipient.getAddress(), Asset.QORA, amount, data, isText, isEncrypted);
|
||||
recipient.getAddress(), Asset.QORT, amount, data, isText, isEncrypted);
|
||||
|
||||
Transaction messageTransaction = new MessageTransaction(repository, messageTransactionData);
|
||||
messageTransaction.sign(sender);
|
||||
@@ -1139,17 +1140,17 @@ public class TransactionTests extends Common {
|
||||
|
||||
// Check sender's balance
|
||||
BigDecimal expectedBalance = initialSenderBalance.subtract(amount).subtract(fee);
|
||||
BigDecimal actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORA).getBalance();
|
||||
BigDecimal actualBalance = accountRepository.getBalance(sender.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Sender's new balance incorrect", expectedBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Fee should be in generator's balance
|
||||
expectedBalance = initialGeneratorBalance.add(fee);
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(generator.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Generator's new balance incorrect", expectedBalance.compareTo(actualBalance) == 0);
|
||||
|
||||
// Amount should be in recipient's balance
|
||||
expectedBalance = amount;
|
||||
actualBalance = accountRepository.getBalance(recipient.getAddress(), Asset.QORA).getBalance();
|
||||
actualBalance = accountRepository.getBalance(recipient.getAddress(), Asset.QORT).getBalance();
|
||||
assertTrue("Recipient's new balance incorrect", expectedBalance.compareTo(actualBalance) == 0);
|
||||
}
|
||||
|
||||
|
@@ -39,7 +39,7 @@ public class AssetUtils {
|
||||
long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1;
|
||||
|
||||
BaseTransactionData baseTransactionData = new BaseTransactionData(timestamp, AssetUtils.txGroupId, reference, account.getPublicKey(), AssetUtils.fee, null);
|
||||
TransactionData transactionData = new IssueAssetTransactionData(baseTransactionData, account.getAddress(), assetName, "desc", quantity, isDivisible, "{}");
|
||||
TransactionData transactionData = new IssueAssetTransactionData(baseTransactionData, account.getAddress(), assetName, "desc", quantity, isDivisible, "{}", false);
|
||||
|
||||
TransactionUtils.signAndForge(repository, transactionData, account);
|
||||
|
||||
|
@@ -25,7 +25,7 @@ public class ArbitraryTestTransaction extends TestTransaction {
|
||||
DataType dataType = DataType.RAW_DATA;
|
||||
|
||||
String recipient = account.getAddress();
|
||||
final long assetId = Asset.QORA;
|
||||
final long assetId = Asset.QORT;
|
||||
BigDecimal amount = BigDecimal.valueOf(123L);
|
||||
|
||||
List<PaymentData> payments = new ArrayList<>();
|
||||
|
@@ -18,7 +18,7 @@ public class AtTestTransaction extends TestTransaction {
|
||||
String atAddress = Crypto.toATAddress(signature);
|
||||
String recipient = account.getAddress();
|
||||
BigDecimal amount = BigDecimal.valueOf(123);
|
||||
final long assetId = Asset.QORA;
|
||||
final long assetId = Asset.QORT;
|
||||
byte[] message = new byte[32];
|
||||
random.nextBytes(message);
|
||||
|
||||
|
@@ -12,7 +12,7 @@ import org.qora.repository.Repository;
|
||||
public class CreateAssetOrderTestTransaction extends TestTransaction {
|
||||
|
||||
public static TransactionData randomTransaction(Repository repository, PrivateKeyAccount account, boolean wantValid) throws DataException {
|
||||
final long haveAssetId = Asset.QORA;
|
||||
final long haveAssetId = Asset.QORT;
|
||||
final long wantAssetId = 1;
|
||||
BigDecimal amount = BigDecimal.valueOf(123);
|
||||
BigDecimal price = BigDecimal.valueOf(123);
|
||||
|
@@ -22,7 +22,7 @@ public class DeployAtTestTransaction extends TestTransaction {
|
||||
byte[] creationBytes = new byte[1024];
|
||||
random.nextBytes(creationBytes);
|
||||
BigDecimal amount = BigDecimal.valueOf(123);
|
||||
final long assetId = Asset.QORA;
|
||||
final long assetId = Asset.QORT;
|
||||
|
||||
return new DeployAtTransactionData(generateBase(account), name, description, atType, tags, creationBytes, amount, assetId);
|
||||
}
|
||||
|
@@ -20,8 +20,9 @@ public class IssueAssetTestTransaction extends TestTransaction {
|
||||
final long quantity = 1_000_000L;
|
||||
final boolean isDivisible = true;
|
||||
String data = AssetUtils.randomData();
|
||||
final boolean isUnspendable = false;
|
||||
|
||||
return new IssueAssetTransactionData(generateBase(account), owner, assetName, description, quantity, isDivisible, data);
|
||||
return new IssueAssetTransactionData(generateBase(account), owner, assetName, description, quantity, isDivisible, data, isUnspendable);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ public class MessageTestTransaction extends TestTransaction {
|
||||
public static TransactionData randomTransaction(Repository repository, PrivateKeyAccount account, boolean wantValid) throws DataException {
|
||||
final int version = 3;
|
||||
String recipient = account.getAddress();
|
||||
final long assetId = Asset.QORA;
|
||||
final long assetId = Asset.QORT;
|
||||
BigDecimal amount = BigDecimal.valueOf(123L);
|
||||
byte[] data = "message contents".getBytes();
|
||||
final boolean isText = true;
|
||||
|
@@ -16,7 +16,7 @@ public class MultiPaymentTestTransaction extends TestTransaction {
|
||||
|
||||
public static TransactionData randomTransaction(Repository repository, PrivateKeyAccount account, boolean wantValid) throws DataException {
|
||||
String recipient = account.getAddress();
|
||||
final long assetId = Asset.QORA;
|
||||
final long assetId = Asset.QORT;
|
||||
BigDecimal amount = BigDecimal.valueOf(123L);
|
||||
|
||||
List<PaymentData> payments = new ArrayList<>();
|
||||
|
@@ -13,7 +13,7 @@ public class TransferAssetTestTransaction extends TestTransaction {
|
||||
|
||||
public static TransactionData randomTransaction(Repository repository, PrivateKeyAccount account, boolean wantValid) throws DataException {
|
||||
String recipient = account.getAddress();
|
||||
final long assetId = Asset.QORA;
|
||||
final long assetId = Asset.QORT;
|
||||
BigDecimal amount = BigDecimal.valueOf(123);
|
||||
|
||||
return new TransferAssetTransactionData(generateBase(account), recipient, amount, assetId);
|
||||
|
@@ -35,7 +35,7 @@ public class RewardTests extends Common {
|
||||
@Test
|
||||
public void testSimpleReward() throws DataException {
|
||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||
Map<String, Map<Long, BigDecimal>> initialBalances = AccountUtils.getBalances(repository, Asset.QORA);
|
||||
Map<String, Map<Long, BigDecimal>> initialBalances = AccountUtils.getBalances(repository, Asset.QORT);
|
||||
|
||||
PrivateKeyAccount forgingAccount = Common.getTestAccount(repository, "alice");
|
||||
|
||||
@@ -43,15 +43,15 @@ public class RewardTests extends Common {
|
||||
|
||||
BlockGenerator.generateTestingBlock(repository, forgingAccount);
|
||||
|
||||
BigDecimal expectedBalance = initialBalances.get("alice").get(Asset.QORA).add(blockReward);
|
||||
AccountUtils.assertBalance(repository, "alice", Asset.QORA, expectedBalance);
|
||||
BigDecimal expectedBalance = initialBalances.get("alice").get(Asset.QORT).add(blockReward);
|
||||
AccountUtils.assertBalance(repository, "alice", Asset.QORT, expectedBalance);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRewards() throws DataException {
|
||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||
Map<String, Map<Long, BigDecimal>> initialBalances = AccountUtils.getBalances(repository, Asset.QORA);
|
||||
Map<String, Map<Long, BigDecimal>> initialBalances = AccountUtils.getBalances(repository, Asset.QORT);
|
||||
|
||||
PrivateKeyAccount forgingAccount = Common.getTestAccount(repository, "alice");
|
||||
|
||||
@@ -60,7 +60,7 @@ public class RewardTests extends Common {
|
||||
int rewardIndex = rewards.size() - 1;
|
||||
|
||||
RewardByHeight rewardInfo = rewards.get(rewardIndex);
|
||||
BigDecimal expectedBalance = initialBalances.get("alice").get(Asset.QORA);
|
||||
BigDecimal expectedBalance = initialBalances.get("alice").get(Asset.QORT);
|
||||
|
||||
for (int height = rewardInfo.height; height > 1; --height) {
|
||||
if (height < rewardInfo.height) {
|
||||
@@ -72,7 +72,7 @@ public class RewardTests extends Common {
|
||||
expectedBalance = expectedBalance.add(rewardInfo.reward);
|
||||
}
|
||||
|
||||
AccountUtils.assertBalance(repository, "alice", Asset.QORA, expectedBalance);
|
||||
AccountUtils.assertBalance(repository, "alice", Asset.QORT, expectedBalance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,17 +84,17 @@ public class RewardTests extends Common {
|
||||
byte[] proxyPrivateKey = AccountUtils.proxyForging(repository, "alice", "bob", share);
|
||||
PrivateKeyAccount proxyAccount = new PrivateKeyAccount(repository, proxyPrivateKey);
|
||||
|
||||
Map<String, Map<Long, BigDecimal>> initialBalances = AccountUtils.getBalances(repository, Asset.QORA);
|
||||
Map<String, Map<Long, BigDecimal>> initialBalances = AccountUtils.getBalances(repository, Asset.QORT);
|
||||
BigDecimal blockReward = BlockUtils.getNextBlockReward(repository);
|
||||
BlockGenerator.generateTestingBlock(repository, proxyAccount);
|
||||
|
||||
// We're expecting reward * 12.8% to Bob, the rest to Alice
|
||||
|
||||
BigDecimal bobShare = blockReward.multiply(share.movePointLeft(2)).setScale(8, RoundingMode.DOWN);
|
||||
AccountUtils.assertBalance(repository, "bob", Asset.QORA, initialBalances.get("bob").get(Asset.QORA).add(bobShare));
|
||||
AccountUtils.assertBalance(repository, "bob", Asset.QORT, initialBalances.get("bob").get(Asset.QORT).add(bobShare));
|
||||
|
||||
BigDecimal aliceShare = blockReward.subtract(bobShare);
|
||||
AccountUtils.assertBalance(repository, "alice", Asset.QORA, initialBalances.get("alice").get(Asset.QORA).add(aliceShare));
|
||||
AccountUtils.assertBalance(repository, "alice", Asset.QORT, initialBalances.get("alice").get(Asset.QORT).add(aliceShare));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -90,8 +90,8 @@ public class GroupApprovalTests extends Common {
|
||||
PrivateKeyAccount bobAccount = Common.getTestAccount(repository, "bob");
|
||||
byte[] bobOriginalReference = bobAccount.getLastReference();
|
||||
|
||||
BigDecimal aliceOriginalBalance = aliceAccount.getConfirmedBalance(Asset.QORA);
|
||||
BigDecimal bobOriginalBalance = bobAccount.getConfirmedBalance(Asset.QORA);
|
||||
BigDecimal aliceOriginalBalance = aliceAccount.getConfirmedBalance(Asset.QORT);
|
||||
BigDecimal bobOriginalBalance = bobAccount.getConfirmedBalance(Asset.QORT);
|
||||
|
||||
BigDecimal blockReward = BlockUtils.getNextBlockReward(repository);
|
||||
Transaction bobAssetTransaction = buildIssueAssetTransaction(repository, "bob", groupId);
|
||||
@@ -106,11 +106,11 @@ public class GroupApprovalTests extends Common {
|
||||
assertFalse("reference should have changed", Arrays.equals(bobOriginalReference, bobPostAssetReference));
|
||||
|
||||
// Bob's balance should have the fee removed, even though the transaction itself hasn't been approved yet
|
||||
BigDecimal bobPostAssetBalance = bobAccount.getConfirmedBalance(Asset.QORA);
|
||||
BigDecimal bobPostAssetBalance = bobAccount.getConfirmedBalance(Asset.QORT);
|
||||
Common.assertEqualBigDecimals("approval-pending transaction creator's balance incorrect", bobOriginalBalance.subtract(fee), bobPostAssetBalance);
|
||||
|
||||
// Transaction fee should have ended up in forging account
|
||||
BigDecimal alicePostAssetBalance = aliceAccount.getConfirmedBalance(Asset.QORA);
|
||||
BigDecimal alicePostAssetBalance = aliceAccount.getConfirmedBalance(Asset.QORT);
|
||||
Common.assertEqualBigDecimals("block forger's balance incorrect", aliceOriginalBalance.add(blockReward).add(fee), alicePostAssetBalance);
|
||||
|
||||
// Have Bob do a non-approval transaction to change his last-reference
|
||||
@@ -167,7 +167,7 @@ public class GroupApprovalTests extends Common {
|
||||
assertTrue("reference should be pre-payment", Arrays.equals(bobOriginalReference, bobReference));
|
||||
|
||||
// Also check Bob's balance is back to original value
|
||||
BigDecimal bobBalance = bobAccount.getConfirmedBalance(Asset.QORA);
|
||||
BigDecimal bobBalance = bobAccount.getConfirmedBalance(Asset.QORT);
|
||||
Common.assertEqualBigDecimals("reverted balance doesn't match original", bobOriginalBalance, bobBalance);
|
||||
}
|
||||
}
|
||||
@@ -438,7 +438,7 @@ public class GroupApprovalTests extends Common {
|
||||
long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1;
|
||||
|
||||
BaseTransactionData baseTransactionData = new BaseTransactionData(timestamp, txGroupId, reference, account.getPublicKey(), fee, null);
|
||||
TransactionData transactionData = new IssueAssetTransactionData(baseTransactionData, account.getAddress(), "test asset", "test asset desc", 1000L, true, "{}");
|
||||
TransactionData transactionData = new IssueAssetTransactionData(baseTransactionData, account.getAddress(), "test asset", "test asset desc", 1000L, true, "{}", false);
|
||||
|
||||
return Transaction.fromData(repository, transactionData);
|
||||
}
|
||||
|
Reference in New Issue
Block a user