Search in sources :

Example 31 with RskAddress

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

the class RepositoryImplTest method hibernateAccount.

@Test
public void hibernateAccount() {
    RskAddress accAddress = randomAccountAddress();
    RepositoryImpl repository = new RepositoryImpl(config);
    repository.createAccount(accAddress);
    repository.hibernate(accAddress);
    AccountState accState = repository.getAccountState(accAddress);
    Assert.assertNotNull(accState);
    Assert.assertTrue(accState.isHibernated());
}
Also used : RskAddress(co.rsk.core.RskAddress) AccountState(org.ethereum.core.AccountState) TrieImplHashTest(co.rsk.trie.TrieImplHashTest) Test(org.junit.Test)

Example 32 with RskAddress

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

the class RepositoryImplTest method getAccountsKeys.

@Test
public void getAccountsKeys() {
    RskAddress accAddress1 = randomAccountAddress();
    RskAddress accAddress2 = randomAccountAddress();
    RepositoryImpl repository = new RepositoryImpl(config);
    repository.createAccount(accAddress1);
    repository.createAccount(accAddress2);
    Set<RskAddress> keys = repository.getAccountsKeys();
    Assert.assertNotNull(keys);
    Assert.assertFalse(keys.isEmpty());
    Assert.assertEquals(2, keys.size());
}
Also used : RskAddress(co.rsk.core.RskAddress) TrieImplHashTest(co.rsk.trie.TrieImplHashTest) Test(org.junit.Test)

Example 33 with RskAddress

use of co.rsk.core.RskAddress 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);
}
Also used : RskAddress(co.rsk.core.RskAddress) DataWord(org.ethereum.vm.DataWord) TrieImplHashTest(co.rsk.trie.TrieImplHashTest) Test(org.junit.Test)

Example 34 with RskAddress

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

the class RepositoryImplTest method incrementAccountBalanceForNewAccount.

@Test
public void incrementAccountBalanceForNewAccount() {
    RskAddress accAddress = randomAccountAddress();
    RepositoryImpl repository = new RepositoryImpl(config);
    Assert.assertEquals(BigInteger.ONE, repository.addBalance(accAddress, Coin.valueOf(1L)).asBigInteger());
    Assert.assertEquals(BigInteger.ONE, repository.getBalance(accAddress).asBigInteger());
}
Also used : RskAddress(co.rsk.core.RskAddress) TrieImplHashTest(co.rsk.trie.TrieImplHashTest) Test(org.junit.Test)

Example 35 with RskAddress

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

the class RepositoryImplTest method getCodeFromAccountWithoutCode.

@Test
public void getCodeFromAccountWithoutCode() {
    RskAddress accAddress = randomAccountAddress();
    RepositoryImpl repository = new RepositoryImpl(config);
    repository.createAccount(accAddress);
    byte[] code = repository.getCode(accAddress);
    Assert.assertNotNull(code);
    Assert.assertEquals(0, code.length);
}
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