Search in sources :

Example 1 with AccountBuilder

use of co.rsk.test.builders.AccountBuilder in project rskj by rsksmart.

the class AddressesTopicsFilterTest method matchAddress.

@Test
public void matchAddress() {
    Account account = new AccountBuilder().name("account").build();
    RskAddress address = account.getAddress();
    AddressesTopicsFilter filter = new AddressesTopicsFilter(new RskAddress[] { address }, null);
    Assert.assertTrue(filter.matchesContractAddress(address));
    Assert.assertFalse(filter.matchesContractAddress(RskAddress.nullAddress()));
}
Also used : Account(org.ethereum.core.Account) RskAddress(co.rsk.core.RskAddress) AccountBuilder(co.rsk.test.builders.AccountBuilder) Test(org.junit.Test)

Example 2 with AccountBuilder

use of co.rsk.test.builders.AccountBuilder in project rskj by rsksmart.

the class AddressesTopicsFilterTest method matchAllBloomWithFilterWithAccount.

@Test
public void matchAllBloomWithFilterWithAccount() {
    Account account = new AccountBuilder().name("account").build();
    RskAddress address = account.getAddress();
    AddressesTopicsFilter filter = new AddressesTopicsFilter(new RskAddress[] { address }, null);
    Assert.assertTrue(filter.matchBloom(getAllBloom()));
}
Also used : Account(org.ethereum.core.Account) RskAddress(co.rsk.core.RskAddress) AccountBuilder(co.rsk.test.builders.AccountBuilder) Test(org.junit.Test)

Example 3 with AccountBuilder

use of co.rsk.test.builders.AccountBuilder in project rskj by rsksmart.

the class AddressesTopicsFilterTest method noMatchEmptyBloomWithFilterWithAccount.

@Test
public void noMatchEmptyBloomWithFilterWithAccount() {
    Account account = new AccountBuilder().name("account").build();
    RskAddress address = account.getAddress();
    AddressesTopicsFilter filter = new AddressesTopicsFilter(new RskAddress[] { address }, null);
    Assert.assertFalse(filter.matchBloom(new Bloom()));
}
Also used : Account(org.ethereum.core.Account) Bloom(org.ethereum.core.Bloom) RskAddress(co.rsk.core.RskAddress) AccountBuilder(co.rsk.test.builders.AccountBuilder) Test(org.junit.Test)

Example 4 with AccountBuilder

use of co.rsk.test.builders.AccountBuilder in project rskj by rsksmart.

the class PendingTransactionFilterTest method twoTransactionsAndEvents.

@Test
public void twoTransactionsAndEvents() {
    PendingTransactionFilter filter = new PendingTransactionFilter();
    Account sender = new AccountBuilder().name("sender").build();
    Account receiver = new AccountBuilder().name("receiver").build();
    Transaction tx1 = new TransactionBuilder().sender(sender).receiver(receiver).value(BigInteger.TEN).build();
    Transaction tx2 = new TransactionBuilder().sender(sender).receiver(receiver).value(BigInteger.ONE).build();
    filter.newPendingTx(tx1);
    filter.newPendingTx(tx2);
    Object[] result = filter.getEvents();
    Assert.assertNotNull(result);
    Assert.assertEquals(2, result.length);
    Assert.assertEquals("0x" + tx1.getHash().toHexString(), result[0]);
    Assert.assertEquals("0x" + tx2.getHash().toHexString(), result[1]);
}
Also used : Account(org.ethereum.core.Account) Transaction(org.ethereum.core.Transaction) TransactionBuilder(co.rsk.test.builders.TransactionBuilder) AccountBuilder(co.rsk.test.builders.AccountBuilder) Test(org.junit.Test)

Example 5 with AccountBuilder

use of co.rsk.test.builders.AccountBuilder in project rskj by rsksmart.

the class PendingTransactionFilterTest method oneTransactionAndEvents.

@Test
public void oneTransactionAndEvents() {
    PendingTransactionFilter filter = new PendingTransactionFilter();
    Account sender = new AccountBuilder().name("sender").build();
    Account receiver = new AccountBuilder().name("receiver").build();
    Transaction tx = new TransactionBuilder().sender(sender).receiver(receiver).value(BigInteger.TEN).build();
    filter.newPendingTx(tx);
    Object[] result = filter.getEvents();
    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.length);
    Assert.assertEquals("0x" + tx.getHash().toHexString(), result[0]);
}
Also used : Account(org.ethereum.core.Account) Transaction(org.ethereum.core.Transaction) TransactionBuilder(co.rsk.test.builders.TransactionBuilder) AccountBuilder(co.rsk.test.builders.AccountBuilder) Test(org.junit.Test)

Aggregations

AccountBuilder (co.rsk.test.builders.AccountBuilder)49 Test (org.junit.Test)37 World (co.rsk.test.World)33 BlockBuilder (co.rsk.test.builders.BlockBuilder)26 TransactionBuilder (co.rsk.test.builders.TransactionBuilder)24 Account (org.ethereum.core.Account)14 TransactionPoolImpl (co.rsk.core.bc.TransactionPoolImpl)13 ArrayList (java.util.ArrayList)12 BlockChainImpl (co.rsk.core.bc.BlockChainImpl)10 SimpleEthereum (org.ethereum.rpc.Simples.SimpleEthereum)8 Transaction (org.ethereum.core.Transaction)7 TransactionResultDTO (org.ethereum.rpc.dto.TransactionResultDTO)5 BigInteger (java.math.BigInteger)4 HashMapDB (org.ethereum.datasource.HashMapDB)4 ReceiptStore (org.ethereum.db.ReceiptStore)4 ReceiptStoreImpl (org.ethereum.db.ReceiptStoreImpl)4 RskAddress (co.rsk.core.RskAddress)3 Coin (co.rsk.core.Coin)2 TransactionReceiptDTO (org.ethereum.rpc.dto.TransactionReceiptDTO)2 TestContract (co.rsk.util.TestContract)1