Search in sources :

Example 56 with Block

use of neo.model.core.Block in project neo-java by coranos.

the class TestDBH2 method test009putAndGetHeaderOfBlockWithMaxIndex.

/**
 * test put, and getFullBlockFromHash.
 */
@Test
public void test009putAndGetHeaderOfBlockWithMaxIndex() {
    try (TestLocalControllerNode controller = getTestLocalControllerNode()) {
        final Block expectedBlock = MockUtil.getMockBlock001();
        controller.getBlockDb().put(true, expectedBlock);
        expectedBlock.getTransactionList().clear();
        final Block actualBlock = controller.getBlockDb().getHeaderOfBlockWithMaxIndex();
        Assert.assertEquals("blocks should match.", expectedBlock.toString(), actualBlock.toString());
    }
}
Also used : Block(neo.model.core.Block) Test(org.junit.Test)

Example 57 with Block

use of neo.model.core.Block in project neo-java by coranos.

the class TestDBH2 method test004getHeaderOfBlockWithMaxIndex.

/**
 * test getHeaderOfBlockWithMaxIndex.
 */
@Test
public void test004getHeaderOfBlockWithMaxIndex() {
    try (TestLocalControllerNode controller = getTestLocalControllerNode()) {
        final Block actual = controller.getBlockDb().getHeaderOfBlockWithMaxIndex();
        Assert.assertEquals("getHeaderOfBlockWithMaxIndex should return null with empty db.", null, actual);
    }
}
Also used : Block(neo.model.core.Block) Test(org.junit.Test)

Example 58 with Block

use of neo.model.core.Block in project neo-java by coranos.

the class TestDBH2 method test005putAndGetFullBlockFromHeight.

/**
 * test put, and getFullBlockFromHeight.
 */
@Test
public void test005putAndGetFullBlockFromHeight() {
    try (TestLocalControllerNode controller = getTestLocalControllerNode()) {
        final Block expectedBlock = MockUtil.getMockBlock001();
        controller.getBlockDb().put(true, expectedBlock);
        final Block actualBlock = controller.getBlockDb().getFullBlockFromHeight(0);
        Assert.assertEquals("blocks should match.", expectedBlock.toString(), actualBlock.toString());
    }
}
Also used : Block(neo.model.core.Block) Test(org.junit.Test)

Example 59 with Block

use of neo.model.core.Block in project neo-java by coranos.

the class TestDBH2 method test010putAndGetHeaderOfBlockFromHeight.

/**
 * test put, and getHeaderOfBlockFromHeight.
 */
@Test
public void test010putAndGetHeaderOfBlockFromHeight() {
    try (TestLocalControllerNode controller = getTestLocalControllerNode()) {
        final Block expectedBlock = MockUtil.getMockBlock001();
        controller.getBlockDb().put(true, expectedBlock);
        expectedBlock.getTransactionList().clear();
        final Block actualBlock = controller.getBlockDb().getHeaderOfBlockFromHeight(0);
        Assert.assertEquals("blocks should match.", expectedBlock.toString(), actualBlock.toString());
    }
}
Also used : Block(neo.model.core.Block) Test(org.junit.Test)

Example 60 with Block

use of neo.model.core.Block in project neo-java by coranos.

the class TestDBH2 method test011putAndGetHeaderOfBlockFromHash.

/**
 * test put, and getHeaderOfBlockFromHash.
 */
@Test
public void test011putAndGetHeaderOfBlockFromHash() {
    try (TestLocalControllerNode controller = getTestLocalControllerNode()) {
        final Block expectedBlock = MockUtil.getMockBlock001();
        controller.getBlockDb().put(true, expectedBlock);
        expectedBlock.getTransactionList().clear();
        final Block actualBlock = controller.getBlockDb().getHeaderOfBlockFromHash(expectedBlock.hash);
        Assert.assertEquals("blocks should match.", expectedBlock.toString(), actualBlock.toString());
    }
}
Also used : Block(neo.model.core.Block) Test(org.junit.Test)

Aggregations

Block (neo.model.core.Block)65 Test (org.junit.Test)26 Transaction (neo.model.core.Transaction)25 JSONObject (org.json.JSONObject)24 JSONArray (org.json.JSONArray)16 TransactionOutput (neo.model.core.TransactionOutput)9 BlockDb (neo.model.db.BlockDb)9 IOException (java.io.IOException)8 TreeMap (java.util.TreeMap)8 UInt256 (neo.model.bytes.UInt256)8 LocalNodeData (neo.network.model.LocalNodeData)6 Fixed8 (neo.model.bytes.Fixed8)5 Timestamp (java.sql.Timestamp)4 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 TreeSet (java.util.TreeSet)4 OutputStream (java.io.OutputStream)3 SQLException (java.sql.SQLException)3 UInt160 (neo.model.bytes.UInt160)3 UInt32 (neo.model.bytes.UInt32)3