Search in sources :

Example 11 with IByteArrayKeyValueDatabase

use of org.aion.base.db.IByteArrayKeyValueDatabase in project aion by aionnetwork.

the class AccessWithExceptionTest method testPutBatchWithClosedDatabase.

@Test(expected = RuntimeException.class)
@Parameters(method = "databaseInstanceDefinitions")
public void testPutBatchWithClosedDatabase(Properties dbDef) {
    // create database
    dbDef.setProperty("db_name", DatabaseTestUtils.dbName + DatabaseTestUtils.getNext());
    IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
    assertThat(db.isOpen()).isFalse();
    Map<byte[], byte[]> map = new HashMap<>();
    map.put(DatabaseTestUtils.randomBytes(32), DatabaseTestUtils.randomBytes(32));
    map.put(DatabaseTestUtils.randomBytes(32), DatabaseTestUtils.randomBytes(32));
    map.put(DatabaseTestUtils.randomBytes(32), DatabaseTestUtils.randomBytes(32));
    // attempt putBatch on closed db
    db.putBatch(map);
}
Also used : IByteArrayKeyValueDatabase(org.aion.base.db.IByteArrayKeyValueDatabase) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 12 with IByteArrayKeyValueDatabase

use of org.aion.base.db.IByteArrayKeyValueDatabase in project aion by aionnetwork.

the class AccessWithExceptionTest method testPutWithNullKey.

@Test(expected = IllegalArgumentException.class)
@Parameters(method = "databaseInstanceDefinitions")
public void testPutWithNullKey(Properties dbDef) {
    // create database
    dbDef.setProperty("db_name", DatabaseTestUtils.dbName + DatabaseTestUtils.getNext());
    IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
    assertThat(db.open()).isTrue();
    // attempt put with null key
    db.put(null, DatabaseTestUtils.randomBytes(32));
}
Also used : IByteArrayKeyValueDatabase(org.aion.base.db.IByteArrayKeyValueDatabase) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 13 with IByteArrayKeyValueDatabase

use of org.aion.base.db.IByteArrayKeyValueDatabase in project aion by aionnetwork.

the class AccessWithExceptionTest method testDeleteWithClosedDatabase.

@Test(expected = RuntimeException.class)
@Parameters(method = "databaseInstanceDefinitions")
public void testDeleteWithClosedDatabase(Properties dbDef) {
    // create database
    dbDef.setProperty("db_name", DatabaseTestUtils.dbName + DatabaseTestUtils.getNext());
    IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
    assertThat(db.isOpen()).isFalse();
    // attempt delete on closed db
    db.delete(DatabaseTestUtils.randomBytes(32));
}
Also used : IByteArrayKeyValueDatabase(org.aion.base.db.IByteArrayKeyValueDatabase) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 14 with IByteArrayKeyValueDatabase

use of org.aion.base.db.IByteArrayKeyValueDatabase in project aion by aionnetwork.

the class AccessWithExceptionTest method testPutBatchWithNullKey.

@Test(expected = IllegalArgumentException.class)
@Parameters(method = "databaseInstanceDefinitions")
public void testPutBatchWithNullKey(Properties dbDef) {
    // create database
    dbDef.setProperty("db_name", DatabaseTestUtils.dbName + DatabaseTestUtils.getNext());
    IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
    assertThat(db.open()).isTrue();
    Map<byte[], byte[]> map = new HashMap<>();
    map.put(DatabaseTestUtils.randomBytes(32), DatabaseTestUtils.randomBytes(32));
    map.put(DatabaseTestUtils.randomBytes(32), DatabaseTestUtils.randomBytes(32));
    map.put(null, DatabaseTestUtils.randomBytes(32));
    // attempt putBatch on closed db
    db.putBatch(map);
}
Also used : IByteArrayKeyValueDatabase(org.aion.base.db.IByteArrayKeyValueDatabase) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 15 with IByteArrayKeyValueDatabase

use of org.aion.base.db.IByteArrayKeyValueDatabase in project aion by aionnetwork.

the class AccessWithExceptionTest method testDeleteBatchWithNullKey.

@Test(expected = IllegalArgumentException.class)
@Parameters(method = "databaseInstanceDefinitions")
public void testDeleteBatchWithNullKey(Properties dbDef) {
    // create database
    dbDef.setProperty("db_name", DatabaseTestUtils.dbName + DatabaseTestUtils.getNext());
    IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
    assertThat(db.open()).isTrue();
    List<byte[]> list = new ArrayList<>();
    list.add(DatabaseTestUtils.randomBytes(32));
    list.add(DatabaseTestUtils.randomBytes(32));
    list.add(null);
    // attempt deleteBatch on closed db
    db.deleteBatch(list);
}
Also used : IByteArrayKeyValueDatabase(org.aion.base.db.IByteArrayKeyValueDatabase) Parameters(junitparams.Parameters) Test(org.junit.Test)

Aggregations

IByteArrayKeyValueDatabase (org.aion.base.db.IByteArrayKeyValueDatabase)26 Test (org.junit.Test)24 Parameters (junitparams.Parameters)18 ArrayList (java.util.ArrayList)3 ImportResult (org.aion.mcf.core.ImportResult)3 TrieImpl (org.aion.mcf.trie.TrieImpl)3 AionBlock (org.aion.zero.impl.types.AionBlock)3 HashMap (java.util.HashMap)2 Address (org.aion.base.type.Address)2 DataWord (org.aion.mcf.vm.types.DataWord)2 AionContractDetailsImpl (org.aion.zero.db.AionContractDetailsImpl)2 AionRepositoryImpl (org.aion.zero.impl.db.AionRepositoryImpl)2 Properties (java.util.Properties)1 IContractDetails (org.aion.base.db.IContractDetails)1 MockDBDriver (org.aion.db.impl.mockdb.MockDBDriver)1