File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed
packages/taco/integration-test Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff 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) ;
Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments