Skip to content
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
2 changes: 1 addition & 1 deletion .github/actions/run-polkadot/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ runs:
key: ${{ runner.os }}-${{ inputs.polkadot-version }}-${{ hashFiles('substrate-tip-bot/polkadot.e2e.patch') }}
- name: Run a local Rococo node
run: |
polkadot-sdk/target/release/polkadot --rpc-external --no-prometheus --no-telemetry --chain=rococo-dev --tmp --alice --execution Native --rpc-port 9902 &
polkadot-sdk/target/release/polkadot --rpc-external --no-prometheus --no-telemetry --chain=rococo-dev --tmp --alice --execution Native --unsafe-force-node-key-generation --rpc-port 9902 &
until curl -s '127.0.0.1:9902'; do sleep 3; done
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Start a local Polkadot node
uses: ./.github/actions/run-polkadot
with:
polkadot-version: polkadot-v1.7.1
polkadot-version: polkadot-v1.13.0
- name: Wait for the node
run: |
until curl -s '127.0.0.1:9902'; do sleep 3; done
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"dependencies": {
"@eng-automation/integrations": "^4.4.0",
"@eng-automation/js": "^2.2.0",
"@polkadot/api": "^10.9.1",
"@polkadot/api": "^12.0.2",
"@polkadot/util": "^12.3.2",
"@polkadot/util-crypto": "^12.3.2",
"concurrently": "^8.2.2",
Expand Down
32 changes: 25 additions & 7 deletions src/tip-opengov.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ all the way to completing the referendum.
import "@polkadot/api-augment";
import { until } from "@eng-automation/js";
import { ApiPromise, Keyring, WsProvider } from "@polkadot/api";
import type { SubmittableExtrinsic } from "@polkadot/api/types";
import { KeyringPair } from "@polkadot/keyring/types";
import { BN } from "@polkadot/util";
import { cryptoWaitReady } from "@polkadot/util-crypto";
Expand All @@ -25,6 +26,22 @@ const treasuryAccount = "13UVJyLnbVp9RBZYFwFGyDvVd1y27Tt8tkntv6Q7JVPhFsTB"; // h

const network = "localrococo";

const signAndSend = (signer: KeyringPair, extrinsic: SubmittableExtrinsic<"promise">) =>
new Promise<void>(async (resolve, reject) => {
try {
await extrinsic.signAndSend(signer, { nonce: -1 }, (result) => {
if (result.isError) {
reject(result.status.toString());
}
if (result.isInBlock) {
resolve();
}
});
} catch (e) {
reject(e);
}
});

describe("E2E opengov tip", () => {
let state: State;
let api: ApiPromise;
Expand Down Expand Up @@ -69,9 +86,7 @@ describe("E2E opengov tip", () => {
alice = keyring.addFromUri("//Alice");

// In some local dev chains, treasury is broke, so we fund it.
await api.tx.balances
.transferKeepAlive(treasuryAccount, new BN("10000000000000"))
.signAndSend(alice, { nonce: -1 });
await signAndSend(alice, api.tx.balances.transferKeepAlive(treasuryAccount, new BN("10000000000000")));
});

test("Small OpenGov tip", async () => {
Expand All @@ -90,10 +105,13 @@ describe("E2E opengov tip", () => {
expect(result.success).toBeTruthy();

// Alice votes "aye" on the referendum.
await api.tx.referenda.placeDecisionDeposit(referendumId).signAndSend(alice, { nonce: -1 });
await api.tx.convictionVoting
.vote(referendumId, { Standard: { balance: new BN(1_000_000), vote: { aye: true, conviction: 1 } } })
.signAndSend(alice, { nonce: -1 });
await signAndSend(alice, api.tx.referenda.placeDecisionDeposit(referendumId));
await signAndSend(
alice,
api.tx.convictionVoting.vote(referendumId, {
Standard: { balance: new BN(1_000_000), vote: { aye: true, conviction: 1 } },
}),
);

// Waiting for the referendum voting, enactment, and treasury spend period.
await until(async () => (await getUserBalance(tipRequest.contributor.account.address)).gtn(0), 5000, 50);
Expand Down
2 changes: 1 addition & 1 deletion src/tip.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe("tip", () => {
throw new Error("Encoding the proposal failed.");
}
const { encodedProposal } = encodeProposalResult;
const nextFreeReferendumId = new BN(await api.query.referenda.referendumCount());
const nextFreeReferendumId = new BN((await api.query.referenda.referendumCount()).toNumber());

// We surround our tip with two "decoys" to make sure that we find the proper one.
await tipUser(state, tipRequest); // Will occupy nextFreeReferendumId
Expand Down
Loading