Skip to content

Commit af31f0c

Browse files
authored
fix: do not discard actHistoryAddress header for uploads (#984)
1 parent 141af79 commit af31f0c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/utils/type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export function prepareUploadOptions(value: unknown, name = 'UploadOptions'): Up
6969

7070
return {
7171
act: Types.asOptional(x => Types.asBoolean(x, { name: 'act' }), object.act),
72+
actHistoryAddress: Types.asOptional(x => new Reference(x), object.actHistoryAddress),
7273
deferred: Types.asOptional(x => Types.asBoolean(x, { name: 'deferred' }), object.deferred),
7374
encrypt: Types.asOptional(x => Types.asBoolean(x, { name: 'encrypt' }), object.encrypt),
7475
pin: Types.asOptional(x => Types.asBoolean(x, { name: 'pin' }), object.pin),

test/integration/act.spec.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dates, System } from 'cafe-utility'
1+
import { Dates, Strings, System } from 'cafe-utility'
22
import { PublicKey } from '../../src'
33
import { batch, makeBee } from '../utils'
44

@@ -57,3 +57,21 @@ test('CRUD grantee', async () => {
5757
})
5858
expect(file.data.toUtf8()).toBe(data)
5959
})
60+
61+
test('ACT upload history address', async () => {
62+
const bee = makeBee()
63+
const data = Strings.randomHex(2000)
64+
65+
const upload = await bee.uploadFile(batch(), data, 'README.md', { act: true })
66+
67+
const uploadAgain = await bee.uploadFile(batch(), data, 'README.md', {
68+
act: true,
69+
actHistoryAddress: upload.historyAddress.getOrThrow(),
70+
})
71+
72+
// same history address
73+
expect(upload.historyAddress.getOrThrow().toHex()).toBe(uploadAgain.historyAddress.getOrThrow().toHex())
74+
75+
// different reference
76+
expect(upload.reference.toHex()).not.toBe(uploadAgain.reference.toHex())
77+
})

0 commit comments

Comments
 (0)