Search in sources :

Example 6 with BootstrapDataIndex

use of co.rsk.db.importer.provider.index.data.BootstrapDataIndex in project rskj by rsksmart.

the class BootstrapIndexCandidateSelectorTest method getMaximumCommonHeightDataOneEntry.

@Test(expected = BootstrapImportException.class)
public void getMaximumCommonHeightDataOneEntry() {
    List<String> keys = Arrays.asList("key1", "key2");
    BootstrapIndexCandidateSelector indexMCH = new BootstrapIndexCandidateSelector(keys, 2);
    List<BootstrapDataIndex> indexes = new ArrayList<>();
    ArrayList<BootstrapDataEntry> entries = new ArrayList<>();
    entries.add(new BootstrapDataEntry(1, "", "dbPath", "hash", new BootstrapDataSignature("r", "s")));
    indexes.add(new BootstrapDataIndex(entries));
    indexMCH.getHeightData(indexes);
}
Also used : BootstrapDataSignature(co.rsk.db.importer.provider.index.data.BootstrapDataSignature) BootstrapDataEntry(co.rsk.db.importer.provider.index.data.BootstrapDataEntry) ArrayList(java.util.ArrayList) BootstrapDataIndex(co.rsk.db.importer.provider.index.data.BootstrapDataIndex) Test(org.junit.Test)

Example 7 with BootstrapDataIndex

use of co.rsk.db.importer.provider.index.data.BootstrapDataIndex in project rskj by rsksmart.

the class BootstrapIndexCandidateSelectorTest method getMaximumCommonHeightDataTwoEntries.

@Test
public void getMaximumCommonHeightDataTwoEntries() {
    List<String> keys = Arrays.asList("key1", "key2");
    BootstrapIndexCandidateSelector indexMCH = new BootstrapIndexCandidateSelector(keys, 2);
    List<BootstrapDataIndex> indexes = new ArrayList<>();
    ArrayList<BootstrapDataEntry> entries = new ArrayList<>();
    ArrayList<BootstrapDataEntry> entries2 = new ArrayList<>();
    entries.add(new BootstrapDataEntry(1, "", "dbPath", "hash", new BootstrapDataSignature("r", "s")));
    entries2.add(new BootstrapDataEntry(1, "", "dbPath", "hash", new BootstrapDataSignature("r", "s")));
    indexes.add(new BootstrapDataIndex(entries));
    indexes.add(new BootstrapDataIndex(entries2));
    BootstrapIndexCandidateSelector.HeightCandidate heightCandidate = indexMCH.getHeightData(indexes);
    assertEquals(1, heightCandidate.getHeight());
}
Also used : BootstrapDataSignature(co.rsk.db.importer.provider.index.data.BootstrapDataSignature) BootstrapDataEntry(co.rsk.db.importer.provider.index.data.BootstrapDataEntry) ArrayList(java.util.ArrayList) BootstrapDataIndex(co.rsk.db.importer.provider.index.data.BootstrapDataIndex) Test(org.junit.Test)

Example 8 with BootstrapDataIndex

use of co.rsk.db.importer.provider.index.data.BootstrapDataIndex in project rskj by rsksmart.

the class BootstrapIndexCandidateSelectorTest method getMaximumCommonHeightDataManyEntries.

@Test
public void getMaximumCommonHeightDataManyEntries() {
    List<String> keys = Arrays.asList("key1", "key2", "keys3");
    BootstrapIndexCandidateSelector indexMCH = new BootstrapIndexCandidateSelector(keys, 2);
    List<BootstrapDataIndex> indexes = new ArrayList<>();
    ArrayList<BootstrapDataEntry> entries = new ArrayList<>();
    ArrayList<BootstrapDataEntry> entries2 = new ArrayList<>();
    ArrayList<BootstrapDataEntry> entries3 = new ArrayList<>();
    entries.add(new BootstrapDataEntry(1, "", "dbPath", "hash", new BootstrapDataSignature("r", "s")));
    entries2.add(new BootstrapDataEntry(1, "", "dbPath", "hash", new BootstrapDataSignature("r", "s")));
    entries3.add(new BootstrapDataEntry(1, "", "dbPath", "hash", new BootstrapDataSignature("r", "s")));
    entries.add(new BootstrapDataEntry(2, "", "dbPath", "hash", new BootstrapDataSignature("r", "s")));
    entries2.add(new BootstrapDataEntry(2, "", "dbPath", "hash", new BootstrapDataSignature("r", "s")));
    entries3.add(new BootstrapDataEntry(2, "", "dbPath", "hash", new BootstrapDataSignature("r", "s")));
    indexes.add(new BootstrapDataIndex(entries));
    indexes.add(new BootstrapDataIndex(entries2));
    indexes.add(new BootstrapDataIndex(entries3));
    BootstrapIndexCandidateSelector.HeightCandidate heightCandidate = indexMCH.getHeightData(indexes);
    assertEquals(heightCandidate.getHeight(), 2L);
}
Also used : BootstrapDataSignature(co.rsk.db.importer.provider.index.data.BootstrapDataSignature) BootstrapDataEntry(co.rsk.db.importer.provider.index.data.BootstrapDataEntry) ArrayList(java.util.ArrayList) BootstrapDataIndex(co.rsk.db.importer.provider.index.data.BootstrapDataIndex) Test(org.junit.Test)

Aggregations

BootstrapDataIndex (co.rsk.db.importer.provider.index.data.BootstrapDataIndex)8 BootstrapDataEntry (co.rsk.db.importer.provider.index.data.BootstrapDataEntry)7 BootstrapDataSignature (co.rsk.db.importer.provider.index.data.BootstrapDataSignature)6 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 URL (java.net.URL)2 BootstrapImportException (co.rsk.db.importer.BootstrapImportException)1 BootstrapURLProvider (co.rsk.db.importer.BootstrapURLProvider)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1