Skip to content

Commit 5e814c2

Browse files
Merge pull request #160 from paritytech/e2e-fixtures
chore: modernize e2e fixture registration
2 parents 86fe5ca + 612421a commit 5e814c2

7 files changed

Lines changed: 222 additions & 307 deletions

File tree

e2e/cli/fixtures/registry.ts

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,50 +19,27 @@
1919
* Queries the on-chain playground registry to verify deploy outcomes.
2020
*/
2121

22-
import { ContractManager } from "@parity/product-sdk-contracts";
23-
import { createDevSigner, getDevPublicKey } from "@parity/product-sdk-tx";
24-
import { ss58Encode } from "@parity/product-sdk-address";
2522
import { getTestClient } from "../helpers/chain.js";
26-
import {
27-
PLAYGROUND_REGISTRY_CONTRACT,
28-
suppressReviveTraceNoise,
29-
withRequiredLiveContractAddresses,
30-
} from "../../../src/utils/contractManifest.js";
23+
import { getReadOnlyRegistryContract } from "../../../src/utils/registry.js";
3124
import { resolveSigner } from "../../../src/utils/signer.js";
3225
import { publishToPlayground } from "../../../src/utils/deploy/playground.js";
3326
import { SIGNER } from "./accounts.js";
3427

35-
import cdmJson from "../../../cdm.json";
36-
3728
export interface AppEntry {
3829
domain: string;
3930
owner: string;
4031
metadataUri: string;
4132
}
4233

43-
type Registry = Awaited<ReturnType<Awaited<ReturnType<typeof ContractManager.fromClient>>["getContract"]>>;
34+
type Registry = Awaited<ReturnType<typeof getReadOnlyRegistryContract>>;
4435

4536
let registryPromise: Promise<Registry> | null = null;
4637

4738
async function getRegistry(): Promise<Registry> {
4839
if (!registryPromise) {
4940
registryPromise = (async () => {
5041
const client = await getTestClient();
51-
const aliceSigner = createDevSigner("Alice");
52-
const aliceAddress = ss58Encode(getDevPublicKey("Alice"));
53-
// Mirror src/utils/registry.ts — query the CDM meta-registry for the
54-
// live address before binding, so the helper reads from the same
55-
// contract `dot mod` and `dot deploy` actually use. Without this,
56-
// reads land on the cdm.json snapshot and silently diverge from the
57-
// command paths after a registry redeploy. See issue #74.
58-
const manifest = await withRequiredLiveContractAddresses(cdmJson, client.raw.assetHub, [
59-
PLAYGROUND_REGISTRY_CONTRACT,
60-
]);
61-
const manager = await ContractManager.fromClient(manifest, client.raw.assetHub, {
62-
defaultSigner: aliceSigner,
63-
defaultOrigin: aliceAddress,
64-
});
65-
return suppressReviveTraceNoise(manager.getContract(PLAYGROUND_REGISTRY_CONTRACT));
42+
return getReadOnlyRegistryContract(client.raw.assetHub);
6643
})().catch((err) => {
6744
// Reset so the next call can retry instead of replaying the error
6845
registryPromise = null;

e2e/cli/setup/fund.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ import { checkBalance, ensureFunded } from "../../../src/utils/account/funding.j
3030
import { getTestClient } from "../helpers/chain.js";
3131
import { SIGNER } from "../fixtures/accounts.js";
3232

33+
interface FundedAccount {
34+
name: string;
35+
address: string;
36+
}
37+
3338
const PAS = 10_000_000_000n;
3439

3540
/** Top up the deployer if it falls below this. */
@@ -38,18 +43,22 @@ export const MIN_BALANCE = 500n * PAS;
3843
/** Amount to send when topping up. */
3944
export const TOP_UP_AMOUNT = 1000n * PAS;
4045

41-
export async function fundDeployerIfLow(): Promise<void> {
46+
export async function fundAccountIfLow(account: FundedAccount): Promise<void> {
4247
const client = await getTestClient();
43-
const before = await checkBalance(client, SIGNER.address, MIN_BALANCE);
48+
const before = await checkBalance(client, account.address, MIN_BALANCE);
4449
console.log(
45-
`[e2e setup] SIGNER (${SIGNER.name}) balance: ${before.free / PAS} PAS (${SIGNER.address})`,
50+
`[e2e setup] ${account.name} balance: ${before.free / PAS} PAS (${account.address})`,
4651
);
4752
if (before.sufficient) return;
4853

4954
console.log(
5055
`[e2e setup] balance below ${MIN_BALANCE / PAS} PAS — topping up by ${TOP_UP_AMOUNT / PAS} PAS…`,
5156
);
52-
await ensureFunded(client, SIGNER.address, MIN_BALANCE, TOP_UP_AMOUNT);
53-
const after = await checkBalance(client, SIGNER.address, MIN_BALANCE);
54-
console.log(`[e2e setup] SIGNER topped up: ${after.free / PAS} PAS`);
57+
await ensureFunded(client, account.address, MIN_BALANCE, TOP_UP_AMOUNT);
58+
const after = await checkBalance(client, account.address, MIN_BALANCE);
59+
console.log(`[e2e setup] ${account.name} topped up: ${after.free / PAS} PAS`);
60+
}
61+
62+
export async function fundDeployerIfLow(): Promise<void> {
63+
await fundAccountIfLow(SIGNER);
5564
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"bulletin-deploy": "0.7.20-rc.4",
4444
"commander": "^12.0.0",
4545
"ink": "^5.2.1",
46-
"polkadot-api": "^2.1.2",
46+
"polkadot-api": "^2.1.3",
4747
"react": "^18.3.1",
4848
"react-devtools-core": "file:stubs/react-devtools-core",
4949
"tar": "^7.5.13"

0 commit comments

Comments
 (0)