Skip to content

Commit a1852c0

Browse files
committed
Add integration test for variable operation usage; lingo and encrypt/decrypt test.
1 parent b15e380 commit a1852c0

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

packages/taco/integration-test/condition-lingo.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,44 @@ describe.skipIf(!process.env.RUNNING_IN_CI)(
173173
const conditionExpr = new ConditionExpression(contextVariableCondition);
174174
await validateConditionExpression(conditionExpr);
175175
}, 15000);
176+
177+
test('validate conditions with operations', async () => {
178+
const sequentialCondition = new SequentialCondition({
179+
conditionVariables: [
180+
{
181+
varName: 'rpcValue',
182+
condition: testRpcConditionObj,
183+
operations: [
184+
{ operation: 'abs' },
185+
{ operation: '^=', value: BigInt('1000000000000000') },
186+
],
187+
},
188+
{
189+
// add some operations
190+
varName: 'timeValue',
191+
condition: {
192+
...testTimeConditionObj,
193+
returnValueTest: {
194+
comparator: '>',
195+
value: 100,
196+
operations: [
197+
{ operation: 'abs' },
198+
{ operation: 'index', value: 0 },
199+
{ operation: '+=', value: 5 },
200+
{ operation: '*=', value: ':multiplier' }, // context variable
201+
],
202+
},
203+
},
204+
},
205+
{
206+
varName: 'contractValue',
207+
condition: testContractConditionObj,
208+
operations: [{ operation: '-=', value: 5.5 }],
209+
},
210+
],
211+
});
212+
const conditionExpr = new ConditionExpression(sequentialCondition);
213+
await validateConditionExpression(conditionExpr);
214+
}, 15000);
176215
},
177216
);

packages/taco/integration-test/encrypt-decrypt.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ describe.skipIf(!process.env.RUNNING_IN_CI)(
6969
},
7070
});
7171

72+
const positiveBalanceWithOperation = new conditions.base.rpc.RpcCondition(
73+
{
74+
chain: CHAIN_ID,
75+
method: 'eth_getBalance',
76+
parameters: [':userAddress', 'latest'],
77+
returnValueTest: {
78+
comparator: '==',
79+
value: 0,
80+
// no-op operations
81+
operations: [
82+
{ operation: '*=', value: 0 },
83+
{ operation: 'abs' },
84+
{ operation: 'int' },
85+
],
86+
},
87+
},
88+
);
89+
7290
const balanceLessThanMaxUintBigInt = new conditions.base.rpc.RpcCondition(
7391
{
7492
chain: CHAIN_ID,
@@ -84,6 +102,7 @@ describe.skipIf(!process.env.RUNNING_IN_CI)(
84102
const compoundCondition = CompoundCondition.and([
85103
hasPositiveBalance,
86104
balanceLessThanMaxUintBigInt,
105+
positiveBalanceWithOperation,
87106
]);
88107

89108
const messageKit = await encrypt(

0 commit comments

Comments
 (0)