diff --git a/packages/core/src/implementations/business/QueryService.ts b/packages/core/src/implementations/business/QueryService.ts index 95d4f7ae50..7ecb9cfe26 100644 --- a/packages/core/src/implementations/business/QueryService.ts +++ b/packages/core/src/implementations/business/QueryService.ts @@ -166,9 +166,7 @@ export class QueryService implements IQueryService { | QueryFormatError | EvaluationError > { - console.log( - `Processing query for consent contract ${consentContractAddress} with CID ${query.cid}`, - ); + //console.log(`Processing query for consent contract ${consentContractAddress} with CID ${query.cid}`,); return ResultUtils.combine([ this.contextProvider.getContext(), this.configProvider.getConfig(), @@ -188,7 +186,7 @@ export class QueryService implements IQueryService { const maps2 = maps as [InsightString[], EligibleReward[]]; const insights = maps2[0]; const rewards = maps2[1]; - console.log("insights: ", insights); + //console.log("insights: ", insights); // console.log("rewards: ", rewards); // console.log(insights, rewards); @@ -200,7 +198,7 @@ export class QueryService implements IQueryService { query.cid, insights, ).map(() => { - console.log("insight delivery api call done"); + // console.log("insight delivery api call done"); // context.publicEvents.onQueryPosted.next({ // consentContractAddress, // query, diff --git a/packages/core/src/implementations/business/utilities/query/BalanceQueryEvaluator.ts b/packages/core/src/implementations/business/utilities/query/BalanceQueryEvaluator.ts index 0a37183519..ce2bfecd4e 100644 --- a/packages/core/src/implementations/business/utilities/query/BalanceQueryEvaluator.ts +++ b/packages/core/src/implementations/business/utilities/query/BalanceQueryEvaluator.ts @@ -51,7 +51,6 @@ export class BalanceQueryEvaluator implements IBalanceQueryEvaluator { balance: BigNumber.from("0"), }; }) - console.log("TokenBalances: ", tokenBalances) return okAsync(tokenBalances); } ).andThen( (balanceArray) => { @@ -70,32 +69,31 @@ export class BalanceQueryEvaluator implements IBalanceQueryEvaluator { //console.log("Condition: ", condition); //console.log("balanceArray: ", balanceArray); let val: BigNumber = BigNumber.from(0); - console.log("Val: ", val.toNumber()); switch (condition.constructor) { case ConditionGE: val = BigNumber.from((condition as ConditionGE).rval); - console.log("val: ", val.toNumber()); + //console.log("val: ", val.toNumber()); balanceArray = balanceArray.filter((balance) => BigNumber.from((balance.balance)).toNumber() >= val.toNumber()); - console.log("BalanceArray: ", balanceArray); + //console.log("BalanceArray: ", balanceArray); break; case ConditionG: val = BigNumber.from((condition as ConditionG).rval); - console.log("val: ", val.toNumber()); + //console.log("val: ", val.toNumber()); balanceArray = balanceArray.filter((balance) => BigNumber.from((balance.balance)).toNumber() > val.toNumber()); break; case ConditionL: val = BigNumber.from((condition as ConditionL).rval); - console.log("val: ", val.toNumber()); + //console.log("val: ", val.toNumber()); balanceArray = balanceArray.filter((balance) => BigNumber.from((balance.balance)).toNumber() < val.toNumber()); break; case ConditionE: val = BigNumber.from((condition as ConditionE).rval); - console.log("val: ", val.toNumber()); + //console.log("val: ", val.toNumber()); balanceArray = balanceArray.filter((balance) => BigNumber.from((balance.balance)).toNumber() == val.toNumber()); break; case ConditionLE: val = BigNumber.from((condition as ConditionLE).rval); - console.log("val: ", val.toNumber()); + //console.log("val: ", val.toNumber()); balanceArray = balanceArray.filter((balance) => BigNumber.from((balance.balance)).toNumber() <= val.toNumber()); break; diff --git a/packages/core/test/unit/business/QueryService.test.ts b/packages/core/test/unit/business/QueryService.test.ts index 05f4d1c483..9247a1f952 100644 --- a/packages/core/test/unit/business/QueryService.test.ts +++ b/packages/core/test/unit/business/QueryService.test.ts @@ -260,7 +260,7 @@ describe("processQuery tests", () => { await queryService .processQuery(consentContractAddress, sdqlQuery) .andThen((result) => { - console.log("result", result); + //console.log("result", result); expect(result).toBeUndefined(); // expect(result.isOk()).toBeTruthy(); return okAsync(true); diff --git a/packages/core/test/unit/business/query/AST_Evaluator.test.ts b/packages/core/test/unit/business/query/AST_Evaluator.test.ts index 1fb1ed6f73..3b0b023f29 100644 --- a/packages/core/test/unit/business/query/AST_Evaluator.test.ts +++ b/packages/core/test/unit/business/query/AST_Evaluator.test.ts @@ -29,7 +29,9 @@ import { ConditionL, ConditionOr, } from "@core/interfaces/objects"; -import { IQueryFactories } from "@core/interfaces/utilities/factory"; +import { IQueryFactories, IQueryObjectFactory } from "@core/interfaces/utilities/factory"; +import { IBalanceQueryEvaluator } from "@core/interfaces/business/utilities/query/IBalanceQueryEvaluator"; +import { BalanceQueryEvaluator } from "@core/implementations/business/utilities/query/BalanceQueryEvaluator"; // const ast = new AST( // Version("0.1"), @@ -39,20 +41,24 @@ import { IQueryFactories } from "@core/interfaces/utilities/factory"; class ASTMocks { public persistenceRepo = td.object(); + public queryObjectFactory = td.object(); + public queryFactories: IQueryFactories; // protected queryRepository = td.object(); public queryRepository: QueryRepository; public queryEvaluator: QueryEvaluator; + public balanceQueryEvaluator: IBalanceQueryEvaluator; public constructor() { - this.queryFactories = new QueryFactories(); + this.queryFactories = new QueryFactories(this.queryObjectFactory); + this.balanceQueryEvaluator = new BalanceQueryEvaluator(this.persistenceRepo); td.when(this.persistenceRepo.getAge()).thenReturn(okAsync(Age(25))); td.when(this.persistenceRepo.getLocation()).thenReturn( okAsync(CountryCode("1")), ); - this.queryEvaluator = new QueryEvaluator(this.persistenceRepo); + this.queryEvaluator = new QueryEvaluator(this.persistenceRepo, this.balanceQueryEvaluator); this.queryRepository = new QueryRepository(this.queryEvaluator); } diff --git a/packages/core/test/unit/business/query/BalanceQueryEvaluator.test.ts b/packages/core/test/unit/business/query/BalanceQueryEvaluator.test.ts index 1438fec394..e51e08e496 100644 --- a/packages/core/test/unit/business/query/BalanceQueryEvaluator.test.ts +++ b/packages/core/test/unit/business/query/BalanceQueryEvaluator.test.ts @@ -156,7 +156,7 @@ describe("BalanceQueryEvaluator", () => { const balanceQuery = new AST_BalanceQuery( SDQL_Name("q7"), "array", - "*", + null, // * - for all, use null [], ) // >= 20 and < 30 diff --git a/packages/core/test/unit/business/query/ExprParser.test.ts b/packages/core/test/unit/business/query/ExprParser.test.ts index f4ca678cec..e2a8cc82e3 100644 --- a/packages/core/test/unit/business/query/ExprParser.test.ts +++ b/packages/core/test/unit/business/query/ExprParser.test.ts @@ -1,11 +1,12 @@ import "reflect-metadata"; -import { IpfsCID } from "@objects/primitives"; +import { IpfsCID, SDQLString } from "@objects/primitives"; import { avalance1SchemaStr } from "./avalanche1.data"; import { ExprParser, + QueryObjectFactory, SDQLParser, Token, Tokenizer, @@ -22,6 +23,9 @@ import { ConditionOr, SDQLSchema, } from "@core/interfaces/objects/SDQL"; +import { IQueryObjectFactory } from "@core/interfaces/utilities/factory"; +import td from "testdouble"; + // import { ExprParser } from "businessObjects/SDQL/ExprParser"; // import { Token, Tokenizer, TokenType } from "businessObjects/SDQL/Tokenizer"; // import { IpfsCID } from "primitives"; @@ -339,8 +343,10 @@ describe("Postfix expressions", () => { }); describe("Postfix to AST", () => { - const schema = SDQLSchema.fromString(avalance1SchemaStr); - const parser = new SDQLParser(IpfsCID("0"), schema); + const schema = SDQLSchema.fromString(SDQLString(avalance1SchemaStr)); + let queryObjectFactory = td.object(); + + const parser = new SDQLParser(IpfsCID("0"), schema, queryObjectFactory); parser.buildAST(); const context = parser.context; diff --git a/packages/core/test/unit/business/query/QueryEvaluator.test.ts b/packages/core/test/unit/business/query/QueryEvaluator.test.ts index 1ba30744f1..d6ca521de0 100644 --- a/packages/core/test/unit/business/query/QueryEvaluator.test.ts +++ b/packages/core/test/unit/business/query/QueryEvaluator.test.ts @@ -904,7 +904,7 @@ describe("Return Chain Transaction Count", () => { }) }) - +/* describe("BalanceQueryEvaluator", () => { test("Return Query Balance Array - 1 Chain ID, 20 <= x < 30", async () => { const balanceQuery = new AST_BalanceQuery( @@ -955,3 +955,4 @@ describe("BalanceQueryEvaluator", () => { expect(result["value"].length).toEqual(4) }) }) +*/ \ No newline at end of file