From 58bc81a2a5c3e06d9576e3d9072dfb68310992a1 Mon Sep 17 00:00:00 2001 From: Cafe137 Date: Thu, 24 Oct 2024 12:01:18 +0200 Subject: [PATCH] feat: add null_topic and null_stamp --- src/utils/expose.ts | 15 ++++++++++----- test/integration/feed/index.spec.ts | 3 ++- test/integration/modules/feed.spec.ts | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/utils/expose.ts b/src/utils/expose.ts index 02b56c17..448057d7 100644 --- a/src/utils/expose.ts +++ b/src/utils/expose.ts @@ -1,33 +1,35 @@ +import { BatchId, Topic } from '..' + export { getCollectionSize } from './collection' export { getFolderSize } from './collection.node' export { - Bytes, - FlexBytes, assertBytes, assertFlexBytes, + Bytes, bytesAtOffset, bytesEqual, + FlexBytes, flexBytesAtOffset, isBytes, isFlexBytes, } from './bytes' export { - HexString, - PrefixedHexString, assertHexString, assertPrefixedHexString, bytesToHex, + HexString, hexToBytes, intToHex, isHexString, makeHexString, + PrefixedHexString, } from './hex' export { - EthAddress, capitalizeAddressERC55, + EthAddress, ethToSwarmAddress, fromLittleEndian, isHexEthAddress, @@ -52,3 +54,6 @@ export { } from './stamps' export { approximateOverheadForRedundancyLevel, getRedundancyStat, getRedundancyStats } from './redundancy' + +export const NULL_STAMP: BatchId = '0000000000000000000000000000000000000000000000000000000000000000' as BatchId +export const NULL_TOPIC: Topic = '0000000000000000000000000000000000000000000000000000000000000000' as Topic diff --git a/test/integration/feed/index.spec.ts b/test/integration/feed/index.spec.ts index d5ede001..45130b62 100644 --- a/test/integration/feed/index.spec.ts +++ b/test/integration/feed/index.spec.ts @@ -5,6 +5,7 @@ import * as chunkAPI from '../../../src/modules/chunk' import { fetchLatestFeedUpdate } from '../../../src/modules/feed' import type { BeeRequestOptions, BytesReference, PrivateKeyBytes, Signer, Topic } from '../../../src/types' import { assertBytes, Bytes } from '../../../src/utils/bytes' +import { NULL_TOPIC } from '../../../src/utils/expose' import { hexToBytes, makeHexString } from '../../../src/utils/hex' import { beeKyOptions, getPostageBatch, testIdentity } from '../../utils' @@ -44,7 +45,7 @@ describe('feed', () => { const BEE_REQUEST_OPTIONS = beeKyOptions() const owner = makeHexString(testIdentity.address, 40) const signer = makePrivateKeySigner(hexToBytes(testIdentity.privateKey) as PrivateKeyBytes) - const topic = '0000000000000000000000000000000000000000000000000000000000000000' as Topic + const topic = NULL_TOPIC it('empty feed update', async function () { const emptyTopic = '1000000000000000000000000000000000000000000000000000000000000000' as Topic diff --git a/test/integration/modules/feed.spec.ts b/test/integration/modules/feed.spec.ts index fef073dd..6b11476e 100644 --- a/test/integration/modules/feed.spec.ts +++ b/test/integration/modules/feed.spec.ts @@ -1,6 +1,7 @@ import { createFeedManifest, fetchLatestFeedUpdate } from '../../../src/modules/feed' import { upload as uploadSOC } from '../../../src/modules/soc' import type { Topic } from '../../../src/types' +import { NULL_TOPIC } from '../../../src/utils/expose' import { HexString, hexToBytes, makeHexString } from '../../../src/utils/hex' import { beeKyOptions, commonMatchers, getPostageBatch, testIdentity } from '../../utils' @@ -9,7 +10,7 @@ commonMatchers() describe('modules/feed', () => { const BEE_REQUEST_OPTIONS = beeKyOptions() const owner = makeHexString(testIdentity.address, 40) - const topic = '0000000000000000000000000000000000000000000000000000000000000000' as Topic + const topic = NULL_TOPIC it('feed manifest creation', async function () { const reference = '92442c3e08a308aeba8e2d231733ec57011a203354cad24129e7e0c37bac0cbe'