Skip to content

Commit

Permalink
Fixing type errors on new pkgs (#1964)
Browse files Browse the repository at this point in the history
  • Loading branch information
timbrinded committed Nov 22, 2022
1 parent dd24953 commit 3bdd08e
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion tests/smoke-tests/test-balances-consistency.ts
Expand Up @@ -100,7 +100,7 @@ describeSmokeSuite(`Verifying balances consistency...`, (context) => {
apiAt.query.identity.subsOf.entries(),
apiAt.query.democracy.depositOf.entries(),
apiAt.query.democracy.votingOf.entries(),
apiAt.query.democracy.preimages.entries(),
apiAt.query.democracy.preimages.entries() as any, // TODO: Replace with preimage pallet
apiAt.query.assets.asset.entries(),
apiAt.query.assets.metadata.entries(),
apiAt.query.localAssets.asset.entries(),
Expand Down
4 changes: 3 additions & 1 deletion tests/smoke-tests/test-block-weights.ts
Expand Up @@ -67,7 +67,9 @@ describeSmokeSuite(
const specVersion = apiAt.consts.system.version.specVersion.toNumber();
const events = await apiAt.query.system.events();
if (specVersion >= 1700) {
const { normal, operational, mandatory } = await apiAt.query.system.blockWeight();
// TODO: replace type when we update to use SpWeightsWeightV2Weight
const { normal, operational, mandatory } =
(await apiAt.query.system.blockWeight()) as any;
return {
blockNum,
hash: blockHash.toString(),
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/test-crowdloan/test-crowdloan.ts
Expand Up @@ -466,7 +466,7 @@ describeDevMoonbeam("Crowdloan", (context) => {
await context.createBlock(
context.polkadotApi.tx.sudo.sudoUncheckedWeight(
context.polkadotApi.tx.democracy.enactProposal(encodedHash, publicPropCount),
1
"1"
)
);

Expand Down
16 changes: 11 additions & 5 deletions tests/tests/test-democracy/test-democracy-preimage.ts
Expand Up @@ -17,7 +17,9 @@ describeDevMoonbeam("Democracy - Preimage", (context) => {
const encodedHash = blake2AsHex(encodedProposal);
await context.createBlock(context.polkadotApi.tx.democracy.notePreimage(encodedProposal));

const preimageStatus = await context.polkadotApi.query.democracy.preimages(encodedHash);
const preimageStatus = (await context.polkadotApi.query.democracy.preimages(
encodedHash
)) as any;
expect(preimageStatus.isSome).to.be.true;
expect(preimageStatus.unwrap().isAvailable).to.eq(true, "Preimage should be available");
expect(preimageStatus.unwrap().asAvailable.provider.toString()).to.equal(alith.address);
Expand All @@ -40,8 +42,10 @@ describeDevMoonbeam("Democracy - Preimage", (context) => {
);

expect(error.name).to.equal("TooEarly");

const preimageStatus = await context.polkadotApi.query.democracy.preimages(encodedHash);
// TODO: Replace casting when preimage pallet available
const preimageStatus = (await context.polkadotApi.query.democracy.preimages(
encodedHash
)) as any;
expect(preimageStatus.isSome).to.be.true;
});
});
Expand All @@ -55,8 +59,10 @@ describeDevMoonbeam("Democracy - Preimage", (context) => {
);

await context.createBlock(context.polkadotApi.tx.democracy.reapPreimage(encodedHash, 10000));

const preimageStatus = await context.polkadotApi.query.democracy.preimages(encodedHash);
// TODO: Replace casting when preimage pallet available
const preimageStatus = (await context.polkadotApi.query.democracy.preimages(
encodedHash
)) as any;
expect(preimageStatus.isSome).to.be.true;
expect(preimageStatus.unwrap().isAvailable).to.eq(true, "Preimage should be available");
expect(preimageStatus.unwrap().asAvailable.provider.toString()).to.equal(alith.address);
Expand Down
6 changes: 4 additions & 2 deletions tests/tests/test-democracy/test-democracy-proposal.ts
Expand Up @@ -71,7 +71,8 @@ describeDevMoonbeam("Democracy - Seconding a proposal", (context) => {
await context.createBlock(
context.polkadotApi.tx.democracy.propose(encodedHash, PROPOSAL_AMOUNT)
);
await context.createBlock(context.polkadotApi.tx.democracy.second(0, 1000));
// TODO: Remove casting when democracy pallet updated
await context.createBlock((context.polkadotApi.tx.democracy as any).second(0, 1000));
});

it("should succeed", async function () {
Expand Down Expand Up @@ -113,7 +114,8 @@ describeDevMoonbeam("Democracy - Seconding a proposal", (context) => {
await context.createBlock(
context.polkadotApi.tx.democracy.propose(encodedHash, PROPOSAL_AMOUNT)
);
await context.createBlock(context.polkadotApi.tx.democracy.second(0, 1000));
// TODO: Remove casting when democracy pallet updated
await context.createBlock((context.polkadotApi.tx.democracy as any).second(0, 1000));
});

it("should end-up in a valid referendum", async function () {
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/test-eth-fee/test-eth-txn-weights.ts
Expand Up @@ -49,8 +49,8 @@ describeDevMoonbeam("Ethereum Weight Accounting", (context) => {

// query the block's weight, whose normal portion should reflect only this txn
const apiAt = await context.polkadotApi.at(block.hash);

let blockWeightsUsed = await apiAt.query.system.blockWeight();
// TODO: Remove casting when updated to use SpWeightsWeightV2Weight
let blockWeightsUsed = (await apiAt.query.system.blockWeight()) as any;
let normalWeight = blockWeightsUsed.normal;

expect(normalWeight.toBigInt()).to.equal(EXPECTED_WEIGHT);
Expand Down
6 changes: 4 additions & 2 deletions tests/tests/test-precompile/test-precompile-democracy.ts
Expand Up @@ -102,8 +102,10 @@ describeDevMoonbeam("Democracy - genesis and preimage", (context) => {
DEMOCRACY_INTERFACE,
context.polkadotApi.tx.parachainStaking.setParachainBondAccount(alith.address)
);

const preimageStatus = await context.polkadotApi.query.democracy.preimages(encodedHash);
// TODO: Remove casting when preimage pallet added
const preimageStatus = (await context.polkadotApi.query.democracy.preimages(
encodedHash
)) as any;
expect(
preimageStatus.unwrap().isAvailable && preimageStatus.unwrap().asAvailable.provider.toString()
).to.equal(alith.address);
Expand Down
3 changes: 2 additions & 1 deletion tests/tests/test-xcm/test-mock-hrmp-transact-ethereum.ts
Expand Up @@ -1621,7 +1621,8 @@ describeDevMoonbeam("Mock XCM - receive horizontal transact ETHEREUM (transfer)"
transferredBalance - expectedTransferredAmountPlusFees
);

const weightBlock = await context.polkadotApi.query.system.blockWeight();
// TODO: remove casting when updated to use SpWeightsWeightV2Weight
const weightBlock = (await context.polkadotApi.query.system.blockWeight()) as any;
// Make sure the system block weight corresponds to gas used and not gas limit
// It should be sufficient to verify that we used less than what was marked
expect(12_500_000_000n + 25_000_000n - weightBlock.mandatory.toBigInt() > 0n).to.be.true;
Expand Down
5 changes: 3 additions & 2 deletions tests/util/upgrade.ts
Expand Up @@ -49,7 +49,8 @@ export async function upgradeRuntime(api: ApiPromise, preferences: UpgradePrefer
let encodedHash = blake2AsHex(encodedProposal);

// Check if already in governance
const preImageExists = await api.query.democracy.preimages(encodedHash);
// TODO: Remove casting when preimage pallet added
const preImageExists = (await api.query.democracy.preimages(encodedHash)) as any;
if (preImageExists.isSome && preImageExists.unwrap().isAvailable) {
process.stdout.write(`Preimage ${encodedHash} already exists !\n`);
} else {
Expand Down Expand Up @@ -93,7 +94,7 @@ export async function upgradeRuntime(api: ApiPromise, preferences: UpgradePrefer
)} kb])...`
);
await api.tx.sudo
.sudoUncheckedWeight(await api.tx.system.setCodeWithoutChecks(code), 1)
.sudoUncheckedWeight(await api.tx.system.setCodeWithoutChecks(code), "1")
.signAndSend(options.from, { nonce: nonce++ });
process.stdout.write(`✅\n`);
}
Expand Down

0 comments on commit 3bdd08e

Please sign in to comment.