-
Notifications
You must be signed in to change notification settings - Fork 9
Test/db module tests #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eustimenko
wants to merge
47
commits into
develop
Choose a base branch
from
test/db-module-tests
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Test/db module tests #164
Changes from 3 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
5e4a41f
InMemoryDatabase: property tests
eustimenko a8cc578
XorKeyDatabase: property tests
eustimenko a23e3b1
WritableCacheImpl: property tests
eustimenko d0d232e
WritableCacheImpl/DelegateDataSourceTest
eustimenko 8545359
HashMapHoleyListTest
eustimenko 1913308
LinkedDataSourceTest
eustimenko 00fd312
DataSourceListTest
eustimenko a9283d2
Fix after code review
eustimenko 4c0cb48
XorDataSourceTest
eustimenko 045421e
AbstractLinkedDataSourceTest
eustimenko 9384595
HoleyListTest
eustimenko f6f2b31
Merge branch 'develop' into test/db-module-tests
eustimenko fcd0997
Remove WriteCacheImplTest
eustimenko d519fee
Avoid unnecessary merklisation of initial deposits (#171)
mkalinin 9a4aac2
JUnit5 and db tests
eustimenko b1b898e
SingleValueSourceTest/AutoclosableLockTest
eustimenko 0112d23
Merge branch 'develop' into test/db-module-tests
eustimenko 0739114
CacheSizeEvaluatorImplTest
eustimenko 9ba3288
DatabaseFlusherTest
eustimenko 352f9cb
InstantFlusherTest
eustimenko 7ef7ee2
Refactor tests
eustimenko 7023717
test: add BufferSizeObserverTest. Exclude junit4 from db project depe…
eustimenko 452ffa1
test: add param tests to BufferSizeObserverTest
eustimenko 9d4d65d
test: TransactionalDataSourceTest, WriteBufferTest, HashMapDataSource…
eustimenko 44a569a
test: add parameters into tests
eustimenko ac23ca6
test: BatchUpdateDataSourceTest/CacheDataSourceTest/CacheSizeEvaluato…
eustimenko 22b2e1e
test: fix after review
eustimenko 9f0ccfc
test: add non-null checking into BufferSizeObserver
eustimenko e1db551
test: add flush test into BufferSizeObserver
eustimenko 0882595
test: add junit5 into gradle
eustimenko ab80471
test: replace junit4 with junit5 in java code
eustimenko 173a95c
test: db/core/src/test/java/org/ethereum/beacon/db/DatabaseTest
eustimenko 01478a7
test: db/core/src/test/java/org/ethereum/beacon/db/DatabaseTest
eustimenko 0f07f8d
test: add junit4 dependency into test module
eustimenko 2b935f6
test: fix junit 4/5 dependencies
eustimenko 042ee95
Community tests updated to be in line with develop
zilm13 aac0059
test: reformat code
eustimenko 01e17cb
test: update subproject
eustimenko 4fdb06d
test: fix DatabaseTest after code review
eustimenko 23994a6
test: fix DatabaseTest after code review
eustimenko 29245fb
test: delete directories
eustimenko 355bc81
test: add relative directories
eustimenko b2a8186
test: add additional test for Database
eustimenko faa259a
test: fix after merge
eustimenko 2ebabd0
test: correct InMemoryDatabaseTest
eustimenko 9ffb987
test: correct InMemoryDatabaseTest
eustimenko 93cbead
test: temp commit
eustimenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| dependencies { | ||
| api project(':types') | ||
|
|
||
| testImplementation 'com.pholser:junit-quickcheck-core:0.7' | ||
| testImplementation 'ru.vyarus:generics-resolver:3.0.0' | ||
| } |
19 changes: 19 additions & 0 deletions
19
db/core/src/test/java/org/ethereum/beacon/db/InMemoryDatabaseTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package org.ethereum.beacon.db; | ||
|
|
||
| import com.pholser.junit.quickcheck.Property; | ||
| import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; | ||
| import org.ethereum.beacon.db.source.impl.HashMapDataSource; | ||
| import org.junit.runner.RunWith; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| @RunWith(JUnitQuickcheck.class) | ||
| public class InMemoryDatabaseTest { | ||
|
|
||
| @Property | ||
| public void getBackingDataSource() { | ||
| final InMemoryDatabase database = new InMemoryDatabase(); | ||
| assertThat(database.getBackingDataSource()).isNotNull(); | ||
| assertThat(database.getBackingDataSource()).isInstanceOf(HashMapDataSource.class); | ||
| } | ||
| } |
63 changes: 63 additions & 0 deletions
63
db/core/src/test/java/org/ethereum/beacon/db/XorKeyDatabaseTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package org.ethereum.beacon.db; | ||
|
|
||
| import com.pholser.junit.quickcheck.*; | ||
| import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; | ||
| import org.ethereum.beacon.db.configuration.*; | ||
| import org.ethereum.beacon.db.source.DataSource; | ||
| import org.ethereum.beacon.db.source.impl.XorDataSource; | ||
| import org.junit.runner.RunWith; | ||
| import tech.pegasys.artemis.util.bytes.BytesValue; | ||
|
|
||
| import java.util.function.Function; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| @RunWith(JUnitQuickcheck.class) | ||
| public class XorKeyDatabaseTest { | ||
|
|
||
| private final String TEST_STORAGE_NAME = "TEST_STORAGE_NAME"; | ||
| private final String TEST_ENTITY_KEY = "TEST_ENTITY_KEY"; | ||
|
|
||
| @Property | ||
| public void createStorage(@From(HashMapDatasourceGenerator.class) DataSource<@From(EmptyBytesValueGenerator.class) BytesValue, @From(EmptyBytesValueGenerator.class) BytesValue> backingDataSource, | ||
| @From(EmptyFunctionGenerator.class) Function<@From(EmptyBytesValueGenerator.class) BytesValue, @From(EmptyBytesValueGenerator.class) BytesValue> sourceNameHasher) { | ||
|
|
||
| final XorKeyDatabase database = new XorKeyDatabase(backingDataSource, sourceNameHasher) { | ||
| @Override | ||
| public void commit() { | ||
| } | ||
|
|
||
| @Override | ||
| public void close() { | ||
| } | ||
| }; | ||
|
|
||
| final DataSource<BytesValue, BytesValue> actual = database.createStorage(TEST_STORAGE_NAME); | ||
| assertThat(actual).isNotNull(); | ||
| assertThat(actual).isInstanceOf(XorDataSource.class); | ||
|
|
||
| final BytesValue key = BytesValue.wrap(TEST_ENTITY_KEY.getBytes()); | ||
| final BytesValue value = BytesValue.EMPTY; | ||
| actual.put(key, value); | ||
| assertThat(actual.get(key)).isPresent().hasValue(value); | ||
| } | ||
|
|
||
| @Property | ||
| public void getBackingDataSource(@From(HashMapDatasourceGenerator.class) DataSource<@From(EmptyBytesValueGenerator.class) BytesValue, @From(EmptyBytesValueGenerator.class) BytesValue> backingDataSource, | ||
| @From(EmptyFunctionGenerator.class) Function<@From(EmptyBytesValueGenerator.class) BytesValue, @From(EmptyBytesValueGenerator.class) BytesValue> sourceNameHasher) { | ||
|
|
||
| final XorKeyDatabase actual = new XorKeyDatabase(backingDataSource, sourceNameHasher) { | ||
| @Override | ||
| public void commit() { | ||
| } | ||
|
|
||
| @Override | ||
| public void close() { | ||
| } | ||
| }; | ||
|
|
||
| assertThat(actual).isNotNull(); | ||
| assertThat(actual.getBackingDataSource()).isNotNull(); | ||
| assertThat(actual.getBackingDataSource()).isEqualTo(backingDataSource); | ||
| } | ||
| } | ||
16 changes: 16 additions & 0 deletions
16
db/core/src/test/java/org/ethereum/beacon/db/configuration/EmptyBytesValueGenerator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package org.ethereum.beacon.db.configuration; | ||
|
|
||
| import com.pholser.junit.quickcheck.generator.*; | ||
|
||
| import com.pholser.junit.quickcheck.random.SourceOfRandomness; | ||
| import tech.pegasys.artemis.util.bytes.BytesValue; | ||
|
|
||
| public class EmptyBytesValueGenerator extends Generator<BytesValue> { | ||
| public EmptyBytesValueGenerator() { | ||
| super(BytesValue.class); | ||
| } | ||
|
|
||
| @Override | ||
| public BytesValue generate(SourceOfRandomness random, GenerationStatus status) { | ||
| return BytesValue.EMPTY; | ||
| } | ||
| } | ||
17 changes: 17 additions & 0 deletions
17
db/core/src/test/java/org/ethereum/beacon/db/configuration/EmptyFunctionGenerator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package org.ethereum.beacon.db.configuration; | ||
|
|
||
| import com.pholser.junit.quickcheck.generator.*; | ||
| import com.pholser.junit.quickcheck.random.SourceOfRandomness; | ||
|
|
||
| import java.util.function.Function; | ||
|
|
||
| public class EmptyFunctionGenerator extends Generator<Function> { | ||
| public EmptyFunctionGenerator() { | ||
| super(Function.class); | ||
| } | ||
|
|
||
| @Override | ||
| public Function generate(SourceOfRandomness random, GenerationStatus status) { | ||
| return Function.identity(); | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
db/core/src/test/java/org/ethereum/beacon/db/configuration/HashMapDatasourceGenerator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package org.ethereum.beacon.db.configuration; | ||
|
|
||
| import com.pholser.junit.quickcheck.generator.*; | ||
| import com.pholser.junit.quickcheck.random.SourceOfRandomness; | ||
| import org.ethereum.beacon.db.source.DataSource; | ||
| import org.ethereum.beacon.db.source.impl.HashMapDataSource; | ||
|
|
||
| public class HashMapDatasourceGenerator extends Generator<DataSource> { | ||
| public HashMapDatasourceGenerator() { | ||
| super(DataSource.class); | ||
| } | ||
|
|
||
| @Override | ||
| public HashMapDataSource generate(SourceOfRandomness random, GenerationStatus status) { | ||
| return new HashMapDataSource(); | ||
| } | ||
| } |
26 changes: 26 additions & 0 deletions
26
db/core/src/test/java/org/ethereum/beacon/db/source/WriteCacheImplTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package org.ethereum.beacon.db.source; | ||
|
|
||
| import com.pholser.junit.quickcheck.*; | ||
| import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; | ||
| import org.ethereum.beacon.db.configuration.HashMapDatasourceGenerator; | ||
| import org.junit.runner.RunWith; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| @RunWith(JUnitQuickcheck.class) | ||
| public class WriteCacheImplTest { | ||
|
|
||
| private final String TEST_ENTITY_KEY = "TEST_ENTITY_KEY"; | ||
|
|
||
| @Property | ||
| public void get(@From(HashMapDatasourceGenerator.class) DataSource dataSource) { | ||
| final CacheDataSource<String, String> cacheDataSource = new WriteCacheImpl<String, String>(dataSource); | ||
| assertThat(cacheDataSource.get(TEST_ENTITY_KEY)).isNotPresent(); | ||
| } | ||
|
|
||
| @Property | ||
| public void getCacheEntry(@From(HashMapDatasourceGenerator.class) DataSource dataSource) { | ||
| final CacheDataSource<String, String> cacheDataSource = new WriteCacheImpl<String, String>(dataSource); | ||
| assertThat(cacheDataSource.get(TEST_ENTITY_KEY)).isNotPresent(); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.