Restrict TRANSFER_PRIVS recipients to new (non-existent) accounts.

This commit is contained in:
catbref
2020-03-04 15:41:47 +00:00
parent 450ff7318f
commit a3c44428d3
3 changed files with 34 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import org.junit.Before;
import org.junit.Test;
import org.qortal.account.Account;
import org.qortal.account.PrivateKeyAccount;
import org.qortal.account.PublicKeyAccount;
import org.qortal.block.BlockChain;
import org.qortal.block.BlockMinter;
import org.qortal.data.account.AccountData;
@@ -19,11 +20,13 @@ import org.qortal.test.common.BlockUtils;
import org.qortal.test.common.Common;
import org.qortal.test.common.TestAccount;
import org.qortal.test.common.TransactionUtils;
import org.qortal.transform.Transformer;
import static org.junit.Assert.*;
import java.math.BigDecimal;
import java.util.List;
import java.util.Random;
public class TransferPrivsTests extends Common {
@@ -42,6 +45,27 @@ public class TransferPrivsTests extends Common {
Common.orphanCheck();
}
@Test
public void testAliceIntoNewAccountTransferPrivs() throws DataException {
try (final Repository repository = RepositoryManager.getRepository()) {
TestAccount alice = Common.getTestAccount(repository, "alice");
assertTrue(alice.canMint());
PrivateKeyAccount aliceMintingAccount = Common.getTestAccount(repository, "alice-reward-share");
byte[] randomPublicKey = new byte[Transformer.PUBLIC_KEY_LENGTH];
Random random = new Random();
random.nextBytes(randomPublicKey);
Account randomAccount = new PublicKeyAccount(repository, randomPublicKey);
combineAccounts(repository, alice, randomAccount, aliceMintingAccount);
assertFalse(alice.canMint());
assertTrue(randomAccount.canMint());
}
}
@Test
public void testAliceIntoDilbertTransferPrivs() throws DataException {
try (final Repository repository = RepositoryManager.getRepository()) {