forked from Qortal/qortal
Simplified minting code in block archive tests.
This commit is contained in:
parent
53cd967541
commit
1ba542eb50
@ -29,7 +29,6 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
@ -53,14 +52,10 @@ public class BlockArchiveTests extends Common {
|
|||||||
public void testWriter() throws DataException, InterruptedException, TransformationException, IOException {
|
public void testWriter() throws DataException, InterruptedException, TransformationException, IOException {
|
||||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
|
|
||||||
// Alice self share online
|
|
||||||
List<PrivateKeyAccount> mintingAndOnlineAccounts = new ArrayList<>();
|
|
||||||
PrivateKeyAccount aliceSelfShare = Common.getTestAccount(repository, "alice-reward-share");
|
|
||||||
mintingAndOnlineAccounts.add(aliceSelfShare);
|
|
||||||
|
|
||||||
// Mint some blocks so that we are able to archive them later
|
// Mint some blocks so that we are able to archive them later
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++) {
|
||||||
BlockMinter.mintTestingBlock(repository, mintingAndOnlineAccounts.toArray(new PrivateKeyAccount[0]));
|
BlockMinter.mintTestingBlock(repository, Common.getTestAccount(repository, "alice-reward-share"));
|
||||||
|
}
|
||||||
|
|
||||||
// 900 blocks are trimmed (this specifies the first untrimmed height)
|
// 900 blocks are trimmed (this specifies the first untrimmed height)
|
||||||
repository.getBlockRepository().setOnlineAccountsSignaturesTrimHeight(901);
|
repository.getBlockRepository().setOnlineAccountsSignaturesTrimHeight(901);
|
||||||
@ -94,14 +89,10 @@ public class BlockArchiveTests extends Common {
|
|||||||
public void testWriterAndReader() throws DataException, InterruptedException, TransformationException, IOException {
|
public void testWriterAndReader() throws DataException, InterruptedException, TransformationException, IOException {
|
||||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
|
|
||||||
// Alice self share online
|
|
||||||
List<PrivateKeyAccount> mintingAndOnlineAccounts = new ArrayList<>();
|
|
||||||
PrivateKeyAccount aliceSelfShare = Common.getTestAccount(repository, "alice-reward-share");
|
|
||||||
mintingAndOnlineAccounts.add(aliceSelfShare);
|
|
||||||
|
|
||||||
// Mint some blocks so that we are able to archive them later
|
// Mint some blocks so that we are able to archive them later
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++) {
|
||||||
BlockMinter.mintTestingBlock(repository, mintingAndOnlineAccounts.toArray(new PrivateKeyAccount[0]));
|
BlockMinter.mintTestingBlock(repository, Common.getTestAccount(repository, "alice-reward-share"));
|
||||||
|
}
|
||||||
|
|
||||||
// 900 blocks are trimmed (this specifies the first untrimmed height)
|
// 900 blocks are trimmed (this specifies the first untrimmed height)
|
||||||
repository.getBlockRepository().setOnlineAccountsSignaturesTrimHeight(901);
|
repository.getBlockRepository().setOnlineAccountsSignaturesTrimHeight(901);
|
||||||
@ -165,11 +156,6 @@ public class BlockArchiveTests extends Common {
|
|||||||
public void testArchivedAtStates() throws DataException, InterruptedException, TransformationException, IOException {
|
public void testArchivedAtStates() throws DataException, InterruptedException, TransformationException, IOException {
|
||||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
|
|
||||||
// Alice self share online
|
|
||||||
List<PrivateKeyAccount> mintingAndOnlineAccounts = new ArrayList<>();
|
|
||||||
PrivateKeyAccount aliceSelfShare = Common.getTestAccount(repository, "alice-reward-share");
|
|
||||||
mintingAndOnlineAccounts.add(aliceSelfShare);
|
|
||||||
|
|
||||||
// Deploy an AT so that we have AT state data
|
// Deploy an AT so that we have AT state data
|
||||||
PrivateKeyAccount deployer = Common.getTestAccount(repository, "alice");
|
PrivateKeyAccount deployer = Common.getTestAccount(repository, "alice");
|
||||||
byte[] creationBytes = AtUtils.buildSimpleAT();
|
byte[] creationBytes = AtUtils.buildSimpleAT();
|
||||||
@ -178,8 +164,9 @@ public class BlockArchiveTests extends Common {
|
|||||||
String atAddress = deployAtTransaction.getATAccount().getAddress();
|
String atAddress = deployAtTransaction.getATAccount().getAddress();
|
||||||
|
|
||||||
// Mint some blocks so that we are able to archive them later
|
// Mint some blocks so that we are able to archive them later
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 1000; i++) {
|
||||||
BlockMinter.mintTestingBlock(repository, mintingAndOnlineAccounts.toArray(new PrivateKeyAccount[0]));
|
BlockMinter.mintTestingBlock(repository, Common.getTestAccount(repository, "alice-reward-share"));
|
||||||
|
}
|
||||||
|
|
||||||
// 9 blocks are trimmed (this specifies the first untrimmed height)
|
// 9 blocks are trimmed (this specifies the first untrimmed height)
|
||||||
repository.getBlockRepository().setOnlineAccountsSignaturesTrimHeight(10);
|
repository.getBlockRepository().setOnlineAccountsSignaturesTrimHeight(10);
|
||||||
@ -278,11 +265,6 @@ public class BlockArchiveTests extends Common {
|
|||||||
public void testArchiveAndPrune() throws DataException, InterruptedException, TransformationException, IOException {
|
public void testArchiveAndPrune() throws DataException, InterruptedException, TransformationException, IOException {
|
||||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
|
|
||||||
// Alice self share online
|
|
||||||
List<PrivateKeyAccount> mintingAndOnlineAccounts = new ArrayList<>();
|
|
||||||
PrivateKeyAccount aliceSelfShare = Common.getTestAccount(repository, "alice-reward-share");
|
|
||||||
mintingAndOnlineAccounts.add(aliceSelfShare);
|
|
||||||
|
|
||||||
// Deploy an AT so that we have AT state data
|
// Deploy an AT so that we have AT state data
|
||||||
PrivateKeyAccount deployer = Common.getTestAccount(repository, "alice");
|
PrivateKeyAccount deployer = Common.getTestAccount(repository, "alice");
|
||||||
byte[] creationBytes = AtUtils.buildSimpleAT();
|
byte[] creationBytes = AtUtils.buildSimpleAT();
|
||||||
@ -290,8 +272,9 @@ public class BlockArchiveTests extends Common {
|
|||||||
AtUtils.doDeployAT(repository, deployer, creationBytes, fundingAmount);
|
AtUtils.doDeployAT(repository, deployer, creationBytes, fundingAmount);
|
||||||
|
|
||||||
// Mint some blocks so that we are able to archive them later
|
// Mint some blocks so that we are able to archive them later
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++) {
|
||||||
BlockMinter.mintTestingBlock(repository, mintingAndOnlineAccounts.toArray(new PrivateKeyAccount[0]));
|
BlockMinter.mintTestingBlock(repository, Common.getTestAccount(repository, "alice-reward-share"));
|
||||||
|
}
|
||||||
|
|
||||||
// Assume 900 blocks are trimmed (this specifies the first untrimmed height)
|
// Assume 900 blocks are trimmed (this specifies the first untrimmed height)
|
||||||
repository.getBlockRepository().setOnlineAccountsSignaturesTrimHeight(901);
|
repository.getBlockRepository().setOnlineAccountsSignaturesTrimHeight(901);
|
||||||
@ -353,11 +336,6 @@ public class BlockArchiveTests extends Common {
|
|||||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
HSQLDBRepository hsqldb = (HSQLDBRepository) repository;
|
HSQLDBRepository hsqldb = (HSQLDBRepository) repository;
|
||||||
|
|
||||||
// Alice self share online
|
|
||||||
List<PrivateKeyAccount> mintingAndOnlineAccounts = new ArrayList<>();
|
|
||||||
PrivateKeyAccount aliceSelfShare = Common.getTestAccount(repository, "alice-reward-share");
|
|
||||||
mintingAndOnlineAccounts.add(aliceSelfShare);
|
|
||||||
|
|
||||||
// Deploy an AT so that we have AT state data
|
// Deploy an AT so that we have AT state data
|
||||||
PrivateKeyAccount deployer = Common.getTestAccount(repository, "alice");
|
PrivateKeyAccount deployer = Common.getTestAccount(repository, "alice");
|
||||||
byte[] creationBytes = AtUtils.buildSimpleAT();
|
byte[] creationBytes = AtUtils.buildSimpleAT();
|
||||||
@ -365,8 +343,9 @@ public class BlockArchiveTests extends Common {
|
|||||||
AtUtils.doDeployAT(repository, deployer, creationBytes, fundingAmount);
|
AtUtils.doDeployAT(repository, deployer, creationBytes, fundingAmount);
|
||||||
|
|
||||||
// Mint some blocks so that we are able to archive them later
|
// Mint some blocks so that we are able to archive them later
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++) {
|
||||||
BlockMinter.mintTestingBlock(repository, mintingAndOnlineAccounts.toArray(new PrivateKeyAccount[0]));
|
BlockMinter.mintTestingBlock(repository, Common.getTestAccount(repository, "alice-reward-share"));
|
||||||
|
}
|
||||||
|
|
||||||
// Assume 900 blocks are trimmed (this specifies the first untrimmed height)
|
// Assume 900 blocks are trimmed (this specifies the first untrimmed height)
|
||||||
repository.getBlockRepository().setOnlineAccountsSignaturesTrimHeight(901);
|
repository.getBlockRepository().setOnlineAccountsSignaturesTrimHeight(901);
|
||||||
@ -450,11 +429,6 @@ public class BlockArchiveTests extends Common {
|
|||||||
public void testTrimArchivePruneAndOrphan() throws DataException, InterruptedException, TransformationException, IOException {
|
public void testTrimArchivePruneAndOrphan() throws DataException, InterruptedException, TransformationException, IOException {
|
||||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
|
|
||||||
// Alice self share online
|
|
||||||
List<PrivateKeyAccount> mintingAndOnlineAccounts = new ArrayList<>();
|
|
||||||
PrivateKeyAccount aliceSelfShare = Common.getTestAccount(repository, "alice-reward-share");
|
|
||||||
mintingAndOnlineAccounts.add(aliceSelfShare);
|
|
||||||
|
|
||||||
// Deploy an AT so that we have AT state data
|
// Deploy an AT so that we have AT state data
|
||||||
PrivateKeyAccount deployer = Common.getTestAccount(repository, "alice");
|
PrivateKeyAccount deployer = Common.getTestAccount(repository, "alice");
|
||||||
byte[] creationBytes = AtUtils.buildSimpleAT();
|
byte[] creationBytes = AtUtils.buildSimpleAT();
|
||||||
@ -462,8 +436,9 @@ public class BlockArchiveTests extends Common {
|
|||||||
AtUtils.doDeployAT(repository, deployer, creationBytes, fundingAmount);
|
AtUtils.doDeployAT(repository, deployer, creationBytes, fundingAmount);
|
||||||
|
|
||||||
// Mint some blocks so that we are able to archive them later
|
// Mint some blocks so that we are able to archive them later
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 1000; i++) {
|
||||||
BlockMinter.mintTestingBlock(repository, mintingAndOnlineAccounts.toArray(new PrivateKeyAccount[0]));
|
BlockMinter.mintTestingBlock(repository, Common.getTestAccount(repository, "alice-reward-share"));
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure that block 500 has full AT state data and data hash
|
// Make sure that block 500 has full AT state data and data hash
|
||||||
List<ATStateData> block500AtStatesData = repository.getATRepository().getBlockATStatesAtHeight(500);
|
List<ATStateData> block500AtStatesData = repository.getATRepository().getBlockATStatesAtHeight(500);
|
||||||
|
Loading…
Reference in New Issue
Block a user