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 maintenance mode #1070

Merged
merged 8 commits into from
Dec 20, 2021
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
50 changes: 50 additions & 0 deletions tests/tests/test-assets-pallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import Keyring from "@polkadot/keyring";
import { expect } from "chai";
import { BN } from "@polkadot/util";
import { ALITH, ALITH_PRIV_KEY, BALTATHAR } from "../util/constants";

import { describeDevMoonbeam } from "../util/setup-dev-tests";
import { createBlockWithExtrinsic } from "../util/substrate-rpc";
import { mockAssetBalance } from "./test-precompile/test-precompile-assets-erc20";

const TEST_ACCOUNT = "0x1111111111111111111111111111111111111111";

describeDevMoonbeam("Pallet Assets Pallet - assets transfer", (context) => {
let sudoAccount, assetId;
before("Try turning maintenance mode on", async () => {
const keyring = new Keyring({ type: "ethereum" });
sudoAccount = await keyring.addFromUri(ALITH_PRIV_KEY, null, "ethereum");

// We need to mint units with sudo.setStorage, as we dont have xcm mocker yet
// And we need relay tokens for issuing a transaction to be executed in the relay
const balance = context.polkadotApi.createType("Balance", 100000000000000);
const assetBalance = context.polkadotApi.createType("PalletAssetsAssetBalance", {
balance: balance,
});

assetId = context.polkadotApi.createType(
"u128",
new BN("42259045809535163221576417993425387648")
);
const assetDetails = context.polkadotApi.createType("PalletAssetsAssetDetails", {
supply: balance,
});

await mockAssetBalance(context, assetBalance, assetDetails, sudoAccount, assetId, ALITH);

await createBlockWithExtrinsic(
context,
sudoAccount,
context.polkadotApi.tx.assets.transfer(assetId, BALTATHAR, 1000)
);
});

it("should transfer asset", async function () {
// Baltathar balance is 1000
let baltatharBalance = (await context.polkadotApi.query.assets.account(
assetId,
BALTATHAR
)) as any;
expect(baltatharBalance.balance.eq(new BN(1000))).to.equal(true);
});
});
5 changes: 4 additions & 1 deletion tests/tests/test-balance/test-balance-extrinsics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect } from "chai";
import { GENESIS_ACCOUNT } from "../../util/constants";

import { describeDevMoonbeam } from "../../util/setup-dev-tests";
import { createTransfer } from "../../util/transactions";
Expand Down Expand Up @@ -40,9 +41,11 @@ describeDevMoonbeam("Balance extrinsics", (context) => {
// ethereum.Executed, system.ExtrinsicSuccess
case 3:
expect(section === "ethereum" && method === "transact").to.be.true;
expect(events.length === 4);
expect(events.length).to.eq(11);
expect(context.polkadotApi.events.system.NewAccount.is(events[1])).to.be.true;
expect(context.polkadotApi.events.balances.Endowed.is(events[2])).to.be.true;
expect(context.polkadotApi.events.balances.Transfer.is(events[3])).to.be.true;
expect(events[3].data[0].toString()).to.eq(GENESIS_ACCOUNT);
// TODO: what event was inserted here?
expect(context.polkadotApi.events.balances.Endowed.is(events[7])).to.be.true; // treasury
expect(context.polkadotApi.events.treasury.Deposit.is(events[8])).to.be.true;
Expand Down
10 changes: 4 additions & 6 deletions tests/tests/test-crowdloan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ import {
ALITH_PRIV_KEY,
ALITH,
BALTATHAR_PRIVATE_KEY,
relayChainAddress,
relayChainAddress_2,
} from "../util/constants";
import { describeDevMoonbeam, DevTestContext } from "../util/setup-dev-tests";
import { verifyLatestBlockFees } from "../util/block";
const relayChainAddress: string =
"0x1111111111111111111111111111111111111111111111111111111111111111";
const relayChainAddress_2: string =
"0x2222222222222222222222222222222222222222222222222222222222222222";

// 5 blocks per minute, 4 weeks
const VESTING_PERIOD = 201600n;
export const VESTING_PERIOD = 201600n;
async function calculate_vested_amount(context, totalReward, initialPayment, numberOfBlocks) {
const amountToVest = BigInt(totalReward) - BigInt(initialPayment);
// On average a parachain only gets a candidate into every other relay chain block.
Expand All @@ -37,7 +35,7 @@ async function calculate_vested_amount(context, totalReward, initialPayment, num
}

// Return the unwrapped accountsPayable or null otherwise
const getAccountPayable = async (
export const getAccountPayable = async (
context: DevTestContext,
address: string
): Promise<{
Expand Down
Loading