Skip to content

Commit

Permalink
fix: ✅ Use new return type of loadFileInStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
ffarall committed Dec 26, 2024
1 parent 875218f commit 4ab8567
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 93 deletions.
2 changes: 1 addition & 1 deletion test/suites/integration/bsp/multi-volunteer-3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describeBspNet("BSPNet: Mulitple BSP Volunteering - 3", ({ before, it, createUse

assert(newBucketEventDataBlob, "Event doesn't match Type");

const fileMetadata = await api.rpc.storagehubclient.loadFileInStorage(
const { file_metadata: fileMetadata } = await api.rpc.storagehubclient.loadFileInStorage(
"res/cloud.jpg",
"cat/cloud.jpg",
signer.address,
Expand Down
2 changes: 1 addition & 1 deletion test/suites/integration/bsp/multi-volunteer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describeBspNet("BSPNet: Mulitple BSP Volunteering - 1", ({ before, it, createUse

assert(newBucketEventDataBlob, "Event doesn't match Type");

const fileMetadata = await api.rpc.storagehubclient.loadFileInStorage(
const { file_metadata: fileMetadata } = await api.rpc.storagehubclient.loadFileInStorage(
"res/smile.jpg",
"cat/smile.jpg",
signer.address,
Expand Down
30 changes: 16 additions & 14 deletions test/suites/integration/bsp/multiple-delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ describeBspNet("Single BSP Volunteering", ({ before, createBspApi, it, createUse
const files = [];
const txs = [];
for (let i = 0; i < source.length; i++) {
const { fingerprint, file_size, location } =
await userApi.rpc.storagehubclient.loadFileInStorage(
source[i],
destination[i],
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);
const {
file_metadata: { location, fingerprint, file_size }
} = await userApi.rpc.storagehubclient.loadFileInStorage(
source[i],
destination[i],
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);

files.push({ fingerprint, file_size, location });
txs.push(
Expand Down Expand Up @@ -172,13 +173,14 @@ describeBspNet("Single BSP Volunteering", ({ before, createBspApi, it, createUse
const files = [];
const txs = [];
for (let i = 0; i < source.length; i++) {
const { fingerprint, file_size, location } =
await userApi.rpc.storagehubclient.loadFileInStorage(
source[i],
destination[i],
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);
const {
file_metadata: { location, fingerprint, file_size }
} = await userApi.rpc.storagehubclient.loadFileInStorage(
source[i],
destination[i],
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);

files.push({ fingerprint, file_size, location });
txs.push(
Expand Down
45 changes: 24 additions & 21 deletions test/suites/integration/bsp/single-volunteer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ describeBspNet("Single BSP Volunteering", ({ before, createBspApi, it, createUse
throw new Error("Event doesn't match Type");
}

const { location, fingerprint, file_size } =
await userApi.rpc.storagehubclient.loadFileInStorage(
source,
destination,
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);
const {
file_metadata: { location, fingerprint, file_size }
} = await userApi.rpc.storagehubclient.loadFileInStorage(
source,
destination,
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);

strictEqual(location.toHuman(), destination);
strictEqual(fingerprint.toString(), userApi.shConsts.TEST_ARTEFACTS[source].fingerprint);
Expand All @@ -62,13 +63,14 @@ describeBspNet("Single BSP Volunteering", ({ before, createBspApi, it, createUse

assert(newBucketEventDataBlob, "Event doesn't match Type");

const { fingerprint, file_size, location } =
await userApi.rpc.storagehubclient.loadFileInStorage(
source,
destination,
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);
const {
file_metadata: { location, fingerprint, file_size }
} = await userApi.rpc.storagehubclient.loadFileInStorage(
source,
destination,
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);

await userApi.sealBlock(
userApi.tx.fileSystem.issueStorageRequest(
Expand Down Expand Up @@ -183,13 +185,14 @@ describeBspNet("Single BSP multi-volunteers", ({ before, createBspApi, createUse

const txs = [];
for (let i = 0; i < source.length; i++) {
const { fingerprint, file_size, location } =
await userApi.rpc.storagehubclient.loadFileInStorage(
source[i],
destination[i],
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);
const {
file_metadata: { location, fingerprint, file_size }
} = await userApi.rpc.storagehubclient.loadFileInStorage(
source[i],
destination[i],
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);

txs.push(
userApi.tx.fileSystem.issueStorageRequest(
Expand Down
15 changes: 8 additions & 7 deletions test/suites/integration/msp/debt-collection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ describeMspNet("Single MSP collecting debt", ({ before, createMsp1Api, it, creat
// Load each file in storage and issue the storage requests
const txs = [];
for (let i = 0; i < source.length; i++) {
const { fingerprint, file_size, location } =
await userApi.rpc.storagehubclient.loadFileInStorage(
source[i],
destination[i],
userApi.shConsts.NODE_INFOS.user.AddressId,
bucketId
);
const {
file_metadata: { location, fingerprint, file_size }
} = await userApi.rpc.storagehubclient.loadFileInStorage(
source[i],
destination[i],
userApi.shConsts.NODE_INFOS.user.AddressId,
bucketId
);

txs.push(
userApi.tx.fileSystem.issueStorageRequest(
Expand Down
15 changes: 8 additions & 7 deletions test/suites/integration/msp/move-bucket.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,14 @@ describeMspNet(
// Seal block with 3 storage requests.
const txs = [];
for (let i = 0; i < source.length; i++) {
const { fingerprint, file_size, location } =
await userApi.rpc.storagehubclient.loadFileInStorage(
source[i],
destination[i],
userApi.shConsts.NODE_INFOS.user.AddressId,
bucketId
);
const {
file_metadata: { location, fingerprint, file_size }
} = await userApi.rpc.storagehubclient.loadFileInStorage(
source[i],
destination[i],
userApi.shConsts.NODE_INFOS.user.AddressId,
bucketId
);

txs.push(
userApi.tx.fileSystem.issueStorageRequest(
Expand Down
15 changes: 8 additions & 7 deletions test/suites/integration/msp/respond-multi-requests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ describeMspNet(
// Seal block with 3 storage requests.
const txs = [];
for (let i = 0; i < source.length; i++) {
const { fingerprint, file_size, location } =
await userApi.rpc.storagehubclient.loadFileInStorage(
source[i],
destination[i],
userApi.shConsts.NODE_INFOS.user.AddressId,
bucketId
);
const {
file_metadata: { location, fingerprint, file_size }
} = await userApi.rpc.storagehubclient.loadFileInStorage(
source[i],
destination[i],
userApi.shConsts.NODE_INFOS.user.AddressId,
bucketId
);

txs.push(
userApi.tx.fileSystem.issueStorageRequest(
Expand Down
15 changes: 8 additions & 7 deletions test/suites/integration/msp/respond-single-request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ describeMspNet(

assert(newBucketEventDataBlob, "Event doesn't match Type");

const { location, fingerprint, file_size } =
await userApi.rpc.storagehubclient.loadFileInStorage(
source,
destination,
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);
const {
file_metadata: { location, fingerprint, file_size }
} = await userApi.rpc.storagehubclient.loadFileInStorage(
source,
destination,
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);

strictEqual(location.toHuman(), destination);
strictEqual(fingerprint.toString(), userApi.shConsts.TEST_ARTEFACTS[source].fingerprint);
Expand Down
15 changes: 8 additions & 7 deletions test/suites/integration/user/file-upload-storage-request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ describeBspNet("User: Issue Storage Requests", ({ before, createUserApi, it }) =
throw new Error("Event doesn't match Type");
}

const { location, fingerprint, file_size } =
await userApi.rpc.storagehubclient.loadFileInStorage(
source,
destination,
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);
const {
file_metadata: { location, fingerprint, file_size }
} = await userApi.rpc.storagehubclient.loadFileInStorage(
source,
destination,
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);

strictEqual(location.toHuman(), destination);
strictEqual(fingerprint.toString(), userApi.shConsts.TEST_ARTEFACTS[source].fingerprint);
Expand Down
45 changes: 24 additions & 21 deletions test/suites/integration/user/load-file-storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ describeBspNet("User: Load File Into Storage", ({ before, createUserApi, it }) =
throw new Error("Event doesn't match Type");
}

const { location, fingerprint, file_size } =
await userApi.rpc.storagehubclient.loadFileInStorage(
source,
destination,
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);
const {
file_metadata: { location, fingerprint, file_size }
} = await userApi.rpc.storagehubclient.loadFileInStorage(
source,
destination,
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);

strictEqual(location.toHuman(), destination);
strictEqual(fingerprint.toString(), userApi.shConsts.TEST_ARTEFACTS[source].fingerprint);
Expand Down Expand Up @@ -72,13 +73,14 @@ describeBspNet("User: Load File Into Storage", ({ before, createUserApi, it }) =
throw new Error("Event doesn't match Type");
}

const { location, fingerprint, file_size } =
await userApi.rpc.storagehubclient.loadFileInStorage(
source,
destination,
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);
const {
file_metadata: { location, fingerprint, file_size }
} = await userApi.rpc.storagehubclient.loadFileInStorage(
source,
destination,
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);

strictEqual(location.toHuman(), destination);
strictEqual(fingerprint.toString(), userApi.shConsts.TEST_ARTEFACTS[source].fingerprint);
Expand All @@ -98,13 +100,14 @@ describeBspNet("User: Load File Into Storage", ({ before, createUserApi, it }) =
throw new Error("Event doesn't match Type");
}

const { location, fingerprint, file_size } =
await userApi.rpc.storagehubclient.loadFileInStorage(
source,
destination,
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);
const {
file_metadata: { location, fingerprint, file_size }
} = await userApi.rpc.storagehubclient.loadFileInStorage(
source,
destination,
userApi.shConsts.NODE_INFOS.user.AddressId,
newBucketEventDataBlob.bucketId
);

strictEqual(location.toHuman(), destination);
strictEqual(fingerprint.toString(), userApi.shConsts.TEST_ARTEFACTS[source].fingerprint);
Expand Down

0 comments on commit 4ab8567

Please sign in to comment.