Skip to content

Commit

Permalink
chore: bump bee 1.4-rc1 (#453)
Browse files Browse the repository at this point in the history
Support for Bee 1.4-rc1

feat!: dropping bee class postage stamps methods (#458)
feat: openapi versions in health (#459)
  • Loading branch information
AuHau authored Nov 25, 2021
1 parent 0ae47aa commit 98afdcd
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 295 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
- '**'

env:
BEE_VERSION: '1.3.0-fd09d1c4-stateful'
BLOCKCHAIN_VERSION: '1.2.0-for-1.3.0-fd09d1c4-stateful'
BEE_VERSION: '1.4.0-rc1-014b4761-stateful'
BLOCKCHAIN_VERSION: '1.2.0-for-1.4.0-rc1-014b4761-stateful'
BEE_ENV_PREFIX: 'swarm-test'
BEE_IMAGE_PREFIX: 'docker.pkg.github.com/ethersphere/bee-factory'
COMMIT_VERSION_TAG: 'false'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@
"engines": {
"node": ">=12.0.0",
"npm": ">=6.0.0",
"bee": "1.3.0-fd09d1c4"
"bee": "1.4.0-rc1-014b4761"
}
}
89 changes: 2 additions & 87 deletions src/bee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import * as pinning from './modules/pinning'
import * as bytes from './modules/bytes'
import * as pss from './modules/pss'
import * as status from './modules/status'
import * as stamps from './modules/stamps'

import { BeeArgumentError, BeeError } from './utils/error'
import { BeeError } from './utils/error'
import { prepareWebsocketData } from './utils/data'
import { fileArrayBuffer, isFile } from './utils/file'
import { makeFeedReader, makeFeedWriter } from './feed'
Expand All @@ -27,8 +26,6 @@ import {
assertData,
assertFileData,
assertFileUploadOptions,
assertNonNegativeInteger,
assertPostageBatchOptions,
assertPssMessageHandler,
assertPublicKey,
assertReference,
Expand All @@ -38,18 +35,7 @@ import {
} from './utils/type'
import { setJsonData, getJsonData } from './feed/json'
import { makeCollectionFromFS, makeCollectionFromFileList, assertCollection } from './utils/collection'
import {
AllTagsOptions,
Collection,
Ky,
NumberString,
PostageBatchOptions,
Readable,
RequestOptions,
STAMPS_DEPTH_MAX,
STAMPS_DEPTH_MIN,
UploadResult,
} from './types'
import { AllTagsOptions, Collection, Ky, Readable, RequestOptions, UploadResult } from './types'

import type { Options as KyOptions } from 'ky-universal'

Expand All @@ -75,7 +61,6 @@ import type {
JsonFeedOptions,
AnyJson,
Pin,
PostageBatch,
BatchId,
} from './types'
import { makeDefaultKy, wrapRequestClosure, wrapResponseClosure } from './utils/http'
Expand Down Expand Up @@ -960,76 +945,6 @@ export class Bee {
}
}

/**
* Creates new postage batch from the funds that the node has available in its Ethereum account.
*
* For better understanding what each parameter means and what are the optimal values please see
* [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive).
*
* **WARNING: THIS CREATES TRANSACTIONS THAT SPENDS MONEY**
* **Warning! Not allowed when node is in Gateway mode!**
*
* @param amount Amount that represents the value per chunk, has to be greater or equal zero.
* @param depth Logarithm of the number of chunks that can be stamped with the batch.
* @param options Options for creation of postage batch and request options
* @throws BeeArgumentError when negative amount or depth is specified
* @throws TypeError if non-integer value is passed to amount or depth
*
* @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
* @see [Bee API reference - `POST /stamps`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1{amount}~1{depth}/post)
* @deprecated Use DebugBee for postage batch management
*/
async createPostageBatch(amount: NumberString, depth: number, options?: PostageBatchOptions): Promise<BatchId> {
assertPostageBatchOptions(options)
assertNonNegativeInteger(amount)
assertNonNegativeInteger(depth)

if (depth < STAMPS_DEPTH_MIN) {
throw new BeeArgumentError(`Depth has to be at least ${STAMPS_DEPTH_MIN}`, depth)
}

if (depth > STAMPS_DEPTH_MAX) {
throw new BeeArgumentError(`Depth has to be at most ${STAMPS_DEPTH_MAX}`, depth)
}

return stamps.createPostageBatch(this.getKy(options), amount, depth, options)
}

/**
* Return details for specific postage batch.
*
* **Warning! Not allowed when node is in Gateway mode!**
*
* @param postageBatchId Batch ID
* @param options Options that affects the request behavior
*
* @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
* @see [Bee API reference - `GET /stamps/${id}`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1{id}/get)
* @deprecated Use DebugBee for postage batch management
*/
async getPostageBatch(postageBatchId: BatchId | string, options?: RequestOptions): Promise<PostageBatch> {
assertRequestOptions(options, 'PostageBatchOptions')
assertBatchId(postageBatchId)

return stamps.getPostageBatch(this.getKy(options), postageBatchId)
}

/**
* Return all postage batches that has the node available.
*
* **Warning! Not allowed when node is in Gateway mode!**
*
* @param options Options that affects the request behavior
* @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
* @see [Bee API reference - `GET /stamps`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps/get)
* @deprecated Use DebugBee for postage batch management
*/
async getAllPostageBatch(options?: RequestOptions): Promise<PostageBatch[]> {
assertRequestOptions(options, 'PostageBatchOptions')

return stamps.getAllPostageBatches(this.getKy(options))
}

/**
* Ping the Bee node to see if there is a live Bee node on the given URL.
*
Expand Down
59 changes: 0 additions & 59 deletions src/modules/stamps.ts

This file was deleted.

2 changes: 2 additions & 0 deletions src/types/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ export interface BalanceResponse {
export interface Health {
status: 'ok'
version: string
apiVersion: string
debugApiVersion: string
}

export interface RemovePeerResponse {
Expand Down
55 changes: 1 addition & 54 deletions test/integration/bee-class.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Bee, BeeArgumentError, BeeDebug, Collection, PssSubscription } from '../../src'
import { Bee, BeeDebug, Collection, PssSubscription } from '../../src'
import { makeSigner } from '../../src/chunk/signer'
import { makeSOCAddress, uploadSingleOwnerChunkData } from '../../src/chunk/soc'
import { ChunkReference } from '../../src/feed'
Expand All @@ -20,7 +20,6 @@ import {
FEED_TIMEOUT,
getPostageBatch,
makeTestTarget,
BLOCKCHAIN_TRANSACTION_TIMEOUT,
PSS_TIMEOUT,
randomByteArray,
sleep,
Expand Down Expand Up @@ -593,56 +592,4 @@ describe('Bee class', () => {
FEED_TIMEOUT,
)
})

describe('PostageBatch', () => {
it(
'should create a new postage batch with zero amount',
async () => {
const batchId = await bee.createPostageBatch('0', 17)
const allBatches = await bee.getAllPostageBatch()

expect(allBatches.find(batch => batch.batchID === batchId)).toBeTruthy()
},
BLOCKCHAIN_TRANSACTION_TIMEOUT,
)

it(
'should have both immutable true and false',
async () => {
await bee.createPostageBatch('1', 17, { immutableFlag: true })
await bee.createPostageBatch('1', 17, { immutableFlag: false })
const allBatches = await bee.getAllPostageBatch()

expect(allBatches.find(batch => batch.immutableFlag === true)).toBeTruthy()
expect(allBatches.find(batch => batch.immutableFlag === false)).toBeTruthy()
},
BLOCKCHAIN_TRANSACTION_TIMEOUT * 2,
)

it('should have all properties', async () => {
const allBatches = await bee.getAllPostageBatch()

expect(allBatches.length).toBeGreaterThan(0)

expect(allBatches).toEqual(
expect.arrayContaining([
expect.objectContaining({
batchID: expect.any(String),
utilization: expect.any(Number),
usable: expect.any(Boolean),
label: expect.any(String),
depth: expect.any(Number),
amount: expect.any(String),
bucketDepth: expect.any(Number),
blockNumber: expect.any(Number),
immutableFlag: expect.any(Boolean),
}),
]),
)
})

it('should error with negative amount', async () => {
await expect(bee.createPostageBatch('-1', 17)).rejects.toThrowError(BeeArgumentError)
})
})
})
Loading

0 comments on commit 98afdcd

Please sign in to comment.