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

Deploy Manifest Refactor + Recursive ENS Registration Deployer #1097

Merged
merged 24 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
93f62ea
(feat): new manifest with sequences/steps. Smart migrator
namesty Aug 2, 2022
2b48a7e
(feat): refactored to Sequence and Step classes
namesty Aug 3, 2022
9a2ead9
(chore): tests passing
namesty Aug 5, 2022
7535566
Merge branch 'origin-dev' into namesty/deploy-manifest-refactor
namesty Aug 5, 2022
c1439a1
(chore): 0.1.0 -> "0.1". Also updated buildAndDeployWrapper function
namesty Aug 5, 2022
fbab950
(feat): added ens-recursive-name-register deployer and removed local-ens
namesty Aug 5, 2022
ec61500
(chore): simplified name registration using new deployer
namesty Aug 5, 2022
64c232e
(fix): Deploy test fixes
namesty Aug 5, 2022
ecbaf6b
(chore): parallelize loops that needed not be async
namesty Aug 5, 2022
643b60f
(chore): added network to ENS deployer packages
namesty Aug 14, 2022
f6cb2b6
fix: polywrap.deploy format 0.2 only
dOrgJelli Aug 18, 2022
67a3f6f
merge origin-dev
dOrgJelli Aug 18, 2022
348e018
Merge remote-tracking branch 'origin/origin-dev' into deploy-manifest…
krisbitney Sep 7, 2022
392923c
updates after merging origin-dev
krisbitney Sep 7, 2022
6372d43
updated ipfs cid in deploy.spec.ts
krisbitney Sep 7, 2022
0e35b65
Merge remote-tracking branch 'origin/origin-dev' into deploy-manifest…
krisbitney Sep 9, 2022
990790c
Merge remote-tracking branch 'origin/origin-dev' into deploy-manifest…
krisbitney Sep 12, 2022
7ac39ec
fixed bug where "testnet" was always used for network name in ENS rec…
krisbitney Sep 12, 2022
bebc9af
added embedded uts46 and sha3 wrappers to test-env-js
krisbitney Sep 12, 2022
97d32b9
Merge branch 'origin-dev' into namesty/deploy-manifest-refactor
namesty Sep 16, 2022
3e3df10
(fix): corrected and tested deploy migrator 0.1 -> 0.2
namesty Sep 17, 2022
8f594da
(chore): added comment
namesty Sep 17, 2022
481fa5a
(chore): updated migrator code
namesty Sep 17, 2022
92a7c93
merge origin-dev
dOrgJelli Sep 21, 2022
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
263 changes: 158 additions & 105 deletions packages/cli/src/__tests__/e2e/deploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import {
providers
} from "@polywrap/test-env-js";
import { GetPathToCliTestFiles } from "@polywrap/test-cases";
import { PolywrapClient } from "@polywrap/client-js";
import { ethereumPlugin } from "@polywrap/ethereum-plugin-js";
import { Wallet } from "@ethersproject/wallet";
import path from "path";
import fs from "fs";
import yaml from "js-yaml";
Expand All @@ -35,76 +32,27 @@ const testCaseRoot = path.join(GetPathToCliTestFiles(), "wasm/deploy");
const getTestCaseDir = (index: number) =>
path.join(testCaseRoot, testCases[index]);

const setup = async (domainNames: string[]) => {
const setup = async () => {
await stopTestEnvironment();
await initTestEnvironment();

// Wait a little longer just in case
await new Promise((resolve) => setTimeout(resolve, 3000));

const ensAddress = ensAddresses.ensAddress
const resolverAddress = ensAddresses.resolverAddress
const registrarAddress = ensAddresses.registrarAddress
const signer = new Wallet("0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d");

// Setup environment variables
process.env = {
...process.env,
IPFS_GATEWAY_URI: providers.ipfs,
DOMAIN_NAME: "test1.eth",
ENS_REG_ADDR: ensAddress
ENS_REG_ADDR: ensAddresses.ensAddress,
ENS_REGISTRAR_ADDR: ensAddresses.registrarAddress,
ENS_RESOLVER_ADDR: ensAddresses.resolverAddress,
};

const ethereumPluginUri = "wrap://ens/ethereum.polywrap.eth"
const client = new PolywrapClient({
plugins: [
{
uri: ethereumPluginUri,
plugin: ethereumPlugin({
networks: {
testnet: {
provider: providers.ethereum,
signer
}
},
defaultNetwork: "testnet"
}),
}
],
});

const ensWrapperUri = `fs/${path.join(
path.dirname(require.resolve("@polywrap/test-env-js")),
"wrappers", "ens"
)}`;

for await (const domainName of domainNames) {
const result = await client.invoke({
uri: ensWrapperUri,
method: "registerDomainAndSubdomainsRecursively",
args: {
domain: domainName,
owner: signer.address,
registrarAddress,
registryAddress: ensAddress,
resolverAddress,
ttl: "0",
connection: {
networkNameOrChainId: "testnet",
},
},
});

if (result.error) {
throw Error(
`Failed to register ${domainName}: ${result.error.message}`
);
}
}
}

describe("e2e tests for deploy command", () => {
beforeAll(async () => {
await setup(["test1.eth", "test2.eth", "test3.eth"])
await setup()

for (let i = 0; i < testCases.length; ++i) {
await runCLI(
Expand Down Expand Up @@ -152,10 +100,22 @@ describe("e2e tests for deploy command", () => {
expect(error).toBeFalsy();
expect(code).toEqual(0);
expect(sanitizedOutput).toContain(
"Successfully executed stage 'ipfs_deploy'"
"Successfully executed step 'ipfs_deploy'"
);
expect(sanitizedOutput).toContain(
"Successfully executed step 'from_deploy'"
);
expect(sanitizedOutput).toContain(
"Successfully executed stage 'from_deploy'"
"Successfully executed step 'from_deploy2'"
);
expect(sanitizedOutput).toContain(
"Successfully executed 'fs_to_ens' deployment sequence"
);
expect(sanitizedOutput).toContain(
"Successfully executed step 'from_uri'"
);
expect(sanitizedOutput).toContain(
"Successfully executed 'ipfs_to_ens' deployment sequence"
);
});

Expand Down Expand Up @@ -202,51 +162,140 @@ describe("e2e tests for deploy command", () => {
expect(yamlOutputFileContents).toMatchObject(jsonOutputFileContents);
expect(jsonOutputFileContents).toMatchObject([
{
id: "ipfs_deploy",
name: "ipfs_deploy",
input: {
uri: "wrap://fs/./build"
},
result: "wrap://ipfs/QmTVbK7oZr4km4AnRuzJpm1r68G7nGzaXFvQHWdwnu8hmv"
},
{
id: "ipfs_deploy.from_deploy",
name: "from_deploy",
input: {
uri: "wrap://ipfs/QmTVbK7oZr4km4AnRuzJpm1r68G7nGzaXFvQHWdwnu8hmv",
config: {
domainName: "test1.eth",
provider: "http://localhost:8545",
ensRegistryAddress: "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab"
}
},
result: "wrap://ens/test1.eth"
},
{
id: "ipfs_deploy.from_deploy2",
name: "from_deploy2",
input: {
uri: "wrap://ipfs/QmTVbK7oZr4km4AnRuzJpm1r68G7nGzaXFvQHWdwnu8hmv",
config: {
domainName: "test2.eth",
provider: "http://localhost:8545",
ensRegistryAddress: "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab"
"name": "fs_to_ens",
"steps": [
{
"name": "ens_register",
"id": "fs_to_ens.ens_register",
"input": {
"_config": {
"uri": "wrap://ens/test1.eth",
"authority": "ens",
"path": "test1.eth"
}
},
"result": {
"_config": {
"uri": "wrap://ens/test1.eth",
"authority": "ens",
"path": "test1.eth"
}
}
},
{
"name": "ens_register2",
"id": "fs_to_ens.ens_register2",
"input": {
"_config": {
"uri": "wrap://ens/test2.eth",
"authority": "ens",
"path": "test2.eth"
}
},
"result": {
"_config": {
"uri": "wrap://ens/test2.eth",
"authority": "ens",
"path": "test2.eth"
}
}
},
{
"name": "ipfs_deploy",
"id": "fs_to_ens.ipfs_deploy",
"input": {
"_config": {
"uri": "wrap://fs/./build",
"authority": "fs",
"path": "./build"
}
},
"result": {
"_config": {
"uri": "wrap://ipfs/QmTVbK7oZr4km4AnRuzJpm1r68G7nGzaXFvQHWdwnu8hmv",
"authority": "ipfs",
"path": "QmTVbK7oZr4km4AnRuzJpm1r68G7nGzaXFvQHWdwnu8hmv"
}
}
},
{
"name": "from_deploy",
"id": "fs_to_ens.from_deploy",
"input": {
"_config": {
"uri": "wrap://ipfs/QmTVbK7oZr4km4AnRuzJpm1r68G7nGzaXFvQHWdwnu8hmv",
"authority": "ipfs",
"path": "QmTVbK7oZr4km4AnRuzJpm1r68G7nGzaXFvQHWdwnu8hmv"
}
},
"result": {
"_config": {
"uri": "wrap://ens/test1.eth",
"authority": "ens",
"path": "test1.eth"
}
}
},
{
"name": "from_deploy2",
"id": "fs_to_ens.from_deploy2",
"input": {
"_config": {
"uri": "wrap://ipfs/QmTVbK7oZr4km4AnRuzJpm1r68G7nGzaXFvQHWdwnu8hmv",
"authority": "ipfs",
"path": "QmTVbK7oZr4km4AnRuzJpm1r68G7nGzaXFvQHWdwnu8hmv"
}
},
"result": {
"_config": {
"uri": "wrap://ens/test2.eth",
"authority": "ens",
"path": "test2.eth"
}
}
}
},
result: "wrap://ens/test2.eth"
]
},
{
id: "from_uri",
name: "from_uri",
input: {
uri: "wrap://ipfs/QmVdDR6QtigTt38Xwpj2Ki73X1AyZn5WRCreBCJq1CEtpF",
config: {
domainName: "test3.eth",
provider: "http://localhost:8545",
ensRegistryAddress: "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab"
"name": "ipfs_to_ens",
"steps": [
{
"name": "ens_register",
"id": "ipfs_to_ens.ens_register",
"input": {
"_config": {
"uri": "wrap://ens/test3.eth",
"authority": "ens",
"path": "test3.eth"
}
},
"result": {
"_config": {
"uri": "wrap://ens/test3.eth",
"authority": "ens",
"path": "test3.eth"
}
}
},
{
"name": "from_uri",
"id": "ipfs_to_ens.from_uri",
"input": {
"_config": {
"uri": "wrap://ipfs/QmVdDR6QtigTt38Xwpj2Ki73X1AyZn5WRCreBCJq1CEtpF",
"authority": "ipfs",
"path": "QmVdDR6QtigTt38Xwpj2Ki73X1AyZn5WRCreBCJq1CEtpF"
}
},
"result": {
"_config": {
"uri": "wrap://ens/test3.eth",
"authority": "ens",
"path": "test3.eth"
}
}
}
},
result: "wrap://ens/test3.eth"
]
}
])
});
Expand All @@ -257,6 +306,7 @@ describe("e2e tests for deploy command", () => {
args: ["deploy"],
cwd: getTestCaseDir(1),
cli: polywrapCli,
env: process.env as Record<string, string>
},
);

Expand All @@ -267,7 +317,7 @@ describe("e2e tests for deploy command", () => {
"No manifest extension found in"
);
expect(sanitizedOutput).toContain(
"Successfully executed stage 'ipfs_test'"
"Successfully executed step 'ipfs_test'"
);
});

Expand All @@ -277,6 +327,7 @@ describe("e2e tests for deploy command", () => {
args: ["deploy"],
cwd: getTestCaseDir(2),
cli: polywrapCli,
env: process.env as Record<string, string>
},
);

Expand All @@ -292,6 +343,7 @@ describe("e2e tests for deploy command", () => {
args: ["deploy"],
cwd: getTestCaseDir(3),
cli: polywrapCli,
env: process.env as Record<string, string>
},
);

Expand All @@ -300,14 +352,14 @@ describe("e2e tests for deploy command", () => {

expect(code).toEqual(1);
expect(sanitizedOutput).toContain(
"Successfully executed stage 'ipfs_deploy'"
"Successfully executed step 'ipfs_deploy'"
);
expect(sanitizedOutput).not.toContain(
"Successfully executed stage 'from_deploy2'"
"Successfully executed step 'from_deploy2'"
);

expect(sanitizedErr).toContain(
"Failed to execute stage 'from_deploy'"
"Failed to execute step 'from_deploy'"
);
});

Expand All @@ -317,6 +369,7 @@ describe("e2e tests for deploy command", () => {
args: ["deploy"],
cwd: getTestCaseDir(4),
cli: polywrapCli,
env: process.env as Record<string, string>
},
);

Expand Down
Loading