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

Conf parsing #70

Open
matteo-cristino opened this issue Feb 13, 2024 · 0 comments
Open

Conf parsing #70

matteo-cristino opened this issue Feb 13, 2024 · 0 comments

Comments

@matteo-cristino
Copy link
Collaborator

Some zneroom config breaks the json logs format, for examaple

  • debug=3 or higher
  • logfmt=text

and breaking the json logs format brings to slngroom failing to execute the function

export const getIgnoredStatements = async (
contract: string,
params: ZenParams,
): Promise<string[]> => {
// Since we want to get the list of ignored statements, we don't want to
// throw if Zenroom execution fails (but we do fail if something other than
// that happens). When Zenroom fails, the ZenroomError type's message
// contains the logs.
let logs: string[];
try {
// TODO: the zencodeExec() call could potentially be optimized, as
// zencodeExec() parses the output result. Keep in mind: optimization bad.
const zout = await zencodeExec(contract, params);
logs = JSON.parse(zout.logs);
} catch (e) {
// Currently, only ZenError is available.
// Normally, I'd let this code be, but we're trying to achieve 100%
// coverage, so my "future-proof" code needs to be commented out here.
// if (!(e instanceof ZenroomError))
// throw e;
logs = JSON.parse(e.message);
}
const regexIgnored = /(?<=\[W\] Zencode line [0-9]+ pattern ignored: ).*/;
return logs.flatMap((log) => log.match(regexIgnored) || []);
};

Thus slangroom should parse the conf in input and return an error in case one of the above conf is found

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

No branches or pull requests

1 participant