use of org.ethereum.vm.DataWord in project rskj by rsksmart.
the class RepositoryImplOriginalTest method test16_2.
@Test
public void test16_2() {
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();
// changes level_2
Repository track2 = track1.startTracking();
track2.addStorageRow(COW, new DataWord(cowKey2), new DataWord(cowValue2));
track2.addStorageRow(HORSE, new DataWord(horseKey2), new DataWord(horseValue2));
assertNull(track2.getStorageValue(COW, new DataWord(cowKey1)));
assertNull(track2.getStorageValue(HORSE, new DataWord(horseKey1)));
assertEquals(new DataWord(cowValue2), track2.getStorageValue(COW, new DataWord(cowKey2)));
assertEquals(new DataWord(horseValue2), track2.getStorageValue(HORSE, new DataWord(horseKey2)));
track2.commit();
// leaving level_2
assertNull(track1.getStorageValue(COW, new DataWord(cowKey1)));
assertNull(track1.getStorageValue(HORSE, new DataWord(horseKey1)));
assertEquals(new DataWord(cowValue2), track1.getStorageValue(COW, new DataWord(cowKey2)));
assertEquals(new DataWord(horseValue2), track1.getStorageValue(HORSE, new DataWord(horseKey2)));
track1.commit();
// leaving level_1
assertEquals(null, repository.getStorageValue(COW, new DataWord(cowKey1)));
assertEquals(null, repository.getStorageValue(HORSE, new DataWord(horseKey1)));
assertEquals(new DataWord(cowValue2), repository.getStorageValue(COW, new DataWord(cowKey2)));
assertEquals(new DataWord(horseValue2), repository.getStorageValue(HORSE, new DataWord(horseKey2)));
repository.close();
}
use of org.ethereum.vm.DataWord in project rskj by rsksmart.
the class RepositoryImplOriginalTest method test16.
@Test
public void test16() {
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(cowKey1), new DataWord(cowValue1));
track1.addStorageRow(HORSE, new DataWord(horseKey1), new DataWord(horseValue1));
assertEquals(new DataWord(cowValue1), track1.getStorageValue(COW, new DataWord(cowKey1)));
assertEquals(new DataWord(horseValue1), track1.getStorageValue(HORSE, new DataWord(horseKey1)));
// changes level_2
Repository track2 = track1.startTracking();
track2.addStorageRow(COW, new DataWord(cowKey2), new DataWord(cowValue2));
track2.addStorageRow(HORSE, new DataWord(horseKey2), new DataWord(horseValue2));
assertEquals(new DataWord(cowValue1), track2.getStorageValue(COW, new DataWord(cowKey1)));
assertEquals(new DataWord(horseValue1), track2.getStorageValue(HORSE, new DataWord(horseKey1)));
assertEquals(new DataWord(cowValue2), track2.getStorageValue(COW, new DataWord(cowKey2)));
assertEquals(new DataWord(horseValue2), track2.getStorageValue(HORSE, new DataWord(horseKey2)));
track2.commit();
// leaving level_2
assertEquals(new DataWord(cowValue1), track1.getStorageValue(COW, new DataWord(cowKey1)));
assertEquals(new DataWord(horseValue1), track1.getStorageValue(HORSE, new DataWord(horseKey1)));
assertEquals(new DataWord(cowValue2), track1.getStorageValue(COW, new DataWord(cowKey2)));
assertEquals(new DataWord(horseValue2), track1.getStorageValue(HORSE, new DataWord(horseKey2)));
track1.commit();
// leaving level_1
assertEquals(new DataWord(cowValue1), repository.getStorageValue(COW, new DataWord(cowKey1)));
assertEquals(new DataWord(horseValue1), repository.getStorageValue(HORSE, new DataWord(horseKey1)));
assertEquals(new DataWord(cowValue2), repository.getStorageValue(COW, new DataWord(cowKey2)));
assertEquals(new DataWord(horseValue2), repository.getStorageValue(HORSE, new DataWord(horseKey2)));
repository.close();
}
use of org.ethereum.vm.DataWord in project rskj by rsksmart.
the class RepositoryImplTest method setAndGetStorageValueUsingNewRepositoryForTest.
@Test
public void setAndGetStorageValueUsingNewRepositoryForTest() {
RskAddress accAddress = randomAccountAddress();
RepositoryImpl repository = new RepositoryImplForTesting();
repository.addStorageRow(accAddress, DataWord.ONE, DataWord.ONE);
DataWord value = repository.getStorageValue(accAddress, DataWord.ONE);
Assert.assertNotNull(value);
Assert.assertEquals(DataWord.ONE, value);
}
use of org.ethereum.vm.DataWord in project rskj by rsksmart.
the class RepositoryImplTest method getEmptyStorageValue.
@Test
public void getEmptyStorageValue() {
RskAddress accAddress = randomAccountAddress();
RepositoryImpl repository = new RepositoryImpl(config);
repository.createAccount(accAddress);
DataWord value = repository.getStorageValue(accAddress, DataWord.ONE);
Assert.assertNull(value);
}
use of org.ethereum.vm.DataWord in project rskj by rsksmart.
the class RepositoryTest 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.addStorageBytes(COW, new DataWord(cowKey), cowValue);
track.addStorageBytes(HORSE, new DataWord(horseKey), horseValue);
track.commit();
assertArrayEquals(cowValue, repository.getStorageBytes(COW, new DataWord(cowKey)));
assertArrayEquals(horseValue, repository.getStorageBytes(HORSE, new DataWord(horseKey)));
repository.close();
}
Aggregations