use of org.ethereum.core.Repository in project rskj by rsksmart.
the class RepositoryImplOriginalTest method test16_4.
@Test
public void test16_4() {
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();
Repository track = repository.startTracking();
track.addStorageRow(COW, new DataWord(cowKey1), new DataWord(cowValue1));
track.commit();
// changes level_1
Repository track1 = repository.startTracking();
// changes level_2
Repository track2 = track1.startTracking();
track2.addStorageRow(COW, new DataWord(cowKey2), new DataWord(cowValue2));
track2.commit();
// leaving level_2
track1.commit();
// leaving level_1
assertEquals(new DataWord(cowValue1), track1.getStorageValue(COW, new DataWord(cowKey1)));
assertEquals(new DataWord(cowValue2), track1.getStorageValue(COW, new DataWord(cowKey2)));
repository.close();
}
use of org.ethereum.core.Repository in project rskj by rsksmart.
the class RepositoryImplOriginalTest method test5.
@Test
public void test5() {
Repository repository = new RepositoryImpl(config);
Repository track = repository.startTracking();
track.increaseNonce(COW);
track.increaseNonce(COW);
track.increaseNonce(COW);
track.increaseNonce(COW);
track.increaseNonce(COW);
track.increaseNonce(COW);
track.increaseNonce(COW);
track.increaseNonce(COW);
track.increaseNonce(COW);
track.increaseNonce(COW);
track.increaseNonce(HORSE);
track.commit();
assertEquals(BigInteger.TEN, repository.getNonce(COW));
assertEquals(BigInteger.ONE, repository.getNonce(HORSE));
repository.close();
}
use of org.ethereum.core.Repository in project rskj by rsksmart.
the class RepositoryImplOriginalTest method test11.
@Test
public void test11() {
Repository repository = new RepositoryImpl(config);
Repository track = repository.startTracking();
byte[] cowCode = Hex.decode("A1A2A3");
byte[] horseCode = Hex.decode("B1B2B3");
track.saveCode(COW, cowCode);
track.saveCode(HORSE, horseCode);
assertArrayEquals(cowCode, track.getCode(COW));
assertArrayEquals(horseCode, track.getCode(HORSE));
track.commit();
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 test12.
@Test
public void test12() {
Repository repository = new RepositoryImpl(config);
Repository track = repository.startTracking();
byte[] cowCode = Hex.decode("A1A2A3");
byte[] horseCode = Hex.decode("B1B2B3");
track.saveCode(COW, cowCode);
track.saveCode(HORSE, horseCode);
assertArrayEquals(cowCode, track.getCode(COW));
assertArrayEquals(horseCode, track.getCode(HORSE));
track.rollback();
assertArrayEquals(EMPTY_BYTE_ARRAY, repository.getCode(COW));
assertArrayEquals(EMPTY_BYTE_ARRAY, repository.getCode(HORSE));
repository.close();
}
use of org.ethereum.core.Repository in project rskj by rsksmart.
the class RepositoryImplOriginalTest method test7.
@Test
public void test7() {
Repository repository = new RepositoryImpl(config);
Repository track = repository.startTracking();
track.addBalance(COW, Coin.valueOf(10L));
track.addBalance(HORSE, Coin.valueOf(1L));
assertEquals(BigInteger.TEN, track.getBalance(COW).asBigInteger());
assertEquals(BigInteger.ONE, track.getBalance(HORSE).asBigInteger());
track.commit();
assertEquals(BigInteger.TEN, repository.getBalance(COW).asBigInteger());
assertEquals(BigInteger.ONE, repository.getBalance(HORSE).asBigInteger());
repository.close();
}
Aggregations