Skip to content

Commit

Permalink
feat: update to new tag type (#868)
Browse files Browse the repository at this point in the history
* feat: update to new tag type

* test(fix): adjust tag property in test
  • Loading branch information
Cafe137 committed Aug 31, 2023
1 parent 6750b16 commit 3b703d1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
25 changes: 20 additions & 5 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,27 @@ export interface UploadHeaders {
*/
export interface Tag {
/**
* Number of all chunks that the data will be split into.
* Number of chunks created by the splitter.
*/
total: number
split: number

/**
* Number of chunks that is locally stored in the Bee node.
* Number of chunks that are already uploaded with same reference and same postage batch. These don't need to be synced again.
*/
processed: number
seen: number

/**
* Number of chunks that arrived to their designated destination in the network
* Number of chunks that were stored locally as they lie in the uploader node's neighborhood. This is only applicable for full nodes.
*/
stored: number

/**
* Number of chunks sent on the network to peers as a part of the upload. Chunks could be sent multiple times because of failures or replication.
*/
sent: number

/**
* Number of chunks that were pushed with a valid receipt. The receipt will also show if they were stored at the correct depth.
*/
synced: number

Expand All @@ -242,6 +252,11 @@ export interface Tag {
*/
uid: number

/**
* Swarm hash of the uploaded data
*/
address: string

/**
* When the upload process started
*/
Expand Down
4 changes: 2 additions & 2 deletions test/integration/bee-class.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('Bee class', () => {
expect(file.data).to.eql(content)

const retrievedTag = await bee.retrieveTag(tag)
expect(retrievedTag.total).to.eql(8)
expect(retrievedTag.split).to.eql(8)
})

it('should work with file object', async function () {
Expand Down Expand Up @@ -221,7 +221,7 @@ describe('Bee class', () => {
expect(file.data.length).to.eql(13000)

const retrievedTag = await bee.retrieveTag(tag)
expect(retrievedTag.total).to.eql(8)
expect(retrievedTag.split).to.eql(8)
})
})

Expand Down
4 changes: 2 additions & 2 deletions test/integration/modules/bzz.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ describe('modules/bzz', () => {
await bzz.uploadFile(BEE_KY_OPTIONS, data, getPostageBatch(), filename, { tag: tag1.uid })
const tag2 = await tag.retrieveTag(BEE_KY_OPTIONS, tag1.uid)

expect(tag2.total).to.eql(EXPECTED_TAGS_COUNT)
expect(tag2.processed).to.eql(EXPECTED_TAGS_COUNT)
expect(tag2.split).to.eql(EXPECTED_TAGS_COUNT)
expect(tag2.synced).to.eql(EXPECTED_TAGS_COUNT)
})

it('should catch error', async function () {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/modules/tag.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ describe('modules/tag', () => {
it('should create empty tag', async function () {
const tag1 = await tag.createTag(BEE_KY_OPTIONS)

expect(tag1.total).to.eql(0)
expect(tag1.processed).to.eql(0)
expect(tag1.split).to.eql(0)
expect(tag1.sent).to.eql(0)
expect(tag1.synced).to.eql(0)
expect(Number.isInteger(tag1.uid)).to.be.ok()
expect(tag1.startedAt).a('string')
Expand Down

0 comments on commit 3b703d1

Please sign in to comment.