Search in sources :

Example 11 with Block

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

the class TestDBH2 method test002getFullBlockFromHash.

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

Example 12 with Block

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

the class TestDBH2 method test007putAndGetFullBlockFromHash.

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

Example 13 with Block

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

the class TestDBMapDb method test005putAndGetFullBlockFromHeight.

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

Example 14 with Block

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

the class TestDBMapDb method test002getFullBlockFromHash.

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

Example 15 with Block

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

the class TestDBMapDb method test009putAndGetHeaderOfBlockWithMaxIndex.

/**
 * test put, and getFullBlockFromHash.
 */
@Test
public void test009putAndGetHeaderOfBlockWithMaxIndex() {
    try (TestLocalControllerNode controller = getTestLocalControllerNode()) {
        final Block expectedBlock = MockUtil.getMockBlock003();
        controller.getBlockDb().put(true, GenesisBlockUtil.GENESIS_BLOCK);
        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)

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