-
Notifications
You must be signed in to change notification settings - Fork 31
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
base: feat/token-registry-v4
Are you sure you want to change the base?
feat: e2e tests #245
Conversation
There was a problem hiding this 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?
src/e2e/utils/shell.ts
Outdated
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 }; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
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"); | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 `; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mistake?
There was a problem hiding this comment.
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
src/e2e/deploy.e2e.ts
Outdated
import { getSigner, retrieveTokenInfo, rolesCheck } from "./utils/contract-checks"; | ||
import { checkTokenRegistrySuccess, defaultTokenRegistry } from "./utils/helpers"; | ||
|
||
export const deployTokenRegistry = async (): Promise<void> => { |
There was a problem hiding this comment.
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)
* feat(token-registry)!: token registry v4
BREAKING CHANGE: Token Registry V4
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