group approval tests and fixes

This commit is contained in:
catbref
2019-06-02 17:07:07 +01:00
parent 8af761c1c3
commit c9f226cf88
9 changed files with 296 additions and 114 deletions

View File

@@ -1090,7 +1090,7 @@ public class Block {
}
protected void processBlockRewards() throws DataException {
BigDecimal reward = getRewardAtHeight(this.blockData.getHeight());
BigDecimal reward = Block.getRewardAtHeight(this.blockData.getHeight());
// No reward for our height?
if (reward == null)
@@ -1335,7 +1335,7 @@ public class Block {
}
protected void orphanBlockRewards() throws DataException {
BigDecimal reward = getRewardAtHeight(this.blockData.getHeight());
BigDecimal reward = Block.getRewardAtHeight(this.blockData.getHeight());
// No reward for our height?
if (reward == null)
@@ -1397,7 +1397,7 @@ public class Block {
atRepository.deleteATStates(this.blockData.getHeight());
}
protected BigDecimal getRewardAtHeight(int ourHeight) {
public static BigDecimal getRewardAtHeight(int ourHeight) {
List<RewardByHeight> rewardsByHeight = BlockChain.getInstance().getBlockRewardsByHeight();
// No rewards configured?

View File

@@ -68,9 +68,13 @@ public class GroupApprovalTransaction extends Transaction {
if (pendingTransactionData == null)
return ValidationResult.TRANSACTION_UNKNOWN;
// Check pending transaction is not already in a block
if (this.repository.getTransactionRepository().getHeightFromSignature(groupApprovalTransactionData.getPendingSignature()) != 0)
return ValidationResult.TRANSACTION_ALREADY_CONFIRMED;
// Check pending transaction is actually needs group approval
if (pendingTransactionData.getApprovalStatus() == ApprovalStatus.NOT_REQUIRED)
return ValidationResult.GROUP_APPROVAL_NOT_REQUIRED;
// Check pending transaction is actually pending
if (pendingTransactionData.getApprovalStatus() != ApprovalStatus.PENDING)
return ValidationResult.GROUP_APPROVAL_DECIDED;
Account admin = getAdmin();

View File

@@ -230,6 +230,8 @@ public abstract class Transaction {
INVALID_PUBLIC_KEY(79),
AT_UNKNOWN(80),
AT_ALREADY_EXISTS(81),
GROUP_APPROVAL_NOT_REQUIRED(82),
GROUP_APPROVAL_DECIDED(83),
NOT_YET_RELEASED(1000);
public final int value;