Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: ✅ fix integration tests #348

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions test/suites/integration/bsp/multiple-delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,16 @@ describeBspNet("Single BSP Volunteering", ({ before, createBspApi, it, createUse
// Wait enough blocks for the deletion to be allowed.
const currentBlock = await userApi.rpc.chain.getBlock();
const currentBlockNumber = currentBlock.block.header.number.toNumber();
const cooldown =
currentBlockNumber + userApi.consts.fileSystem.minWaitForStopStoring.toNumber();
const minWaitForStopStoring = (
await userApi.query.parameters.parameters({
RuntimeConfig: {
MinWaitForStopStoring: null
}
})
)
.unwrap()
.asRuntimeConfig.asMinWaitForStopStoring.toNumber();
const cooldown = currentBlockNumber + minWaitForStopStoring;
await userApi.block.skipTo(cooldown);

for (let i = 0; i < fileKeys.length; i++) {
Expand Down Expand Up @@ -281,8 +289,16 @@ describeBspNet("Single BSP Volunteering", ({ before, createBspApi, it, createUse
// Wait enough blocks for the deletion to be allowed.
const currentBlock = await userApi.rpc.chain.getBlock();
const currentBlockNumber = currentBlock.block.header.number.toNumber();
const cooldown =
currentBlockNumber + userApi.consts.fileSystem.minWaitForStopStoring.toNumber();
const minWaitForStopStoring = (
await userApi.query.parameters.parameters({
RuntimeConfig: {
MinWaitForStopStoring: null
}
})
)
.unwrap()
.asRuntimeConfig.asMinWaitForStopStoring.toNumber();
const cooldown = currentBlockNumber + minWaitForStopStoring;
await userApi.block.skipTo(cooldown);

// Batching the delete confirmation should fail because of the wrong inclusionForestProof for extrinsinc 2 and 3
Expand Down
10 changes: 9 additions & 1 deletion test/suites/integration/bsp/reorg-proof.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,15 @@ describeBspNet(
// Wait the required time for the BSP to be able to confirm the deletion.
const currentBlock = await userApi.rpc.chain.getBlock();
const currentBlockNumber = currentBlock.block.header.number.toNumber();
const minWaitForStopStoring = userApi.consts.fileSystem.minWaitForStopStoring.toNumber();
const minWaitForStopStoring = (
await userApi.query.parameters.parameters({
RuntimeConfig: {
MinWaitForStopStoring: null
}
})
)
.unwrap()
.asRuntimeConfig.asMinWaitForStopStoring.toNumber();
const blockToAdvanceTo = currentBlockNumber + minWaitForStopStoring;
await userApi.block.skipTo(blockToAdvanceTo, {
watchForBspProofs: [userApi.shConsts.DUMMY_BSP_ID]
Expand Down
12 changes: 10 additions & 2 deletions test/suites/integration/bsp/storage-delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,16 @@ describeBspNet(
// Wait for the right moment to confirm stop storing
const currentBlock = await userApi.rpc.chain.getBlock();
const currentBlockNumber = currentBlock.block.header.number.toNumber();
const cooldown =
currentBlockNumber + userApi.consts.fileSystem.minWaitForStopStoring.toNumber();
const minWaitForStopStoring = (
await userApi.query.parameters.parameters({
RuntimeConfig: {
MinWaitForStopStoring: null
}
})
)
.unwrap()
.asRuntimeConfig.asMinWaitForStopStoring.toNumber();
const cooldown = currentBlockNumber + minWaitForStopStoring;

// New storage request does not get fulfilled and therefore gets cleaned up and we enqueue a checkpoint challenge remove mutation
// Which then the bsp responds to and has the file key get removed from the forest
Expand Down
36 changes: 21 additions & 15 deletions test/suites/integration/bsp/submit-proofs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,16 @@ describeBspNet(
// Wait enough blocks for the deletion to be allowed.
const currentBlock = await userApi.rpc.chain.getBlock();
const currentBlockNumber = currentBlock.block.header.number.toNumber();
const cooldown =
currentBlockNumber + bspThreeApi.consts.fileSystem.minWaitForStopStoring.toNumber();
const minWaitForStopStoring = (
await userApi.query.parameters.parameters({
RuntimeConfig: {
MinWaitForStopStoring: null
}
})
)
.unwrap()
.asRuntimeConfig.asMinWaitForStopStoring.toNumber();
const cooldown = currentBlockNumber + minWaitForStopStoring;
await userApi.block.skipTo(cooldown);
await userApi.wait.waitForAvailabilityToSendTx(bspThreeKey.address.toString());

Expand Down Expand Up @@ -280,9 +288,19 @@ describeBspNet(
oneBspfileMetadata = fileMetadata;
});

it("Only one BSP confirms it", async () => {
it("Only one BSP confirms it and the MSP accepts it", async () => {
// Wait for the MSP acceptance of the file to be in the TX pool
await userApi.assert.extrinsicPresent({
module: "fileSystem",
method: "mspRespondStorageRequestsMultipleBuckets",
checkTxPool: true,
timeout: 5000
});

// Then wait for the BSP volunteer to be in the TX pool and seal the block
await userApi.wait.bspVolunteer(1);

// Finally, wait for the BSP to confirm storing the file and seal the block
const address = userApi.createType("Address", NODE_INFOS.bsp.AddressId);
await userApi.wait.bspStored(1, address);
});
Expand Down Expand Up @@ -317,18 +335,6 @@ describeBspNet(
checkTxPool: true
});

await userApi.assert.extrinsicPresent({
module: "fileSystem",
method: "mspRespondStorageRequestsMultipleBuckets",
checkTxPool: true
});

await userApi.assert.extrinsicPresent({
module: "fileSystem",
method: "mspRespondStorageRequestsMultipleBuckets",
checkTxPool: true
});

// Seal block and check that the transaction was successful.
await userApi.block.seal();

Expand Down
Loading