use of co.rsk.db.RepositoryImplForTesting in project rskj by rsksmart.
the class RemascStorageProviderTest method setSaveRetrieveAndGetSiblings.
@Test
public void setSaveRetrieveAndGetSiblings() throws IOException {
RskAddress accountAddress = randomAddress();
Repository repository = new RepositoryImplForTesting();
RemascStorageProvider provider = new RemascStorageProvider(repository, accountAddress);
BlockGenerator blockGenerator = new BlockGenerator();
Block genesis = blockGenerator.getGenesisBlock();
Block block = blockGenerator.createChildBlock(genesis);
Sibling sibling1 = new Sibling(genesis.getHeader(), genesis.getCoinbase(), 1);
Sibling sibling2 = new Sibling(block.getHeader(), block.getCoinbase(), 2);
List<Sibling> siblings = new ArrayList<>();
siblings.add(sibling1);
siblings.add(sibling2);
provider.getSiblings().put(Long.valueOf(1), siblings);
provider.save();
RemascStorageProvider newProvider = new RemascStorageProvider(repository, accountAddress);
SortedMap<Long, List<Sibling>> map = newProvider.getSiblings();
Assert.assertNotNull(map);
Assert.assertFalse(map.isEmpty());
Assert.assertTrue(map.containsKey(Long.valueOf(1)));
Assert.assertEquals(2, map.get(Long.valueOf(1)).size());
}
Aggregations