From f374748f714147ed8b3ed369da7d699a7dcb8dff Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Tue, 3 Apr 2018 22:11:37 +0200 Subject: [PATCH] Fixed tests and updated dependencies --- app/build.gradle | 8 +++- .../AndroidMessageRepositoryTest.kt | 4 +- .../AndroidProofOfWorkRepositoryTest.kt | 41 +++++++++++-------- build.gradle | 4 +- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 41b9321..330ee5d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/app/src/test/java/ch/dissem/bitmessage/repository/AndroidMessageRepositoryTest.kt b/app/src/test/java/ch/dissem/bitmessage/repository/AndroidMessageRepositoryTest.kt index ead5c9d..de5acd2 100644 --- a/app/src/test/java/ch/dissem/bitmessage/repository/AndroidMessageRepositoryTest.kt +++ b/app/src/test/java/ch/dissem/bitmessage/repository/AndroidMessageRepositoryTest.kt @@ -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, diff --git a/app/src/test/java/ch/dissem/bitmessage/repository/AndroidProofOfWorkRepositoryTest.kt b/app/src/test/java/ch/dissem/bitmessage/repository/AndroidProofOfWorkRepositoryTest.kt index 5c06974..a86baa7 100644 --- a/app/src/test/java/ch/dissem/bitmessage/repository/AndroidProofOfWorkRepositoryTest.kt +++ b/app/src/test/java/ch/dissem/bitmessage/repository/AndroidProofOfWorkRepositoryTest.kt @@ -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(item.objectMessage.payload, instanceOf(GetPubkey::class.java)) + assertThat( + item.objectMessage.payload, + instanceOf(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(item.objectMessage.payload, instanceOf(GenericPayload::class.java)) + assertThat( + item.objectMessage.payload, + instanceOf(GenericPayload::class.java) + ) assertThat(item.nonceTrialsPerByte, `is`(1000L)) assertThat(item.extraBytes, `is`(1000L)) assertThat(item.expirationTime, not(0)) diff --git a/build.gradle b/build.gradle index bcaecb5..ed23df1 100644 --- a/build.gradle +++ b/build.gradle @@ -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'