use of org.ethereum.core.Repository in project rskj by rsksmart.
the class RepositoryImplOriginalTest method test1.
@Test
public void test1() {
Repository repository = new RepositoryImpl(config);
repository.increaseNonce(COW);
repository.increaseNonce(HORSE);
assertEquals(BigInteger.ONE, repository.getNonce(COW));
repository.increaseNonce(COW);
repository.close();
}
use of org.ethereum.core.Repository in project rskj by rsksmart.
the class RepositoryImplOriginalTest method test16_5.
@Test
public void test16_5() {
Repository repository = new RepositoryImpl(config);
byte[] cowKey1 = "key-c-1".getBytes();
byte[] cowValue1 = "val-c-1".getBytes();
byte[] horseKey1 = "key-h-1".getBytes();
byte[] horseValue1 = "val-h-1".getBytes();
byte[] cowKey2 = "key-c-2".getBytes();
byte[] cowValue2 = "val-c-2".getBytes();
byte[] horseKey2 = "key-h-2".getBytes();
byte[] horseValue2 = "val-h-2".getBytes();
// changes level_1
Repository track1 = repository.startTracking();
track1.addStorageRow(COW, new DataWord(cowKey2), new DataWord(cowValue2));
// changes level_2
Repository track2 = track1.startTracking();
assertEquals(new DataWord(cowValue2), track1.getStorageValue(COW, new DataWord(cowKey2)));
assertNull(track1.getStorageValue(COW, new DataWord(cowKey1)));
track2.commit();
// leaving level_2
track1.commit();
// leaving level_1
assertEquals(new DataWord(cowValue2), track1.getStorageValue(COW, new DataWord(cowKey2)));
assertNull(track1.getStorageValue(COW, new DataWord(cowKey1)));
repository.close();
}
use of org.ethereum.core.Repository in project rskj by rsksmart.
the class RepositoryImplOriginalTest method test3.
@Test
public void test3() {
Repository repository = new RepositoryImpl(config);
byte[] cowCode = Hex.decode("A1A2A3");
byte[] horseCode = Hex.decode("B1B2B3");
repository.saveCode(COW, cowCode);
repository.saveCode(HORSE, horseCode);
assertArrayEquals(cowCode, repository.getCode(COW));
assertArrayEquals(horseCode, repository.getCode(HORSE));
repository.close();
}
use of org.ethereum.core.Repository in project rskj by rsksmart.
the class RepositoryImplOriginalTest method test4.
@Test
public void test4() {
Repository repository = new RepositoryImpl(config);
Repository track = repository.startTracking();
byte[] cowKey = Hex.decode("A1A2A3");
byte[] cowValue = Hex.decode("A4A5A6");
byte[] horseKey = Hex.decode("B1B2B3");
byte[] horseValue = Hex.decode("B4B5B6");
track.addStorageRow(COW, new DataWord(cowKey), new DataWord(cowValue));
track.addStorageRow(HORSE, new DataWord(horseKey), new DataWord(horseValue));
track.commit();
assertEquals(new DataWord(cowValue), repository.getStorageValue(COW, new DataWord(cowKey)));
assertEquals(new DataWord(horseValue), repository.getStorageValue(HORSE, new DataWord(horseKey)));
repository.close();
}
use of org.ethereum.core.Repository in project rskj by rsksmart.
the class RepositoryImplOriginalTest method test13.
// Let's upload genesis pre-mine just like in the real world
@Test
public void test13() {
Repository repository = new RepositoryImpl(config);
Repository track = repository.startTracking();
Genesis genesis = (Genesis) Genesis.getInstance(config);
for (RskAddress addr : genesis.getPremine().keySet()) {
repository.createAccount(addr);
repository.addBalance(addr, genesis.getPremine().get(addr).getAccountState().getBalance());
}
track.commit();
// To Review: config Genesis should have an State Root according to the new trie algorithm
// assertArrayEquals(Genesis.getInstance(SystemProperties.CONFIG).getStateRoot(), repository.getRoot());
repository.close();
}
Aggregations