Search in sources :

Example 1 with TransactionRequester

use of com.iota.iri.network.TransactionRequester in project iri by iotaledger.

the class TransactionValidatorTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    dbFolder.create();
    logFolder.create();
    tangle = new Tangle();
    tangle.addPersistenceProvider(new RocksDBPersistenceProvider(dbFolder.getRoot().getAbsolutePath(), logFolder.getRoot().getAbsolutePath(), 1000));
    tangle.init();
    TipsViewModel tipsViewModel = new TipsViewModel();
    MessageQ messageQ = new MessageQ(0, "", 0, false);
    TransactionRequester txRequester = new TransactionRequester(tangle, messageQ);
    txValidator = new TransactionValidator(tangle, tipsViewModel, txRequester, messageQ);
    txValidator.init(false, MAINNET_MWM, TESTNET_MWM);
}
Also used : TransactionRequester(com.iota.iri.network.TransactionRequester) MessageQ(com.iota.iri.zmq.MessageQ) TipsViewModel(com.iota.iri.controllers.TipsViewModel) RocksDBPersistenceProvider(com.iota.iri.storage.rocksDB.RocksDBPersistenceProvider) Tangle(com.iota.iri.storage.Tangle) BeforeClass(org.junit.BeforeClass)

Example 2 with TransactionRequester

use of com.iota.iri.network.TransactionRequester in project iri by iotaledger.

the class TransactionRequesterTest method milestoneCapacityNotLimited.

@Test
public void milestoneCapacityNotLimited() throws Exception {
    TransactionRequester txReq = new TransactionRequester(tangle, mq);
    int capacity = TransactionRequester.MAX_TX_REQ_QUEUE_SIZE;
    // fill tips list
    for (int i = 0; i < capacity * 2; i++) {
        Hash hash = TransactionViewModelTest.getRandomTransactionHash();
        txReq.requestTransaction(hash, true);
    }
    // check that limit was surpassed
    assertEquals(capacity * 2, txReq.numberOfTransactionsToRequest());
}
Also used : TransactionRequester(com.iota.iri.network.TransactionRequester) Hash(com.iota.iri.model.Hash) Test(org.junit.Test)

Example 3 with TransactionRequester

use of com.iota.iri.network.TransactionRequester in project iri by iotaledger.

the class TransactionRequesterTest method mixedCapacityLimited.

@Test
public void mixedCapacityLimited() throws Exception {
    TransactionRequester txReq = new TransactionRequester(tangle, mq);
    int capacity = TransactionRequester.MAX_TX_REQ_QUEUE_SIZE;
    // fill tips list
    for (int i = 0; i < capacity * 4; i++) {
        Hash hash = TransactionViewModelTest.getRandomTransactionHash();
        txReq.requestTransaction(hash, (i % 2 == 1));
    }
    // check that limit wasn't breached
    assertEquals(capacity + capacity * 2, txReq.numberOfTransactionsToRequest());
}
Also used : TransactionRequester(com.iota.iri.network.TransactionRequester) Hash(com.iota.iri.model.Hash) Test(org.junit.Test)

Example 4 with TransactionRequester

use of com.iota.iri.network.TransactionRequester in project iri by iotaledger.

the class TipsManagerTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    tangle = new Tangle();
    dbFolder.create();
    logFolder.create();
    tangle.addPersistenceProvider(new RocksDBPersistenceProvider(dbFolder.getRoot().getAbsolutePath(), logFolder.getRoot().getAbsolutePath(), 1000));
    tangle.init();
    TipsViewModel tipsViewModel = new TipsViewModel();
    MessageQ messageQ = new MessageQ(0, null, 1, false);
    TransactionRequester transactionRequester = new TransactionRequester(tangle, messageQ);
    TransactionValidator transactionValidator = new TransactionValidator(tangle, tipsViewModel, transactionRequester, messageQ);
    Milestone milestone = new Milestone(tangle, Hash.NULL_HASH, Snapshot.initialSnapshot.clone(), transactionValidator, true, messageQ);
    LedgerValidator ledgerValidator = new LedgerValidator(tangle, milestone, transactionRequester, messageQ);
    tipsManager = new TipsManager(tangle, ledgerValidator, transactionValidator, tipsViewModel, milestone, 15, messageQ);
}
Also used : TransactionRequester(com.iota.iri.network.TransactionRequester) MessageQ(com.iota.iri.zmq.MessageQ) Milestone(com.iota.iri.Milestone) TransactionValidator(com.iota.iri.TransactionValidator) TipsViewModel(com.iota.iri.controllers.TipsViewModel) RocksDBPersistenceProvider(com.iota.iri.storage.rocksDB.RocksDBPersistenceProvider) Tangle(com.iota.iri.storage.Tangle) LedgerValidator(com.iota.iri.LedgerValidator) BeforeClass(org.junit.BeforeClass)

Example 5 with TransactionRequester

use of com.iota.iri.network.TransactionRequester in project iri by iotaledger.

the class TransactionRequesterTest method nonMilestoneCapacityLimited.

@Test
public void nonMilestoneCapacityLimited() throws Exception {
    TransactionRequester txReq = new TransactionRequester(tangle, mq);
    int capacity = TransactionRequester.MAX_TX_REQ_QUEUE_SIZE;
    // fill tips list
    for (int i = 0; i < capacity * 2; i++) {
        Hash hash = TransactionViewModelTest.getRandomTransactionHash();
        txReq.requestTransaction(hash, false);
    }
    // check that limit wasn't breached
    assertEquals(capacity, txReq.numberOfTransactionsToRequest());
}
Also used : TransactionRequester(com.iota.iri.network.TransactionRequester) Hash(com.iota.iri.model.Hash) Test(org.junit.Test)

Aggregations

TransactionRequester (com.iota.iri.network.TransactionRequester)5 Hash (com.iota.iri.model.Hash)3 Test (org.junit.Test)3 TipsViewModel (com.iota.iri.controllers.TipsViewModel)2 Tangle (com.iota.iri.storage.Tangle)2 RocksDBPersistenceProvider (com.iota.iri.storage.rocksDB.RocksDBPersistenceProvider)2 MessageQ (com.iota.iri.zmq.MessageQ)2 BeforeClass (org.junit.BeforeClass)2 LedgerValidator (com.iota.iri.LedgerValidator)1 Milestone (com.iota.iri.Milestone)1 TransactionValidator (com.iota.iri.TransactionValidator)1