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

feat: e2e tests #245

Open
wants to merge 24 commits into
base: feat/token-registry-v4
Choose a base branch
from
Open

feat: e2e tests #245

wants to merge 24 commits into from

Conversation

osslgtm
Copy link
Contributor

@osslgtm osslgtm commented Dec 7, 2022

Summary

Validation, End-to-End tests with ganache to test if token-registry is working as intended

Changes

src/e2e containing the tests
package.json & config.yml to update ci workflow
src/implementations to detect if token registry is valid

Issues

@osslgtm osslgtm changed the title Feat/e2e tests feat: e2e tests Jan 19, 2023
@osslgtm osslgtm marked this pull request as ready for review January 19, 2023 01:58
Copy link
Contributor

@cavacado cavacado left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commenting after glancing; can u localise the error strings into constants as well?

Comment on lines 33 to 77
export const printLines = (lines: LineInfo[]): void => {
lines.sort((a: LineInfo, b: LineInfo): number => {
return a.lineNumber - b.lineNumber;
});
for (const line of lines) {
log(`${line.lineNumber}: ${line.lineContent}`);
}
};

export const extractLine = (result: string, query: string): LineInfo[] | void => {
const splitResults = result.trim().split("\n");
const matchedLines = [];
for (let count = 0; count < splitResults.length; count++) {
const line = splitResults[count].trim();
const containsQueryString = line.includes(query);
if (containsQueryString) {
matchedLines.push({
lineNumber: count,
lineContent: line,
});
}
}
if (matchedLines.length > 0) return matchedLines;
else return;
};

// https://github.com/chalk/strip-ansi/blob/main/index.js
export function stripAnsi(ansiString: string): string {
if (typeof ansiString !== "string") {
throw new TypeError(`Expected a \`string\`, got \`${typeof ansiString}\``);
}
return ansiString.replace(ansiRegex(), "");
}

// https://github.com/chalk/ansi-regex/blob/main/index.js
export function ansiRegex({ onlyFirst = false } = {}): RegExp {
const pattern = [
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))",
].join("|");

return new RegExp(pattern, onlyFirst ? undefined : "g");
}

export { shell, ShellString };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do u need to export these??

src/e2e/all.ts Outdated
awaitForDuration(nominate);
awaitForDuration(changeHolder);
awaitForDuration(endorseChangeOwner);
awaitForDuration(endorseTransfer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name this file index better

Comment on lines +22 to +28
const tokenInfo = await retrieveTokenInfo(signer, tokenRegistryAddress);
if (!(tokenInfo.name === tokenRegistryParameter.registryName)) {
throw new Error("tokenInfo.name === tokenRegistryParameter.registryName");
}
if (!(tokenInfo.symbol === tokenRegistryParameter.registrySymbol)) {
throw new Error("tokenInfo.symbol === tokenRegistryParameter.registrySymbol");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

y do we need to check for the name and symbol, when those are the parameters you specified?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's checking the values on the deployed token-registry rather than within oa-cli, not necessary but is of some use in case something is seriously broken on the smart contract level


const command = generateDeployDocumentStoreCommand(documentStoreParameters, owner.privateKey);
const results = run(command);
const tokenRegistrySuccessFormat = `${EndStatus.success} Document store Test Document Store deployed at `;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mistake?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the document store is called Test Document Store
So it's Document store ${Test Document Store} deployed at 0x0
The results of this has no fixed length so it had to match the results directly

import { getSigner, retrieveTokenInfo, rolesCheck } from "./utils/contract-checks";
import { checkTokenRegistrySuccess, defaultTokenRegistry } from "./utils/helpers";

export const deployTokenRegistry = async (): Promise<void> => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can add a suffixes to indicate its a e2e test?
hard to discern whether its a method or e2e (this goes for all the e2e entry point functions)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants