From f1a0472c577757e885a41af78a7e3ee91e7a7f8a Mon Sep 17 00:00:00 2001 From: Ice Date: Thu, 24 Apr 2025 03:27:28 -0400 Subject: [PATCH] Corrections for Unit Tests - Lots of Corrections --- pom.xml | 5 +- .../qortal/arbitrary/ArbitraryDataDigest.java | 14 ++++- .../java/org/qortal/crosschain/ElectrumX.java | 6 +- .../test/SelfSponsorshipAlgoV1Tests.java | 11 ++-- .../test/SelfSponsorshipAlgoV3Tests.java | 3 +- .../qortal/test/api/AddressesApiTests.java | 12 +++- .../arbitrary/ArbitraryDataDigestTests.java | 14 ++++- .../arbitrary/ArbitraryDataMergeTests.java | 20 +++--- .../ArbitraryTransactionMetadataTests.java | 5 +- .../arbitrary/ArbitraryTransactionTests.java | 2 +- .../org/qortal/test/common/GroupUtils.java | 61 ++++++++++++++++--- .../org/qortal/test/group/AdminTests.java | 3 +- .../org/qortal/test/group/OwnerTests.java | 20 +----- .../test-chain-v2-block-timestamps.json | 10 ++- .../test-chain-v2-disable-reference.json | 10 ++- .../test-chain-v2-founder-rewards.json | 3 + .../test-chain-v2-leftover-reward.json | 10 ++- src/test/resources/test-chain-v2-minting.json | 10 ++- .../resources/test-chain-v2-penalty-fix.json | 10 ++- .../test-chain-v2-qora-holder-extremes.json | 10 ++- .../test-chain-v2-qora-holder-reduction.json | 10 ++- .../resources/test-chain-v2-qora-holder.json | 10 ++- .../test-chain-v2-reward-levels.json | 3 + .../test-chain-v2-reward-scaling.json | 10 ++- .../test-chain-v2-reward-shares.json | 10 ++- ...est-chain-v2-self-sponsorship-algo-v1.json | 15 ++++- ...est-chain-v2-self-sponsorship-algo-v2.json | 10 ++- ...est-chain-v2-self-sponsorship-algo-v3.json | 10 ++- src/test/resources/test-settings-v2.json | 3 +- 29 files changed, 252 insertions(+), 68 deletions(-) diff --git a/pom.xml b/pom.xml index 13ad4807..a1a8f758 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,6 @@ UTF-8 true - 7dc8c6f 7dc8c6f 0.15.10 1.70 @@ -747,12 +746,12 @@ org.bouncycastle - bcprov-jdk15on + bcprov-jdk15to18 ${bouncycastle.version} org.bouncycastle - bctls-jdk15on + bctls-jdk15to18 ${bouncycastle.version} diff --git a/src/main/java/org/qortal/arbitrary/ArbitraryDataDigest.java b/src/main/java/org/qortal/arbitrary/ArbitraryDataDigest.java index 9703b231..b07fd396 100644 --- a/src/main/java/org/qortal/arbitrary/ArbitraryDataDigest.java +++ b/src/main/java/org/qortal/arbitrary/ArbitraryDataDigest.java @@ -5,8 +5,10 @@ import org.qortal.utils.Base58; import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.nio.file.FileSystem; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; @@ -44,12 +46,22 @@ public class ArbitraryDataDigest { continue; } + // Account for \ VS / : Linux VS Windows + String pathString = relativePath.toString(); + + if(relativePath.getFileSystem().toString().contains("Windows")) { + pathString = pathString.replace("\\","/"); + } + // Hash path - byte[] filePathBytes = relativePath.toString().getBytes(StandardCharsets.UTF_8); + byte[] filePathBytes = pathString.getBytes(StandardCharsets.UTF_8); + System.out.printf("Path: %s \n", pathString); + System.out.printf("Path Byte Array: %s \n", Arrays.toString(filePathBytes)); sha256.update(filePathBytes); // Hash contents byte[] fileContent = Files.readAllBytes(path); + System.out.printf("File Content: %s \n", Arrays.toString(fileContent)); sha256.update(fileContent); } this.hash = sha256.digest(); diff --git a/src/main/java/org/qortal/crosschain/ElectrumX.java b/src/main/java/org/qortal/crosschain/ElectrumX.java index 6c917659..82c7b89d 100644 --- a/src/main/java/org/qortal/crosschain/ElectrumX.java +++ b/src/main/java/org/qortal/crosschain/ElectrumX.java @@ -644,8 +644,10 @@ public class ElectrumX extends BitcoinyBlockchainProvider { } /** - * Performs RPC call, with automatic reconnection to different server if needed. - *

+ *

Performs RPC call, with automatic reconnection to different server if needed. + *

