Skip to content

Commit

Permalink
Merge pull request #2181 from demergent-labs/certified_data_prop_test
Browse files Browse the repository at this point in the history
Certified data prop test
  • Loading branch information
lastmjs authored Dec 10, 2024
2 parents 5d264b8 + f9c62ab commit 6e65dd1
Show file tree
Hide file tree
Showing 64 changed files with 6,451 additions and 3,831 deletions.
2 changes: 1 addition & 1 deletion benchmark/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,7 @@ function format_number_to_rust(number: string | number | bigint): string {
(number_is_negative === false && Number(number) < 1) ||
(number_is_negative === true && Number(number) > -1);

if (number_is_decimal_less_than_one) {
if (number_is_decimal_less_than_one === true) {
return number.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function onBeforeExit(paths: [Src, Dest][], actor: UploaderActor): void {
let cleanUpComplete = false;

process.on('beforeExit', async () => {
if (cleanUpComplete) {
if (cleanUpComplete === true) {
// If any async behavior happens in 'beforeExit' then 'beforeExit'
// will run again. This is need to prevent an infinite loop.
// Once clean up is complete we are ready to exit
Expand Down
2 changes: 1 addition & 1 deletion src/lib/experimental/candid/serde/decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function decodeSingle(candidType: CandidType, data: ArrayBuffer): any {
// The candid type was AzleVoid if when converted to an Idl Type it is []
const candidTypeWasAzleVoid = Array.isArray(idlType);

if (candidTypeWasAzleVoid) {
if (candidTypeWasAzleVoid === true) {
return undefined;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/experimental/candid/serde/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function encodeSingle(candidType: CandidType, data: any): Uint8Array {
// The candid type was AzleVoid if when converted to an Idl Type it is []
const candidTypeWasAzleVoid = Array.isArray(idlType);

if (candidTypeWasAzleVoid) {
if (candidTypeWasAzleVoid === true) {
return new Uint8Array(IDL.encode([], []));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function serviceCall(
) => {
const encodedArgs = encode(paramCandidTypes, args);

if (notify) {
if (notify === true) {
return (callFunction as NotifyRawFunction)(
canisterId,
methodName,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/experimental/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ if (globalThis._azleInsideCanister === true) {

RegExp.prototype.exec = function (string): RegExpExecArray | null {
const match = originalExec.call(this, string);
if (match) {
if (match !== null) {
RegExp.leftContext = (string ?? '').substring(0, match.index);
}
return match;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/stable/did_file/visitor/visit/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function serviceToCandidString(
postMethodCandidString
);

if (isFirstService) {
if (isFirstService === true) {
return [
`service: ${canisterParamsString} -> {\n${funcStrings}\n}`,
candidTypes
Expand Down
4 changes: 2 additions & 2 deletions src/lib/stable/ic_apis/data_certificate.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* When called from a query call, returns the data certificate
* authenticating `certifiedData` set by this canister. Otherwise returns
* `None`.
* @returns the data certificate or None
* `undefined`.
* @returns the data certificate or undefined
*/
export function dataCertificate(): Uint8Array | undefined {
if (
Expand Down
8 changes: 4 additions & 4 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export function runTests(
const { shouldRunTests, shouldRunTypeChecks, shouldRecordBenchmarks } =
processEnvVars();

if (shouldRunTests) {
if (shouldRunTests === true) {
describe(`tests`, tests);
}

if (shouldRunTypeChecks) {
if (shouldRunTypeChecks === true) {
describe(`type checks`, () => {
it('checks types', () => {
try {
Expand All @@ -47,7 +47,7 @@ export function runTests(
});
}

if (shouldRecordBenchmarks && canisterNames !== undefined) {
if (shouldRecordBenchmarks === true && canisterNames !== undefined) {
const canisterNamesArray = Array.isArray(canisterNames)
? canisterNames
: [canisterNames];
Expand Down Expand Up @@ -154,5 +154,5 @@ function processEnvVars(): {
}

function shouldRun(envVar: string, hasOnly: boolean): boolean {
return hasOnly ? envVar === 'only' : envVar !== 'false';
return hasOnly === true ? envVar === 'only' : envVar !== 'false';
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function generateVariableAliasDeclarations(
innerType: CandidDefinition,
api: Api
): string[] {
if (useTypeDeclaration) {
if (useTypeDeclaration === true) {
const type =
api === 'functional'
? []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function generateVariableAliasDeclarations(
const fieldVariableAliasDeclarations = fields.flatMap(
(field): string[] => field[1].candidMeta.variableAliasDeclarations
);
if (useTypeDeclaration) {
if (useTypeDeclaration === true) {
const type =
api === 'functional'
? []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function generateVariableAliasDeclarations(
const fieldVariableAliasDeclarations = fields.flatMap(
(field) => field.candidMeta.variableAliasDeclarations
);
if (useTypeDeclaration) {
if (useTypeDeclaration === true) {
const type =
api === 'functional'
? []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function generateVariableAliasDeclarations(
const fieldVariableAliasDeclarations = fields.flatMap(
(field): string[] => field[1].candidMeta.variableAliasDeclarations
);
if (useTypeDeclaration) {
if (useTypeDeclaration === true) {
const type =
api === 'functional'
? []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function generateVariableAliasDeclarations(
innerType: CandidDefinition,
api: Api
): string[] {
if (useTypeDeclaration) {
if (useTypeDeclaration === true) {
const type =
api === 'functional'
? []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function generateVariableAliasDeclarations(
const serviceMethodTypeAliasDecls = serviceMethods.flatMap(
(serviceMethod) => serviceMethod.variableAliasDeclarations
);
if (useTypeDeclaration) {
if (useTypeDeclaration === true) {
const type = api === 'functional' ? [] : [`type ${name} = Principal`];
return [
...serviceMethodTypeAliasDecls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function generateVariableAliasDeclarations(
useTypeDeclaration: boolean,
api: Api
): string[] {
if (useTypeDeclaration) {
if (useTypeDeclaration === true) {
if (api === 'class') {
return [
`const ${name} = ${toIDL(candidType)};`,
Expand Down
8 changes: 4 additions & 4 deletions test/property/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export async function runTests(
console.info('\x1b[31m', `${result.Err}`);
console.info('\x1b[0m');

if (exitProcess) {
if (exitProcess === true) {
process.exit(1);
} else {
return false;
Expand All @@ -78,7 +78,7 @@ export async function runTests(
}
console.info('\x1b[0m');

if (exitProcess) {
if (exitProcess === true) {
process.exit(1);
} else {
return false;
Expand All @@ -95,7 +95,7 @@ export async function runTests(
);
console.info('\x1b[0m');

if (exitProcess) {
if (exitProcess === true) {
process.exit(1);
} else {
return false;
Expand Down Expand Up @@ -148,7 +148,7 @@ export function createSnakeCaseProxy<T extends object>(
: camelToSnakeCase(prop as string);

if (typeof (obj as any)[snakeCaseProp] === 'function') {
if (async) {
if (async === true) {
return async (...args: any[]) => {
const new_args = args.map((value) => {
return convertKeysToSnakeCase(value);
Expand Down
Loading

0 comments on commit 6e65dd1

Please sign in to comment.