Skip to content

Commit

Permalink
update scope sdk and provenance protos (#62)
Browse files Browse the repository at this point in the history
* update scope sdk and provenance protos

* fixing tests
  • Loading branch information
wbaker-figure authored Nov 22, 2023
1 parent 47dcbff commit 82f9d17
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion example/src/main/kotlin/CreateAndOnboardScope.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fun Message.toAny() = Any.pack(this, "")

fun main() {
val client = PbClient("pio-testnet-1", URI("grpcs://grpc.test.provenance.io:443"), GasEstimationMethod.MSG_FEE_CALCULATION)
val osClient = CachedOsClient(OsClient(URI("grpc://localhost:5005"), 30_000), 1, 1, 0)
val osClient = CachedOsClient(OsClient(URI("grpc://localhost:5005"), 30_000), 1, 1, 1, 1)

val scopeUuid = UUID.randomUUID()
val scopeAddress = MetadataAddress.forScope(scopeUuid).toString()
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ protobuf = "3.23.2"
provenance-blockapi = "0.2.1"
provenance-client = "1.3.0"
provenance-hdwallet = "0.1.15"
provenance-proto = "1.13.0"
provenance-scope = "0.4.9"
provenance-proto = "1.17.0"
provenance-scope = "0.7.0"
scarlet = "0.1.12"
springboot = "3.1.1"
sqlite = "3.42.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AppConfig {
fun objectStoreClient(objectStoreProperties: ObjectStoreProperties, provenanceProperties: ProvenanceProperties): CachedOsClient {
val osClient = OsClient(objectStoreProperties.uri, 30000)

return CachedOsClient(osClient, objectStoreProperties.decryptionWorkerThreads, objectStoreProperties.concurrencySize, objectStoreProperties.cacheRecordSizeBytes)
return CachedOsClient(osClient, objectStoreProperties.decryptionWorkerThreads, objectStoreProperties.concurrencySize, objectStoreProperties.cacheRecordSizeBytes, objectStoreProperties.cacheJarSizeBytes)
}

@Bean(BeanQualifiers.OBJECTSTORE_ENCRYPTION_KEYS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ data class ObjectStoreProperties @ConstructorBinding constructor(
val masterKey: String,
val decryptionWorkerThreads: Short = 10,
val concurrencySize: Short = 10,
val cacheRecordSizeBytes: Long = 10_000_000
val cacheRecordSizeBytes: Long = 10_000_000,
val cacheJarSizeBytes: Long = 1_000_000
)

@Validated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import tech.figure.objectstore.gateway.service.AddressVerificationService
import tech.figure.objectstore.gateway.service.ObjectService
import tech.figure.objectstore.gateway.service.ScopeFetchService
import tech.figure.objectstore.gateway.service.ScopePermissionsService
import java.io.InputStream
import java.net.URI
import java.security.KeyPair
import java.security.PublicKey
Expand Down Expand Up @@ -523,7 +524,7 @@ class ObjectStoreGatewayServerTest {
val objectBytes = Random.nextBytes(100)
val obj = objectFromParts(objectBytes, "some_type")
val byteHash = objectBytes.sha256String()
every { objectStoreClient.osClient.put(any(), any(), any(), any(), any(), any(), any(), any()).get().hash } returns byteHash.toByteString()
every { objectStoreClient.osClient.put(any<InputStream>(), any(), any(), any(), any(), any(), any(), any()).get().hash } returns byteHash.toByteString()
return objectService.putObject(
obj = obj,
requesterPublicKey = requester,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class ObjectServiceTest {
val objectHash = objectBytes.sha256String()

every { accountsRepository.isAddressEnabled(any()) } returns false
every { osClient.osClient.put(any(), masterKey.publicKey, any(), objectBytes.size.toLong(), setOf(masterKey.publicKey), mapOf(), any(), false) } returns Futures.immediateFuture(
every { osClient.osClient.put(any(), masterKey.publicKey, any(), objectBytes.size.toLong(), setOf(masterKey.publicKey), mapOf(), any(), true, false) } returns Futures.immediateFuture(
Objects.ObjectResponse.newBuilder().setHash(objectHash.base64Decode().toByteString()).build()
)

Expand All @@ -124,7 +124,7 @@ class ObjectServiceTest {

assertEquals(objectHash, response)
verifyAll {
osClient.osClient.put(any(), masterKey.publicKey, any(), objectBytes.size.toLong(), setOf(masterKey.publicKey), mapOf(), any(), false)
osClient.osClient.put(any(), masterKey.publicKey, any(), objectBytes.size.toLong(), setOf(masterKey.publicKey), mapOf(), any(), true, false)
objectPermissionsRepository.addAccessPermission(
objectHash = objectHash,
granterAddress = masterKeyAddress,
Expand All @@ -144,7 +144,7 @@ class ObjectServiceTest {

every { accountsRepository.isAddressEnabled(any()) } returns true

every { osClient.osClient.put(any(), masterKey.publicKey, any(), objectBytes.size.toLong(), setOf(ownerKey), mapOf(), any(), false) } returns Futures.immediateFuture(
every { osClient.osClient.put(any(), masterKey.publicKey, any(), objectBytes.size.toLong(), setOf(ownerKey), mapOf(), any(), true, false) } returns Futures.immediateFuture(
Objects.ObjectResponse.newBuilder().setHash(objectHash.base64Decode().toByteString()).build()
)

Expand All @@ -163,7 +163,7 @@ class ObjectServiceTest {

assertEquals(objectHash, response)
verifyAll {
osClient.osClient.put(any(), masterKey.publicKey, any(), objectBytes.size.toLong(), setOf(ownerKey), mapOf(), any(), false)
osClient.osClient.put(any(), masterKey.publicKey, any(), objectBytes.size.toLong(), setOf(ownerKey), mapOf(), any(), true, false)
objectPermissionsRepository.addAccessPermission(
objectHash = objectHash,
granterAddress = ownerKeyAddress,
Expand All @@ -183,7 +183,7 @@ class ObjectServiceTest {

every { accountsRepository.isAddressEnabled(any()) } returns true

every { osClient.osClient.put(any(), masterKey.publicKey, any(), objectBytes.size.toLong(), setOf(ownerKey), mapOf(), any(), false) } returns Futures.immediateFuture(
every { osClient.osClient.put(any(), masterKey.publicKey, any(), objectBytes.size.toLong(), setOf(ownerKey), mapOf(), any(), true, false) } returns Futures.immediateFuture(
Objects.ObjectResponse.newBuilder().setHash(objectHash.base64Decode().toByteString()).build()
)

Expand All @@ -202,7 +202,7 @@ class ObjectServiceTest {

assertEquals(objectHash, response)
verifyAll {
osClient.osClient.put(any(), masterKey.publicKey, any(), objectBytes.size.toLong(), setOf(ownerKey), mapOf(), any(), false)
osClient.osClient.put(any(), masterKey.publicKey, any(), objectBytes.size.toLong(), setOf(ownerKey), mapOf(), any(), true, false)
objectPermissionsRepository.addAccessPermission(
objectHash = objectHash,
granterAddress = ownerKeyAddress,
Expand All @@ -223,7 +223,7 @@ class ObjectServiceTest {

every { accountsRepository.isAddressEnabled(any()) } returns true

every { osClient.osClient.put(any(), masterKey.publicKey, any(), objectBytes.size.toLong(), setOf(ownerKey, otherKey), mapOf(), any(), false) } returns Futures.immediateFuture(
every { osClient.osClient.put(any(), masterKey.publicKey, any(), objectBytes.size.toLong(), setOf(ownerKey, otherKey), mapOf(), any(), true, false) } returns Futures.immediateFuture(
Objects.ObjectResponse.newBuilder().setHash(objectHash.base64Decode().toByteString()).build()
)

Expand Down Expand Up @@ -286,7 +286,7 @@ class ObjectServiceTest {
val keyToUse = if (useOwnKey) requesterKey else masterKey
val keyToUseAddress = keyToUse.publicKey.getAddress(false)

every { osClient.osClient.put(any(), keyToUse.publicKey, any(), objectBytes.size.toLong(), setOf(requesterKey.publicKey, otherKey), mapOf(), any(), false) } returns Futures.immediateFuture(
every { osClient.osClient.put(any(), keyToUse.publicKey, any(), objectBytes.size.toLong(), setOf(requesterKey.publicKey, otherKey), mapOf(), any(), true, false) } returns Futures.immediateFuture(
Objects.ObjectResponse.newBuilder().setHash(objectHash.base64Decode().toByteString()).build()
)

Expand Down

0 comments on commit 82f9d17

Please sign in to comment.