use of co.rsk.core.RskAddress in project rskj by rsksmart.
the class DetailsDataStoreTest method test4.
@Test
public void test4() {
DatabaseImpl db = new DatabaseImpl(new HashMapDB());
DetailsDataStore dds = new DetailsDataStore(config, db);
RskAddress c_key = new RskAddress("0000000000000000000000000000000000001a2b");
ContractDetails contractDetails = dds.get(c_key);
assertNull(contractDetails);
}
use of co.rsk.core.RskAddress in project rskj by rsksmart.
the class DetailsDataStoreTest method test1.
@Test
public void test1() {
DatabaseImpl db = new DatabaseImpl(new HashMapDB());
DetailsDataStore dds = new DetailsDataStore(config, db);
RskAddress c_key = new RskAddress("0000000000000000000000000000000000001a2b");
byte[] code = Hex.decode("60606060");
byte[] key = Hex.decode("11");
byte[] value = Hex.decode("aa");
ContractDetails contractDetails = new ContractDetailsImpl(config);
contractDetails.setAddress(randomAddress().getBytes());
contractDetails.setCode(code);
contractDetails.put(new DataWord(key), new DataWord(value));
dds.update(c_key, contractDetails);
ContractDetails contractDetails_ = dds.get(c_key);
String encoded1 = Hex.toHexString(contractDetails.getEncoded());
String encoded2 = Hex.toHexString(contractDetails_.getEncoded());
assertEquals(encoded1, encoded2);
dds.flush();
contractDetails_ = dds.get(c_key);
encoded2 = Hex.toHexString(contractDetails_.getEncoded());
assertEquals(encoded1, encoded2);
}
use of co.rsk.core.RskAddress 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 co.rsk.core.RskAddress in project rskj by rsksmart.
the class RepositoryImplTest method randomAccountAddress.
private static RskAddress randomAccountAddress() {
byte[] bytes = new byte[20];
new Random().nextBytes(bytes);
return new RskAddress(bytes);
}
use of co.rsk.core.RskAddress in project rskj by rsksmart.
the class RepositoryImplTest method updateAccountState.
@Test
public void updateAccountState() {
RskAddress accAddress = randomAccountAddress();
RepositoryImpl repository = new RepositoryImpl(config);
AccountState accState = repository.createAccount(accAddress);
accState.incrementNonce();
accState.addToBalance(Coin.valueOf(1L));
repository.updateAccountState(accAddress, accState);
AccountState newAccState = repository.getAccountState(accAddress);
Assert.assertNotNull(newAccState);
Assert.assertEquals(BigInteger.ONE, newAccState.getNonce());
Assert.assertEquals(BigInteger.ONE, newAccState.getBalance().asBigInteger());
}
Aggregations