Search in sources :

Example 36 with RskAddress

use of co.rsk.core.RskAddress in project rskj by rsksmart.

the class RepositoryImplTest method getEmptyStorageBytes.

@Test
public void getEmptyStorageBytes() {
    RskAddress accAddress = randomAccountAddress();
    RepositoryImpl repository = new RepositoryImpl(config);
    byte[] bytes = repository.getStorageBytes(accAddress, DataWord.ONE);
    Assert.assertNull(bytes);
}
Also used : RskAddress(co.rsk.core.RskAddress) TrieImplHashTest(co.rsk.trie.TrieImplHashTest) Test(org.junit.Test)

Example 37 with RskAddress

use of co.rsk.core.RskAddress in project rskj by rsksmart.

the class RepositoryImplTest method flushNoReconnect.

@Test
public void flushNoReconnect() {
    TrieStore store = new TrieStoreImpl(new HashMapDB());
    RepositoryImpl repository = new RepositoryImpl(config, store);
    RskAddress accAddress = randomAccountAddress();
    byte[] initialRoot = repository.getRoot();
    repository.createAccount(accAddress);
    repository.flushNoReconnect();
    Assert.assertTrue(repository.isExist(accAddress));
}
Also used : TrieStoreImpl(co.rsk.trie.TrieStoreImpl) RskAddress(co.rsk.core.RskAddress) HashMapDB(org.ethereum.datasource.HashMapDB) TrieStore(co.rsk.trie.TrieStore) TrieImplHashTest(co.rsk.trie.TrieImplHashTest) Test(org.junit.Test)

Example 38 with RskAddress

use of co.rsk.core.RskAddress in project rskj by rsksmart.

the class RepositoryImplTest method isExistReturnsTrueForCreatedAccount.

@Test
public void isExistReturnsTrueForCreatedAccount() {
    RskAddress accAddress = randomAccountAddress();
    RepositoryImpl repository = new RepositoryImpl(config);
    repository.createAccount(accAddress);
    Assert.assertTrue(repository.isExist(accAddress));
}
Also used : RskAddress(co.rsk.core.RskAddress) TrieImplHashTest(co.rsk.trie.TrieImplHashTest) Test(org.junit.Test)

Example 39 with RskAddress

use of co.rsk.core.RskAddress in project rskj by rsksmart.

the class RepositoryImplTest method createAccountInTrackAndRollback.

@Test
public void createAccountInTrackAndRollback() {
    RskAddress accAddress = randomAccountAddress();
    RepositoryImpl repository = new RepositoryImpl(config);
    Repository track = repository.startTracking();
    Assert.assertNotNull(track);
    track.createAccount(accAddress);
    track.rollback();
    Assert.assertFalse(repository.isExist(accAddress));
}
Also used : Repository(org.ethereum.core.Repository) RskAddress(co.rsk.core.RskAddress) TrieImplHashTest(co.rsk.trie.TrieImplHashTest) Test(org.junit.Test)

Example 40 with RskAddress

use of co.rsk.core.RskAddress in project rskj by rsksmart.

the class RepositoryImplTest method incrementAccountNonceTwiceForAlreadyCreatedAccount.

@Test
public void incrementAccountNonceTwiceForAlreadyCreatedAccount() {
    RskAddress accAddress = randomAccountAddress();
    RepositoryImpl repository = new RepositoryImpl(config);
    repository.createAccount(accAddress);
    repository.increaseNonce(accAddress);
    repository.increaseNonce(accAddress);
    Assert.assertEquals(2, repository.getNonce(accAddress).longValue());
}
Also used : RskAddress(co.rsk.core.RskAddress) TrieImplHashTest(co.rsk.trie.TrieImplHashTest) Test(org.junit.Test)

Aggregations

RskAddress (co.rsk.core.RskAddress)174 Test (org.junit.Test)102 Repository (org.ethereum.core.Repository)60 BigInteger (java.math.BigInteger)47 Coin (co.rsk.core.Coin)38 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)29 DataWord (org.ethereum.vm.DataWord)27 TrieImplHashTest (co.rsk.trie.TrieImplHashTest)24 RepositoryImpl (co.rsk.db.RepositoryImpl)16 SimpleRskTransaction (co.rsk.peg.simples.SimpleRskTransaction)15 Transaction (org.ethereum.core.Transaction)15 Program (org.ethereum.vm.program.Program)15 InvocationOnMock (org.mockito.invocation.InvocationOnMock)14 AccountState (org.ethereum.core.AccountState)12 HashMapDB (org.ethereum.datasource.HashMapDB)11 ArrayList (java.util.ArrayList)10 ProgramInvokeMockImpl (org.ethereum.vm.program.invoke.ProgramInvokeMockImpl)10 BridgeConstants (co.rsk.config.BridgeConstants)8 RskSystemProperties (co.rsk.config.RskSystemProperties)8 TrieStoreImpl (co.rsk.trie.TrieStoreImpl)8