@@ -92,34 +92,34 @@ runBlocking {
92
92
runBlocking {
93
93
// create node
94
94
val irohDir = kotlin.io.path.createTempDirectory(" doc-test" )
95
- val node = IrohNode .persistent(irohDir.toString())
95
+ val node = Iroh .persistent(irohDir.toString())
96
96
97
97
// create bytes
98
98
val blobSize = 100
99
99
val bytes = generateRandomByteArray(blobSize)
100
100
101
101
// add blob
102
- val addOutcome = node.blobsAddBytes (bytes)
102
+ val addOutcome = node.blobs().addBytes (bytes)
103
103
104
104
// check outcome info is as expected
105
105
assert (addOutcome.format == BlobFormat .RAW )
106
106
assert (addOutcome.size == blobSize.toULong())
107
107
108
108
// check we get the expected size from the hash
109
109
val hash = addOutcome.hash
110
- val gotSize = node.blobsSize (hash)
110
+ val gotSize = node.blobs().size (hash)
111
111
assert (gotSize == blobSize.toULong())
112
112
113
113
// get bytes
114
- val gotBytes = node.blobsReadToBytes (hash)
114
+ val gotBytes = node.blobs().readToBytes (hash)
115
115
assert (gotBytes.size == blobSize)
116
116
assert (gotBytes contentEquals bytes)
117
117
}
118
118
119
119
// test functionality between reading bytes from a path and writing bytes to a path
120
120
runBlocking {
121
121
val irohDir = kotlin.io.path.createTempDirectory(" doc-test-read-bytes" )
122
- val node = IrohNode .persistent(irohDir.toString())
122
+ val node = Iroh .persistent(irohDir.toString())
123
123
124
124
// create bytes
125
125
val blobSize = 100
@@ -154,24 +154,24 @@ runBlocking {
154
154
}
155
155
}
156
156
val cb = Handler ()
157
- node.blobsAddFromPath (path, false , tag, wrap, cb)
157
+ node.blobs().addFromPath (path, false , tag, wrap, cb)
158
158
159
159
// check outcome info is as expected
160
160
assert (cb.format == BlobFormat .RAW )
161
161
assert (cb.hash != null )
162
162
163
163
// check we get the expected size from the hash
164
- val gotSize = node.blobsSize (cb.hash!! )
164
+ val gotSize = node.blobs().size (cb.hash!! )
165
165
assert (gotSize == blobSize.toULong())
166
166
167
167
// get bytes
168
- val gotBytes = node.blobsReadToBytes (cb.hash!! )
168
+ val gotBytes = node.blobs().readToBytes (cb.hash!! )
169
169
assert (gotBytes.size == blobSize)
170
170
assert (gotBytes contentEquals bytes)
171
171
172
172
// write to file
173
173
val outPath = dir.toString() + " out"
174
- node.blobsWriteToPath (cb.hash!! , outPath)
174
+ node.blobs().writeToPath (cb.hash!! , outPath)
175
175
176
176
// open file
177
177
val gotBytesFile = java.io.File (outPath).readBytes()
@@ -192,10 +192,10 @@ runBlocking {
192
192
}
193
193
// make node
194
194
val irohDir = kotlin.io.path.createTempDirectory(" doc-test-collection" )
195
- val node = IrohNode .persistent(irohDir.toString())
195
+ val node = Iroh .persistent(irohDir.toString())
196
196
197
197
// ensure zero blobs
198
- val blobs = node.blobsList ()
198
+ val blobs = node.blobs().list ()
199
199
assert (blobs.size == 0 )
200
200
201
201
// create callback to get blobs and collection hash
@@ -226,13 +226,13 @@ runBlocking {
226
226
val tag = SetTagOption .auto()
227
227
val wrap = WrapOption .noWrap()
228
228
// add from path
229
- node.blobsAddFromPath (collectionDir.toString(), false , tag, wrap, cb)
229
+ node.blobs().addFromPath (collectionDir.toString(), false , tag, wrap, cb)
230
230
231
231
assert (cb.collectionHash != null )
232
232
assert (cb.format == BlobFormat .HASH_SEQ )
233
233
234
234
// list collections
235
- val collections = node.blobsListCollections ()
235
+ val collections = node.blobs().listCollections ()
236
236
println (" collection hash " + collections[0 ].hash)
237
237
assert (collections.size == 1 )
238
238
assert (collections[0 ].hash.equal(cb.collectionHash!! ))
@@ -241,9 +241,9 @@ runBlocking {
241
241
// list blobs
242
242
val collectionHashes = cb.blobHashes!!
243
243
collectionHashes.add(cb.collectionHash!! )
244
- val gotHashes = node.blobsList ()
244
+ val gotHashes = node.blobs().list ()
245
245
for (hash in gotHashes) {
246
- val blob = node.blobsReadToBytes (hash)
246
+ val blob = node.blobs().readToBytes (hash)
247
247
println (" hash " + hash + " has size " + blob.size)
248
248
}
249
249
hashesExist(collectionHashes, gotHashes)
@@ -256,7 +256,7 @@ runBlocking {
256
256
runBlocking {
257
257
val irohDir = kotlin.io.path.createTempDirectory(" doc-test-list-del" )
258
258
val opts = NodeOptions (100UL )
259
- val node = IrohNode .persistentWithOptions(irohDir.toString(), opts)
259
+ val node = Iroh .persistentWithOptions(irohDir.toString(), opts)
260
260
261
261
// create bytes
262
262
val blobSize = 100
@@ -272,23 +272,23 @@ runBlocking {
272
272
val hashes: MutableList <Hash > = arrayListOf ()
273
273
val tags: MutableList <ByteArray > = arrayListOf ()
274
274
for (blob in blobs) {
275
- val output = node.blobsAddBytes (blob)
275
+ val output = node.blobs().addBytes (blob)
276
276
hashes.add(output.hash)
277
277
tags.add(output.tag)
278
278
}
279
279
280
- val gotHashes = node.blobsList ()
280
+ val gotHashes = node.blobs().list ()
281
281
assert (gotHashes.size == numBlobs)
282
282
hashesExist(hashes, gotHashes)
283
283
284
284
val removeHash = hashes.removeAt(0 )
285
285
val removeTag = tags.removeAt(0 )
286
286
// delete the tag for the first blob
287
- node.tagsDelete (removeTag)
287
+ node.tags().delete (removeTag)
288
288
// wait for GC to clear the blob
289
289
java.lang.Thread .sleep(250 )
290
290
291
- val clearedHashes = node.blobsList ()
291
+ val clearedHashes = node.blobs().list ()
292
292
assert (clearedHashes.size == numBlobs - 1 )
293
293
hashesExist(hashes, clearedHashes)
294
294
0 commit comments