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

Smoke tests for Data Preservers pallet #751

Merged
merged 8 commits into from
Nov 21, 2024
66 changes: 66 additions & 0 deletions test/suites/smoke-test-common-all/test-data-preservers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import "@tanssi/api-augment";
import { describeSuite, expect, beforeAll } from "@moonwall/cli";
import { ApiPromise } from "@polkadot/api";

describeSuite({
id: "S16",
title: "Verify data preservers consistency",
foundationMethods: "read_only",
testCases: ({ context, it }) => {
let paraApi: ApiPromise;

beforeAll(async function () {
paraApi = context.polkadotJs("para");
});

it({
id: "C01",
title: "all profiles should have a deposit of either 0 or value fixed in the runtime",
test: async function () {
// Add more if we change ProfileDeposit value. Keep previous values for profiles
// created before the change.
const validDeposits = [0, 11330000000000];

const entries = await paraApi.query.dataPreservers.profiles.entries();

for (const [, entry] of entries) {
expect(validDeposits.includes(entry.deposit));
}
},
});

it({
id: "C02",
title: "all assigned profile have assignement witness corresponding to request and whished para id",
test: async function () {
const entries = await paraApi.query.dataPreservers.profiles.entries();

for (const [, entry] of entries) {
console.log(JSON.stringify(entry));

nanocryk marked this conversation as resolved.
Show resolved Hide resolved
if (entry.assignment == null) {
continue;
}

const [para_id, witness] = entry.assignment;

if (entry.profile.paraIds.whitelist != null) {
expect(entry.profile.paraIds.whitelist.includes(para_id));
} else if (entry.profile.paraIds.blacklist != null) {
expect(!entry.profile.paraIds.blacklist.includes(para_id));
}

if (entry.profile.assignmentRequest == "Free") {
expect(witness).to.be.eq("Free");
} else if (entry.profile.assignmentRequest.streamPayment != null) {
expect(witness.streamPayment).to.not.be.undefined();
} else {
// Make test fail on unknown assignment modes.
// This force use to update this test when we add new modes.
expect.fail("unknown assignment mode");
}
}
},
});
},
});
Loading