+ * @param method String representation of the RPC call value + * @param params a list of Objects passed to the method of the Remote Server * @return "result" object from within JSON output * @throws ForeignBlockchainException if server returns error or something goes wrong */ diff --git a/src/test/java/org/qortal/test/SelfSponsorshipAlgoV1Tests.java b/src/test/java/org/qortal/test/SelfSponsorshipAlgoV1Tests.java index fe0556ca..5c6fb091 100644 --- a/src/test/java/org/qortal/test/SelfSponsorshipAlgoV1Tests.java +++ b/src/test/java/org/qortal/test/SelfSponsorshipAlgoV1Tests.java @@ -15,10 +15,7 @@ import org.qortal.repository.DataException; import org.qortal.repository.Repository; import org.qortal.repository.RepositoryManager; import org.qortal.settings.Settings; -import org.qortal.test.common.AccountUtils; -import org.qortal.test.common.BlockUtils; -import org.qortal.test.common.Common; -import org.qortal.test.common.TransactionUtils; +import org.qortal.test.common.*; import org.qortal.test.common.transaction.TestTransaction; import org.qortal.transaction.Transaction; import org.qortal.transaction.TransferPrivsTransaction; @@ -28,6 +25,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; +import static org.hamcrest.core.IsNot.not; import static org.junit.Assert.*; import static org.qortal.test.common.AccountUtils.fee; import static org.qortal.transaction.Transaction.ValidationResult.ACCOUNT_NOT_TRANSFERABLE; @@ -836,7 +834,10 @@ public class SelfSponsorshipAlgoV1Tests extends Common { assertEquals(0, (int) new Account(repository, aliceAccount.getAddress()).getLevel()); // Alice can no longer create a reward share transaction - assertEquals(Transaction.ValidationResult.ACCOUNT_CANNOT_REWARD_SHARE, AccountUtils.createRandomRewardShare(repository, aliceAccount)); + // Used to Chehck for ACCOUNT_CANNOT_REWARD_SHARE / Updated post canMint() function changes + // canMint returns False because reward penality != 0 (account.java:240) + // Causes trip in RewardShareTransaction.java:126, Returns NOT_MINTING_ACCOUNT + assertThat(Transaction.ValidationResult.OK, not(AccountUtils.createRandomRewardShare(repository, aliceAccount))); // ... but Bob still can assertEquals(Transaction.ValidationResult.OK, AccountUtils.createRandomRewardShare(repository, bobAccount)); diff --git a/src/test/java/org/qortal/test/SelfSponsorshipAlgoV3Tests.java b/src/test/java/org/qortal/test/SelfSponsorshipAlgoV3Tests.java index bb9de4e3..c5043190 100644 --- a/src/test/java/org/qortal/test/SelfSponsorshipAlgoV3Tests.java +++ b/src/test/java/org/qortal/test/SelfSponsorshipAlgoV3Tests.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; +import static org.hamcrest.core.IsNot.not; import static org.junit.Assert.*; import static org.qortal.test.common.AccountUtils.fee; import static org.qortal.transaction.Transaction.ValidationResult.ACCOUNT_NOT_TRANSFERABLE; @@ -840,7 +841,7 @@ public class SelfSponsorshipAlgoV3Tests extends Common { assertEquals(0, (int) new Account(repository, aliceAccount.getAddress()).getLevel()); // Alice can no longer create a reward share transaction - assertEquals(Transaction.ValidationResult.ACCOUNT_CANNOT_REWARD_SHARE, AccountUtils.createRandomRewardShare(repository, aliceAccount)); + assertThat(Transaction.ValidationResult.OK, not(AccountUtils.createRandomRewardShare(repository, aliceAccount))); // Bob can no longer create a reward share transaction (disabled at Block 15) assertEquals(Transaction.ValidationResult.OK, AccountUtils.createRandomRewardShare(repository, bobAccount)); diff --git a/src/test/java/org/qortal/test/api/AddressesApiTests.java b/src/test/java/org/qortal/test/api/AddressesApiTests.java index 319a9a52..48d18b43 100644 --- a/src/test/java/org/qortal/test/api/AddressesApiTests.java +++ b/src/test/java/org/qortal/test/api/AddressesApiTests.java @@ -25,9 +25,19 @@ public class AddressesApiTests extends ApiCommon { } @Test - @Ignore(value = "Doesn't work, to be fixed later") + @Ignore(value = "No Logic Coded") public void testGetOnlineAccounts() { + // Add and remove users as online checking count after minting + // TODO: Need to construct logic + // this.addressesResource.getOnlineAccounts(), empty Array, Size = 0 assertNotNull(this.addressesResource.getOnlineAccounts()); + int blocksToMint = 5; + // Add 2 accounts to the online array, mint some blocks + // Assert number of accountsOnline == 2 + // Remove an account from onlineStatus, mint some blocks + // Assert number of accountsOnline == 1 + // Add two accounts as online, mint some blocks + // Asset number of accountsOnline == 3 } @Test diff --git a/src/test/java/org/qortal/test/arbitrary/ArbitraryDataDigestTests.java b/src/test/java/org/qortal/test/arbitrary/ArbitraryDataDigestTests.java index fdc1f541..4409bd41 100644 --- a/src/test/java/org/qortal/test/arbitrary/ArbitraryDataDigestTests.java +++ b/src/test/java/org/qortal/test/arbitrary/ArbitraryDataDigestTests.java @@ -6,11 +6,13 @@ import org.qortal.arbitrary.ArbitraryDataDigest; import org.qortal.repository.DataException; import org.qortal.test.common.Common; +import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Arrays; import java.util.UUID; import static org.junit.Assert.assertEquals; @@ -25,7 +27,10 @@ public class ArbitraryDataDigestTests extends Common { @Test public void testDirectoryDigest() throws IOException, DataException { - Path dataPath = Paths.get("src/test/resources/arbitrary/demo1"); + String dataPathString = "src" + File.separator + "test" + File.separator + "resources" + File.separator + "arbitrary" + File.separator + "demo1"; + Path dataPath = Paths.get(dataPathString); + + // expectedHash is calculated for Linux String expectedHash58 = "DKyMuonWKoneJqiVHgw26Vk1ytrZG9PGsE9xfBg3GKDp"; // Ensure directory exists @@ -35,6 +40,13 @@ public class ArbitraryDataDigestTests extends Common { // Compute a hash ArbitraryDataDigest digest = new ArbitraryDataDigest(dataPath); digest.compute(); + // Assert Fails, Expected: DKyMuonWKoneJqiVHgw26Vk1ytrZG9PGsE9xfBg3GKDp + // Actual : HbvgC6sfhFtDvmDXfPXVUcCUyZ5rM1NzX488qHmMpMB4 + // This might be failing because Windows turns "/" (47) to "\" (92) + // Or maybe a fail due to \n [13] VS \r\n [13,10] in .txt files + // Confirmed the read in windows has \r\n + // Could be a combination of both + System.out.printf("Hash: %s \n", Arrays.toString(digest.getHash())); assertEquals(expectedHash58, digest.getHash58()); // Write a random file to .qortal/cache to ensure it isn't being included in the digest function diff --git a/src/test/java/org/qortal/test/arbitrary/ArbitraryDataMergeTests.java b/src/test/java/org/qortal/test/arbitrary/ArbitraryDataMergeTests.java index a366ef12..ecd07c77 100644 --- a/src/test/java/org/qortal/test/arbitrary/ArbitraryDataMergeTests.java +++ b/src/test/java/org/qortal/test/arbitrary/ArbitraryDataMergeTests.java @@ -15,9 +15,7 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.nio.ByteBuffer; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; +import java.nio.file.*; import java.util.Arrays; import java.util.Objects; import java.util.Random; @@ -242,7 +240,7 @@ public class ArbitraryDataMergeTests extends Common { BufferedWriter file1Writer = new BufferedWriter(new FileWriter(file1)); String initialString = ArbitraryUtils.generateRandomString(1024); // Add a newline every 50 chars - initialString = initialString.replaceAll("(.{50})", "$1\n"); + initialString = initialString.replaceAll("(.{50})", "$1" + System.lineSeparator()); file1Writer.write(initialString); file1Writer.newLine(); file1Writer.close(); @@ -307,23 +305,23 @@ public class ArbitraryDataMergeTests extends Common { file1.deleteOnExit(); file2.deleteOnExit(); - // Write a random string to the first file + // Write a random string to the first file, 1024 characters, \n every 50 chars BufferedWriter file1Writer = new BufferedWriter(new FileWriter(file1)); String initialString = ArbitraryUtils.generateRandomString(1024); // Add a newline every 50 chars - initialString = initialString.replaceAll("(.{50})", "$1\n"); + initialString = initialString.replaceAll("(.{50})", "$1" + System.lineSeparator()); // Remove newline at end of string - initialString = initialString.stripTrailing(); + initialString = initialString.stripTrailing(); // Remove Trailing White Space file1Writer.write(initialString); // No newline file1Writer.close(); byte[] file1Digest = Crypto.digest(file1); - // Write a slightly modified string to the second file + // Write a slightly modified string to the second file, append "-edit" to the string BufferedWriter file2Writer = new BufferedWriter(new FileWriter(file2)); String updatedString = initialString.concat("-edit"); file2Writer.write(updatedString); - // No newline + // No newline - This is wrong, both files contain \n every 50 chars file2Writer.close(); byte[] file2Digest = Crypto.digest(file2); @@ -342,6 +340,7 @@ public class ArbitraryDataMergeTests extends Common { ArbitraryDataCreatePatch patch = new ArbitraryDataCreatePatch(tempDir1, tempDir2, signature); patch.create(); Path patchPath = patch.getFinalPath(); + assertTrue(Files.exists(patchPath)); // Check that the patch file exists @@ -353,6 +352,7 @@ public class ArbitraryDataMergeTests extends Common { assertFalse(Arrays.equals(patchDigest, file1Digest)); // Make sure that the patch file is different from file2 + // This assert fails, patchFile and file2 have the same contents so the digest will match assertFalse(Arrays.equals(patchDigest, file2Digest)); // Now merge the patch with the original path @@ -384,7 +384,7 @@ public class ArbitraryDataMergeTests extends Common { BufferedWriter file1Writer = new BufferedWriter(new FileWriter(file1)); String initialString = ArbitraryUtils.generateRandomString(110 * 1024); // Add a newline every 50 chars - initialString = initialString.replaceAll("(.{50})", "$1\n"); + initialString = initialString.replaceAll("(.{50})", "$1" + System.lineSeparator()); file1Writer.write(initialString); file1Writer.newLine(); file1Writer.close(); diff --git a/src/test/java/org/qortal/test/arbitrary/ArbitraryTransactionMetadataTests.java b/src/test/java/org/qortal/test/arbitrary/ArbitraryTransactionMetadataTests.java index cd3893af..4d5b195c 100644 --- a/src/test/java/org/qortal/test/arbitrary/ArbitraryTransactionMetadataTests.java +++ b/src/test/java/org/qortal/test/arbitrary/ArbitraryTransactionMetadataTests.java @@ -27,6 +27,7 @@ import org.qortal.transaction.RegisterNameTransaction; import org.qortal.utils.Base58; import org.qortal.utils.NTP; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -410,13 +411,13 @@ public class ArbitraryTransactionMetadataTests extends Common { assertEquals(3, arbitraryDataFile.getMetadata().getFiles().size()); assertTrue(arbitraryDataFile.getMetadata().getFiles().contains("file.txt")); assertTrue(arbitraryDataFile.getMetadata().getFiles().contains("image1.jpg")); - assertTrue(arbitraryDataFile.getMetadata().getFiles().contains("subdirectory/config.json")); + assertTrue(arbitraryDataFile.getMetadata().getFiles().contains("subdirectory" + File.separator + "config.json")); // Ensure the file list can be read back out again, when specified to be included ArbitraryResourceMetadata resourceMetadata = ArbitraryResourceMetadata.fromTransactionMetadata(arbitraryDataFile.getMetadata(), true); assertTrue(resourceMetadata.getFiles().contains("file.txt")); assertTrue(resourceMetadata.getFiles().contains("image1.jpg")); - assertTrue(resourceMetadata.getFiles().contains("subdirectory/config.json")); + assertTrue(resourceMetadata.getFiles().contains("subdirectory" + File.separator + "config.json")); // Ensure it's not returned when specified to be excluded // The entire object will be null because there is no metadata diff --git a/src/test/java/org/qortal/test/arbitrary/ArbitraryTransactionTests.java b/src/test/java/org/qortal/test/arbitrary/ArbitraryTransactionTests.java index 089f0475..1c515199 100644 --- a/src/test/java/org/qortal/test/arbitrary/ArbitraryTransactionTests.java +++ b/src/test/java/org/qortal/test/arbitrary/ArbitraryTransactionTests.java @@ -440,7 +440,7 @@ public class ArbitraryTransactionTests extends Common { PrivateKeyAccount alice = Common.getTestAccount(repository, "alice"); String publicKey58 = Base58.encode(alice.getPublicKey()); - String name = "TEST"; // Can be anything for this test + String name = "TEST-testOnChainData"; // Can be anything for this test String identifier = null; // Not used for this test Service service = Service.ARBITRARY_DATA; int chunkSize = 1000; diff --git a/src/test/java/org/qortal/test/common/GroupUtils.java b/src/test/java/org/qortal/test/common/GroupUtils.java index cda7ad8e..9ce140e7 100644 --- a/src/test/java/org/qortal/test/common/GroupUtils.java +++ b/src/test/java/org/qortal/test/common/GroupUtils.java @@ -6,6 +6,7 @@ import org.qortal.group.Group; import org.qortal.group.Group.ApprovalThreshold; import org.qortal.repository.DataException; import org.qortal.repository.Repository; +import org.qortal.test.common.transaction.TestTransaction; import org.qortal.transaction.Transaction.ApprovalStatus; import org.qortal.utils.Amounts; @@ -14,9 +15,18 @@ public class GroupUtils { public static final int txGroupId = Group.NO_GROUP; public static final long fee = 1L * Amounts.MULTIPLIER; - public static int createGroup(Repository repository, String creatorAccountName, String groupName, boolean isOpen, ApprovalThreshold approvalThreshold, + public static int createGroup(Repository repository, Object creatorAccountName, String groupName, boolean isOpen, ApprovalThreshold approvalThreshold, int minimumBlockDelay, int maximumBlockDelay) throws DataException { - PrivateKeyAccount account = Common.getTestAccount(repository, creatorAccountName); + + PrivateKeyAccount account; + if (creatorAccountName instanceof java.lang.String) { + account = Common.getTestAccount(repository, (String) creatorAccountName); + } + else if (creatorAccountName instanceof PrivateKeyAccount) { + account = (PrivateKeyAccount) creatorAccountName; + } else { + account = null; + } byte[] reference = account.getLastReference(); long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1; @@ -30,16 +40,49 @@ public class GroupUtils { return repository.getGroupRepository().fromGroupName(groupName).getGroupId(); } + /** + *

Simplified GroupCreation for Testing - less parameters required + *

+ * @param repository The blockchain database + * @param owner Who will own the group, type PrivateKeyAccount + * @param groupName String representing the published name + * @param isOpen Boolean to allow anyone to join + * @return groupID as an integer + * @throws DataException when error occurs + * @since v4.71 + */ + public static int createGroup(Repository repository, PrivateKeyAccount owner, String groupName, boolean isOpen) throws DataException { + String description = groupName + " (description)"; + + Group.ApprovalThreshold approvalThreshold = Group.ApprovalThreshold.ONE; + int minimumBlockDelay = 10; + int maximumBlockDelay = 1440; + + return createGroup(repository, owner, groupName, isOpen, approvalThreshold, minimumBlockDelay, maximumBlockDelay); + } // End Simplified Group Creation + + /** + * + * @param repository The block chain database + * @param joinerAccount Account of the person joining the group + * @param groupId Integer of the Group mapping + * @throws DataException + * @since v4.7.1 + */ + public static void joinGroup(Repository repository, PrivateKeyAccount joinerAccount, int groupId) throws DataException { + byte[] reference = joinerAccount.getLastReference(); + long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1; + + BaseTransactionData baseTransactionData = new BaseTransactionData(timestamp, Group.NO_GROUP, reference, joinerAccount.getPublicKey(), GroupUtils.fee, null); + TransactionData transactionData = new JoinGroupTransactionData(baseTransactionData, groupId); + + TransactionUtils.signAndMint(repository, transactionData, joinerAccount); + } + public static void joinGroup(Repository repository, String joinerAccountName, int groupId) throws DataException { PrivateKeyAccount account = Common.getTestAccount(repository, joinerAccountName); - byte[] reference = account.getLastReference(); - long timestamp = repository.getTransactionRepository().fromSignature(reference).getTimestamp() + 1; - - BaseTransactionData baseTransactionData = new BaseTransactionData(timestamp, Group.NO_GROUP, reference, account.getPublicKey(), GroupUtils.fee, null); - TransactionData transactionData = new JoinGroupTransactionData(baseTransactionData, groupId); - - TransactionUtils.signAndMint(repository, transactionData, account); + joinGroup(repository, account, groupId); } public static void approveTransaction(Repository repository, String accountName, byte[] pendingSignature, boolean decision) throws DataException { diff --git a/src/test/java/org/qortal/test/group/AdminTests.java b/src/test/java/org/qortal/test/group/AdminTests.java index db3e3400..9a27b008 100644 --- a/src/test/java/org/qortal/test/group/AdminTests.java +++ b/src/test/java/org/qortal/test/group/AdminTests.java @@ -11,6 +11,7 @@ import org.qortal.repository.Repository; import org.qortal.repository.RepositoryManager; import org.qortal.test.common.BlockUtils; import org.qortal.test.common.Common; +import org.qortal.test.common.GroupUtils; import org.qortal.test.common.TransactionUtils; import org.qortal.test.common.transaction.TestTransaction; import org.qortal.transaction.Transaction.ValidationResult; @@ -78,7 +79,7 @@ public class AdminTests extends Common { int groupId = createGroup(repository, alice, "open-group", true); // Bob to join - joinGroup(repository, bob, groupId); + GroupUtils.joinGroup(repository, bob, groupId); // Promote Bob to admin addGroupAdmin(repository, alice, groupId, bob.getAddress()); diff --git a/src/test/java/org/qortal/test/group/OwnerTests.java b/src/test/java/org/qortal/test/group/OwnerTests.java index 7b5af651..a6f8b95a 100644 --- a/src/test/java/org/qortal/test/group/OwnerTests.java +++ b/src/test/java/org/qortal/test/group/OwnerTests.java @@ -5,15 +5,14 @@ import org.junit.Before; import org.junit.Test; import org.qortal.account.PrivateKeyAccount; import org.qortal.data.transaction.AddGroupAdminTransactionData; -import org.qortal.data.transaction.CreateGroupTransactionData; import org.qortal.data.transaction.JoinGroupTransactionData; import org.qortal.data.transaction.RemoveGroupAdminTransactionData; -import org.qortal.group.Group.ApprovalThreshold; import org.qortal.repository.DataException; import org.qortal.repository.Repository; import org.qortal.repository.RepositoryManager; import org.qortal.test.common.BlockUtils; import org.qortal.test.common.Common; +import org.qortal.test.common.GroupUtils; import org.qortal.test.common.TransactionUtils; import org.qortal.test.common.transaction.TestTransaction; import org.qortal.transaction.Transaction.ValidationResult; @@ -39,7 +38,7 @@ public class OwnerTests extends Common { PrivateKeyAccount bob = Common.getTestAccount(repository, "bob"); // Create group - int groupId = createGroup(repository, alice, "open-group", true); + int groupId = GroupUtils.createGroup(repository, alice, "open-group", true); // Attempt to promote non-member ValidationResult result = addGroupAdmin(repository, alice, groupId, bob.getAddress()); @@ -83,7 +82,7 @@ public class OwnerTests extends Common { PrivateKeyAccount bob = Common.getTestAccount(repository, "bob"); // Create group - int groupId = createGroup(repository, alice, "open-group", true); + int groupId = GroupUtils.createGroup(repository, alice, "open-group", true); // Attempt to demote non-member ValidationResult result = removeGroupAdmin(repository, alice, groupId, bob.getAddress()); @@ -133,19 +132,6 @@ public class OwnerTests extends Common { } } - private Integer createGroup(Repository repository, PrivateKeyAccount owner, String groupName, boolean isOpen) throws DataException { - String description = groupName + " (description)"; - - ApprovalThreshold approvalThreshold = ApprovalThreshold.ONE; - int minimumBlockDelay = 10; - int maximumBlockDelay = 1440; - - CreateGroupTransactionData transactionData = new CreateGroupTransactionData(TestTransaction.generateBase(owner), groupName, description, isOpen, approvalThreshold, minimumBlockDelay, maximumBlockDelay); - TransactionUtils.signAndMint(repository, transactionData, owner); - - return repository.getGroupRepository().fromGroupName(groupName).getGroupId(); - } - private ValidationResult joinGroup(Repository repository, PrivateKeyAccount joiner, int groupId) throws DataException { JoinGroupTransactionData transactionData = new JoinGroupTransactionData(TestTransaction.generateBase(joiner), groupId); ValidationResult result = TransactionUtils.signAndImport(repository, transactionData, joiner); diff --git a/src/test/resources/test-chain-v2-block-timestamps.json b/src/test/resources/test-chain-v2-block-timestamps.json index 4e49e86d..0f35a990 100644 --- a/src/test/resources/test-chain-v2-block-timestamps.json +++ b/src/test/resources/test-chain-v2-block-timestamps.json @@ -25,6 +25,9 @@ "blockRewardBatchStartHeight": 999999000, "blockRewardBatchSize": 10, "blockRewardBatchAccountsBlockCount": 3, + "mintingGroupIds": [ + { "height": 0, "ids": [ 1 ]} + ], "rewardsByHeight": [ { "height": 1, "reward": 100 }, { "height": 11, "reward": 10 }, @@ -98,7 +101,12 @@ "onlyMintWithNameHeight": 9999999999990, "groupMemberCheckHeight": 9999999999999, "decreaseOnlineAccountsDifficultyTimestamp": 9999999999999, - "removeOnlyMintWithNameHeight": 9999999999999 + "removeOnlyMintWithNameHeight": 9999999999999, + "fixBatchRewardHeight": 9999999999999, + "adminsReplaceFoundersHeight": 9999999999999, + "ignoreLevelForRewardShareHeight": 9999999999999, + "nullGroupMembershipHeight": 20, + "adminQueryFixHeight": 9999999999999 }, "genesisInfo": { "version": 4, diff --git a/src/test/resources/test-chain-v2-disable-reference.json b/src/test/resources/test-chain-v2-disable-reference.json index 9ad59d79..345a60bf 100644 --- a/src/test/resources/test-chain-v2-disable-reference.json +++ b/src/test/resources/test-chain-v2-disable-reference.json @@ -29,6 +29,9 @@ "blockRewardBatchStartHeight": 999999000, "blockRewardBatchSize": 10, "blockRewardBatchAccountsBlockCount": 3, + "mintingGroupIds": [ + { "height": 0, "ids": [ 1 ]} + ], "rewardsByHeight": [ { "height": 1, "reward": 100 }, { "height": 11, "reward": 10 }, @@ -101,7 +104,12 @@ "onlyMintWithNameHeight": 9999999999990, "groupMemberCheckHeight": 9999999999999, "decreaseOnlineAccountsDifficultyTimestamp": 9999999999999, - "removeOnlyMintWithNameHeight": 9999999999999 + "removeOnlyMintWithNameHeight": 9999999999999, + "fixBatchRewardHeight": 9999999999999, + "adminsReplaceFoundersHeight": 9999999999999, + "ignoreLevelForRewardShareHeight": 9999999999999, + "nullGroupMembershipHeight": 20, + "adminQueryFixHeight": 9999999999999 }, "genesisInfo": { "version": 4, diff --git a/src/test/resources/test-chain-v2-founder-rewards.json b/src/test/resources/test-chain-v2-founder-rewards.json index 123c7e61..7bedc999 100644 --- a/src/test/resources/test-chain-v2-founder-rewards.json +++ b/src/test/resources/test-chain-v2-founder-rewards.json @@ -30,6 +30,9 @@ "blockRewardBatchStartHeight": 999999000, "blockRewardBatchSize": 10, "blockRewardBatchAccountsBlockCount": 3, + "mintingGroupIds": [ + { "height": 0, "ids": [ 1 ]} + ], "rewardsByHeight": [ { "height": 1, "reward": 100 }, { "height": 11, "reward": 10 }, diff --git a/src/test/resources/test-chain-v2-leftover-reward.json b/src/test/resources/test-chain-v2-leftover-reward.json index 04005b2b..1fa116eb 100644 --- a/src/test/resources/test-chain-v2-leftover-reward.json +++ b/src/test/resources/test-chain-v2-leftover-reward.json @@ -30,6 +30,9 @@ "blockRewardBatchStartHeight": 999999000, "blockRewardBatchSize": 10, "blockRewardBatchAccountsBlockCount": 3, + "mintingGroupIds": [ + { "height": 0, "ids": [ 1 ]} + ], "rewardsByHeight": [ { "height": 1, "reward": 100 }, { "height": 11, "reward": 10 }, @@ -102,7 +105,12 @@ "onlyMintWithNameHeight": 9999999999990, "groupMemberCheckHeight": 9999999999999, "decreaseOnlineAccountsDifficultyTimestamp": 9999999999999, - "removeOnlyMintWithNameHeight": 9999999999999 + "removeOnlyMintWithNameHeight": 9999999999999, + "fixBatchRewardHeight": 9999999999999, + "adminsReplaceFoundersHeight": 9999999999999, + "ignoreLevelForRewardShareHeight": 9999999999999, + "nullGroupMembershipHeight": 20, + "adminQueryFixHeight": 9999999999999 }, "genesisInfo": { "version": 4, diff --git a/src/test/resources/test-chain-v2-minting.json b/src/test/resources/test-chain-v2-minting.json index ddb29ca5..0f5d42bf 100644 --- a/src/test/resources/test-chain-v2-minting.json +++ b/src/test/resources/test-chain-v2-minting.json @@ -30,6 +30,9 @@ "blockRewardBatchStartHeight": 999999000, "blockRewardBatchSize": 10, "blockRewardBatchAccountsBlockCount": 3, + "mintingGroupIds": [ + { "height": 0, "ids": [ 1 ]} + ], "rewardsByHeight": [ { "height": 1, "reward": 100 }, { "height": 11, "reward": 10 }, @@ -102,7 +105,12 @@ "onlyMintWithNameHeight": 9999999999990, "groupMemberCheckHeight": 9999999999999, "decreaseOnlineAccountsDifficultyTimestamp": 9999999999999, - "removeOnlyMintWithNameHeight": 9999999999999 + "removeOnlyMintWithNameHeight": 9999999999999, + "fixBatchRewardHeight": 9999999999999, + "adminsReplaceFoundersHeight": 9999999999999, + "ignoreLevelForRewardShareHeight": 9999999999999, + "nullGroupMembershipHeight": 20, + "adminQueryFixHeight": 9999999999999 }, "genesisInfo": { "version": 4, diff --git a/src/test/resources/test-chain-v2-penalty-fix.json b/src/test/resources/test-chain-v2-penalty-fix.json index cac92c16..0c08f87f 100644 --- a/src/test/resources/test-chain-v2-penalty-fix.json +++ b/src/test/resources/test-chain-v2-penalty-fix.json @@ -28,6 +28,9 @@ "blockRewardBatchStartHeight": 999999000, "blockRewardBatchSize": 10, "blockRewardBatchAccountsBlockCount": 3, + "mintingGroupIds": [ + { "height": 0, "ids": [ 1 ]} + ], "rewardsByHeight": [ { "height": 1, "reward": 100 }, { "height": 11, "reward": 10 }, @@ -101,7 +104,12 @@ "groupMemberCheckHeight": 9999999999999, "decreaseOnlineAccountsDifficultyTimestamp": 9999999999999, "removeOnlyMintWithNameHeight": 9999999999999, - "penaltyFixHeight": 5 + "penaltyFixHeight": 5, + "fixBatchRewardHeight": 9999999999999, + "adminsReplaceFoundersHeight": 9999999999999, + "ignoreLevelForRewardShareHeight": 9999999999999, + "nullGroupMembershipHeight": 20, + "adminQueryFixHeight": 9999999999999 }, "genesisInfo": { "version": 4, diff --git a/src/test/resources/test-chain-v2-qora-holder-extremes.json b/src/test/resources/test-chain-v2-qora-holder-extremes.json index 566d8515..7aceb906 100644 --- a/src/test/resources/test-chain-v2-qora-holder-extremes.json +++ b/src/test/resources/test-chain-v2-qora-holder-extremes.json @@ -30,6 +30,9 @@ "blockRewardBatchStartHeight": 999999000, "blockRewardBatchSize": 10, "blockRewardBatchAccountsBlockCount": 3, + "mintingGroupIds": [ + { "height": 0, "ids": [ 1 ]} + ], "rewardsByHeight": [ { "height": 1, "reward": 100 }, { "height": 11, "reward": 10 }, @@ -102,7 +105,12 @@ "onlyMintWithNameHeight": 9999999999990, "groupMemberCheckHeight": 9999999999999, "decreaseOnlineAccountsDifficultyTimestamp": 9999999999999, - "removeOnlyMintWithNameHeight": 9999999999999 + "removeOnlyMintWithNameHeight": 9999999999999, + "fixBatchRewardHeight": 9999999999999, + "adminsReplaceFoundersHeight": 9999999999999, + "ignoreLevelForRewardShareHeight": 9999999999999, + "nullGroupMembershipHeight": 20, + "adminQueryFixHeight": 9999999999999 }, "genesisInfo": { "version": 4, diff --git a/src/test/resources/test-chain-v2-qora-holder-reduction.json b/src/test/resources/test-chain-v2-qora-holder-reduction.json index c7ed2270..d8a9c541 100644 --- a/src/test/resources/test-chain-v2-qora-holder-reduction.json +++ b/src/test/resources/test-chain-v2-qora-holder-reduction.json @@ -30,6 +30,9 @@ "blockRewardBatchStartHeight": 999999000, "blockRewardBatchSize": 10, "blockRewardBatchAccountsBlockCount": 3, + "mintingGroupIds": [ + { "height": 0, "ids": [ 1 ]} + ], "rewardsByHeight": [ { "height": 1, "reward": 100 }, { "height": 11, "reward": 10 }, @@ -103,7 +106,12 @@ "onlyMintWithNameHeight": 9999999999990, "groupMemberCheckHeight": 9999999999999, "decreaseOnlineAccountsDifficultyTimestamp": 9999999999999, - "removeOnlyMintWithNameHeight": 9999999999999 + "removeOnlyMintWithNameHeight": 9999999999999, + "fixBatchRewardHeight": 9999999999999, + "adminsReplaceFoundersHeight": 9999999999999, + "ignoreLevelForRewardShareHeight": 9999999999999, + "nullGroupMembershipHeight": 20, + "adminQueryFixHeight": 9999999999999 }, "genesisInfo": { "version": 4, diff --git a/src/test/resources/test-chain-v2-qora-holder.json b/src/test/resources/test-chain-v2-qora-holder.json index 1c4f0d93..ee67b6f0 100644 --- a/src/test/resources/test-chain-v2-qora-holder.json +++ b/src/test/resources/test-chain-v2-qora-holder.json @@ -30,6 +30,9 @@ "blockRewardBatchStartHeight": 999999000, "blockRewardBatchSize": 10, "blockRewardBatchAccountsBlockCount": 3, + "mintingGroupIds": [ + { "height": 0, "ids": [ 1 ]} + ], "rewardsByHeight": [ { "height": 1, "reward": 100 }, { "height": 11, "reward": 10 }, @@ -102,7 +105,12 @@ "onlyMintWithNameHeight": 9999999999990, "groupMemberCheckHeight": 9999999999999, "decreaseOnlineAccountsDifficultyTimestamp": 9999999999999, - "removeOnlyMintWithNameHeight": 9999999999999 + "removeOnlyMintWithNameHeight": 9999999999999, + "fixBatchRewardHeight": 9999999999999, + "adminsReplaceFoundersHeight": 9999999999999, + "ignoreLevelForRewardShareHeight": 9999999999999, + "nullGroupMembershipHeight": 20, + "adminQueryFixHeight": 9999999999999 }, "genesisInfo": { "version": 4, diff --git a/src/test/resources/test-chain-v2-reward-levels.json b/src/test/resources/test-chain-v2-reward-levels.json index 2f51f74d..e0c734fa 100644 --- a/src/test/resources/test-chain-v2-reward-levels.json +++ b/src/test/resources/test-chain-v2-reward-levels.json @@ -30,6 +30,9 @@ "blockRewardBatchStartHeight": 999999000, "blockRewardBatchSize": 10, "blockRewardBatchAccountsBlockCount": 3, + "mintingGroupIds": [ + { "height": 0, "ids": [ 1 ]} + ], "rewardsByHeight": [ { "height": 1, "reward": 100 }, { "height": 11, "reward": 10 }, diff --git a/src/test/resources/test-chain-v2-reward-scaling.json b/src/test/resources/test-chain-v2-reward-scaling.json index 612f02a5..258b3ff2 100644 --- a/src/test/resources/test-chain-v2-reward-scaling.json +++ b/src/test/resources/test-chain-v2-reward-scaling.json @@ -30,6 +30,9 @@ "blockRewardBatchStartHeight": 999999000, "blockRewardBatchSize": 10, "blockRewardBatchAccountsBlockCount": 3, + "mintingGroupIds": [ + { "height": 0, "ids": [ 1 ]} + ], "rewardsByHeight": [ { "height": 1, "reward": 100 }, { "height": 11, "reward": 10 }, @@ -102,7 +105,12 @@ "onlyMintWithNameHeight": 9999999999990, "groupMemberCheckHeight": 9999999999999, "decreaseOnlineAccountsDifficultyTimestamp": 9999999999999, - "removeOnlyMintWithNameHeight": 9999999999999 + "removeOnlyMintWithNameHeight": 9999999999999, + "fixBatchRewardHeight": 9999999999999, + "adminsReplaceFoundersHeight": 9999999999999, + "ignoreLevelForRewardShareHeight": 9999999999999, + "nullGroupMembershipHeight": 20, + "adminQueryFixHeight": 9999999999999 }, "genesisInfo": { "version": 4, diff --git a/src/test/resources/test-chain-v2-reward-shares.json b/src/test/resources/test-chain-v2-reward-shares.json index 2f332233..36d83f81 100644 --- a/src/test/resources/test-chain-v2-reward-shares.json +++ b/src/test/resources/test-chain-v2-reward-shares.json @@ -29,6 +29,9 @@ "blockRewardBatchStartHeight": 999999000, "blockRewardBatchSize": 10, "blockRewardBatchAccountsBlockCount": 3, + "mintingGroupIds": [ + { "height": 0, "ids": [ 1 ]} + ], "rewardsByHeight": [ { "height": 1, "reward": 100 }, { "height": 11, "reward": 10 }, @@ -102,7 +105,12 @@ "onlyMintWithNameHeight": 9999999999990, "groupMemberCheckHeight": 9999999999999, "decreaseOnlineAccountsDifficultyTimestamp": 9999999999999, - "removeOnlyMintWithNameHeight": 9999999999999 + "removeOnlyMintWithNameHeight": 9999999999999, + "fixBatchRewardHeight": 9999999999999, + "adminsReplaceFoundersHeight": 9999999999999, + "ignoreLevelForRewardShareHeight": 9999999999999, + "nullGroupMembershipHeight": 20, + "adminQueryFixHeight": 9999999999999 }, "genesisInfo": { "version": 4, diff --git a/src/test/resources/test-chain-v2-self-sponsorship-algo-v1.json b/src/test/resources/test-chain-v2-self-sponsorship-algo-v1.json index 3ea8bc70..06b9a575 100644 --- a/src/test/resources/test-chain-v2-self-sponsorship-algo-v1.json +++ b/src/test/resources/test-chain-v2-self-sponsorship-algo-v1.json @@ -30,6 +30,9 @@ "blockRewardBatchStartHeight": 999999000, "blockRewardBatchSize": 10, "blockRewardBatchAccountsBlockCount": 3, + "mintingGroupIds": [ + { "height": 0, "ids": [ 2 ]} + ], "rewardsByHeight": [ { "height": 1, "reward": 100 }, { "height": 11, "reward": 10 }, @@ -102,7 +105,12 @@ "onlyMintWithNameHeight": 9999999999990, "groupMemberCheckHeight": 9999999999999, "decreaseOnlineAccountsDifficultyTimestamp": 9999999999999, - "removeOnlyMintWithNameHeight": 9999999999999 + "removeOnlyMintWithNameHeight": 9999999999999, + "fixBatchRewardHeight": 9999999999999, + "adminsReplaceFoundersHeight": 9999999999999, + "ignoreLevelForRewardShareHeight": 9999999999999, + "nullGroupMembershipHeight": 20, + "adminQueryFixHeight": 9999999999999 }, "genesisInfo": { "version": 4, @@ -118,8 +126,12 @@ { "type": "GENESIS", "recipient": "Qci5m9k4rcwe4ruKrZZQKka4FzUUMut3er", "amount": "1000000" }, { "type": "CREATE_GROUP", "creatorPublicKey": "2tiMr5LTpaWCgbRvkPK8TFd7k63DyHJMMFFsz9uBf1ZP", "groupName": "dev-group", "description": "developer group", "isOpen": false, "approvalThreshold": "PCT100", "minimumBlockDelay": 0, "maximumBlockDelay": 1440 }, + { "type": "CREATE_GROUP", "creatorPublicKey": "2tiMr5LTpaWCgbRvkPK8TFd7k63DyHJMMFFsz9uBf1ZP", "groupName": "MINTER", "description": "Minter group", "isOpen": false, "approvalThreshold": "PCT100", "minimumBlockDelay": 0, "maximumBlockDelay": 1440 }, { "type": "UPDATE_GROUP", "ownerPublicKey": "2tiMr5LTpaWCgbRvkPK8TFd7k63DyHJMMFFsz9uBf1ZP", "groupId": 1, "newOwner": "QdSnUy6sUiEnaN87dWmE92g1uQjrvPgrWG", "newDescription": "developer group", "newIsOpen": false, "newApprovalThreshold": "PCT40", "minimumBlockDelay": 10, "maximumBlockDelay": 1440 }, + { "type": "UPDATE_GROUP", "ownerPublicKey": "2tiMr5LTpaWCgbRvkPK8TFd7k63DyHJMMFFsz9uBf1ZP", "groupId": 2, "newOwner": "QdSnUy6sUiEnaN87dWmE92g1uQjrvPgrWG", "newDescription": "Minter group", "newIsOpen": true, "newApprovalThreshold": "PCT40", "minimumBlockDelay": 1, "maximumBlockDelay": 1440 }, + + { "type": "JOIN_GROUP", "joinerPublicKey": "2tiMr5LTpaWCgbRvkPK8TFd7k63DyHJMMFFsz9uBf1ZP", "groupId": 2}, { "type": "ISSUE_ASSET", "issuerPublicKey": "2tiMr5LTpaWCgbRvkPK8TFd7k63DyHJMMFFsz9uBf1ZP", "assetName": "TEST", "description": "test asset", "data": "", "quantity": "1000000", "isDivisible": true, "fee": 0 }, { "type": "ISSUE_ASSET", "issuerPublicKey": "C6wuddsBV3HzRrXUtezE7P5MoRXp5m3mEDokRDGZB6ry", "assetName": "OTHER", "description": "other test asset", "data": "", "quantity": "1000000", "isDivisible": true, "fee": 0 }, @@ -134,6 +146,7 @@ { "type": "ACCOUNT_LEVEL", "target": "Qci5m9k4rcwe4ruKrZZQKka4FzUUMut3er", "level": 5 }, { "type": "ACCOUNT_LEVEL", "target": "QaUpHNhT3Ygx6avRiKobuLdusppR5biXjL", "level": 5 }, { "type": "ACCOUNT_LEVEL", "target": "Qci5m9k4rcwe4ruKrZZQKka4FzUUMut3er", "level": 6 } + ] } } diff --git a/src/test/resources/test-chain-v2-self-sponsorship-algo-v2.json b/src/test/resources/test-chain-v2-self-sponsorship-algo-v2.json index ae424704..ea091e83 100644 --- a/src/test/resources/test-chain-v2-self-sponsorship-algo-v2.json +++ b/src/test/resources/test-chain-v2-self-sponsorship-algo-v2.json @@ -30,6 +30,9 @@ "blockRewardBatchStartHeight": 999999000, "blockRewardBatchSize": 10, "blockRewardBatchAccountsBlockCount": 3, + "mintingGroupIds": [ + { "height": 0, "ids": [ 1 ]} + ], "rewardsByHeight": [ { "height": 1, "reward": 100 }, { "height": 11, "reward": 10 }, @@ -102,7 +105,12 @@ "onlyMintWithNameHeight": 9999999999990, "groupMemberCheckHeight": 9999999999999, "decreaseOnlineAccountsDifficultyTimestamp": 9999999999999, - "removeOnlyMintWithNameHeight": 9999999999999 + "removeOnlyMintWithNameHeight": 9999999999999, + "fixBatchRewardHeight": 9999999999999, + "adminsReplaceFoundersHeight": 9999999999999, + "ignoreLevelForRewardShareHeight": 9999999999999, + "nullGroupMembershipHeight": 20, + "adminQueryFixHeight": 9999999999999 }, "genesisInfo": { "version": 4, diff --git a/src/test/resources/test-chain-v2-self-sponsorship-algo-v3.json b/src/test/resources/test-chain-v2-self-sponsorship-algo-v3.json index 2a24473b..306bf734 100644 --- a/src/test/resources/test-chain-v2-self-sponsorship-algo-v3.json +++ b/src/test/resources/test-chain-v2-self-sponsorship-algo-v3.json @@ -30,6 +30,9 @@ "blockRewardBatchStartHeight": 999999000, "blockRewardBatchSize": 10, "blockRewardBatchAccountsBlockCount": 3, + "mintingGroupIds": [ + { "height": 0, "ids": [ 1 ]} + ], "rewardsByHeight": [ { "height": 1, "reward": 100 }, { "height": 11, "reward": 10 }, @@ -102,7 +105,12 @@ "onlyMintWithNameHeight": 9999999999990, "groupMemberCheckHeight": 9999999999999, "decreaseOnlineAccountsDifficultyTimestamp": 9999999999999, - "removeOnlyMintWithNameHeight": 9999999999999 + "removeOnlyMintWithNameHeight": 9999999999999, + "fixBatchRewardHeight": 9999999999999, + "adminsReplaceFoundersHeight": 9999999999999, + "ignoreLevelForRewardShareHeight": 9999999999999, + "nullGroupMembershipHeight": 20, + "adminQueryFixHeight": 9999999999999 }, "genesisInfo": { "version": 4, diff --git a/src/test/resources/test-settings-v2.json b/src/test/resources/test-settings-v2.json index 0a604efa..5be973c9 100644 --- a/src/test/resources/test-settings-v2.json +++ b/src/test/resources/test-settings-v2.json @@ -16,5 +16,6 @@ "listsPath": "lists-test", "storagePolicy": "FOLLOWED_OR_VIEWED", "maxStorageCapacity": 104857600, - "arrrDefaultBirthday": 1900000 + "arrrDefaultBirthday": 1900000, + "archivingPause": 5 }