Fixed tests and updated dependencies

This commit is contained in:
Christian Basler 2018-04-03 22:11:37 +02:00
parent 49e77199b0
commit f374748f71
4 changed files with 35 additions and 22 deletions

View File

@ -14,8 +14,11 @@ if (project.hasProperty("project.configs")
//noinspection GroovyMissingReturnStatement
android {
compileSdkVersion 27
buildToolsVersion "26.0.2"
buildToolsVersion "27.0.3"
signingConfigs {
release
}
defaultConfig {
applicationId "ch.dissem.apps.${appName.toLowerCase()}"
minSdkVersion 19
@ -69,10 +72,11 @@ dependencies {
implementation "ch.dissem.jabit:jabit-core:$jabitVersion"
implementation "ch.dissem.jabit:jabit-networking:$jabitVersion"
implementation "ch.dissem.jabit:jabit-cryptography-spongy:$jabitVersion"
implementation "ch.dissem.jabit:jabit-extensions:$jabitVersion"
implementation "ch.dissem.jabit:jabit-wif:$jabitVersion"
implementation "ch.dissem.jabit:jabit-exports:$jabitVersion"
implementation "ch.dissem.jabit:jabit-cryptography-spongy:$jabitVersion"
testImplementation "ch.dissem.jabit:jabit-cryptography-bouncy:$jabitVersion"
implementation 'org.slf4j:slf4j-android:1.7.25'

View File

@ -21,7 +21,7 @@ import ch.dissem.apps.abit.repository.AndroidAddressRepository
import ch.dissem.apps.abit.repository.AndroidLabelRepository
import ch.dissem.apps.abit.repository.AndroidMessageRepository
import ch.dissem.apps.abit.repository.SqlHelper
import ch.dissem.bitmessage.cryptography.sc.SpongyCryptography
import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography
import ch.dissem.bitmessage.entity.BitmessageAddress
import ch.dissem.bitmessage.entity.ObjectMessage
import ch.dissem.bitmessage.entity.Plaintext
@ -69,7 +69,7 @@ class AndroidMessageRepositoryTest : TestBase() {
val labelRepo = AndroidLabelRepository(sqlHelper, RuntimeEnvironment.application)
repo = AndroidMessageRepository(sqlHelper)
mockedInternalContext(
cryptography = SpongyCryptography(),
cryptography = BouncyCryptography(),
addressRepository = addressRepo,
labelRepository = labelRepo,
messageRepository = repo,

View File

@ -59,7 +59,6 @@ class AndroidProofOfWorkRepositoryTest : TestBase() {
fun setUp() {
RuntimeEnvironment.application.deleteDatabase(SqlHelper.DATABASE_NAME)
val sqlHelper = SqlHelper(RuntimeEnvironment.application)
addressRepo = AndroidAddressRepository(sqlHelper)
messageRepo = AndroidMessageRepository(sqlHelper)
repo = AndroidProofOfWorkRepository(sqlHelper)
@ -94,12 +93,14 @@ class AndroidProofOfWorkRepositoryTest : TestBase() {
messageRepo.save(plaintext)
plaintext.ackMessage!!.let { ackMessage ->
initialHash2 = cryptography().getInitialHash(ackMessage)
repo.putObject(ProofOfWorkRepository.Item(
objectMessage = ackMessage,
nonceTrialsPerByte = 1000, extraBytes = 1000,
expirationTime = UnixTime.now + 10 * UnixTime.MINUTE,
message = plaintext
))
repo.putObject(
ProofOfWorkRepository.Item(
objectMessage = ackMessage,
nonceTrialsPerByte = 1000, extraBytes = 1000,
expirationTime = UnixTime.now + 10 * UnixTime.MINUTE,
message = plaintext
)
)
}
}
@ -132,13 +133,15 @@ class AndroidProofOfWorkRepositoryTest : TestBase() {
.build()
messageRepo.save(plaintext)
plaintext.ackMessage!!.let { ackMessage ->
repo.putObject(ProofOfWorkRepository.Item(
objectMessage = ackMessage,
nonceTrialsPerByte = 1000,
extraBytes = 1000,
expirationTime = UnixTime.now + 10 * UnixTime.MINUTE,
message = plaintext
))
repo.putObject(
ProofOfWorkRepository.Item(
objectMessage = ackMessage,
nonceTrialsPerByte = 1000,
extraBytes = 1000,
expirationTime = UnixTime.now + 10 * UnixTime.MINUTE,
message = plaintext
)
)
}
assertThat(repo.getItems().size, `is`(sizeBefore + 1))
}
@ -147,7 +150,10 @@ class AndroidProofOfWorkRepositoryTest : TestBase() {
fun `ensure item can be retrieved`() {
val item = repo.getItem(initialHash1)
assertThat(item, notNullValue())
assertThat<ObjectPayload>(item.objectMessage.payload, instanceOf<ObjectPayload>(GetPubkey::class.java))
assertThat<ObjectPayload>(
item.objectMessage.payload,
instanceOf<ObjectPayload>(GetPubkey::class.java)
)
assertThat(item.nonceTrialsPerByte, `is`(1000L))
assertThat(item.extraBytes, `is`(1000L))
}
@ -156,7 +162,10 @@ class AndroidProofOfWorkRepositoryTest : TestBase() {
fun `ensure ack item can be retrieved`() {
val item = repo.getItem(initialHash2)
assertThat(item, notNullValue())
assertThat<ObjectPayload>(item.objectMessage.payload, instanceOf<ObjectPayload>(GenericPayload::class.java))
assertThat<ObjectPayload>(
item.objectMessage.payload,
instanceOf<ObjectPayload>(GenericPayload::class.java)
)
assertThat(item.nonceTrialsPerByte, `is`(1000L))
assertThat(item.extraBytes, `is`(1000L))
assertThat(item.expirationTime, not<Number>(0))

View File

@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.2.30'
ext.kotlin_version = '1.2.31'
ext.anko_version = '0.10.4'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'