@@ -237,15 +237,13 @@ describe('Integration tests', function () {
237237 let accountsInitBalances = [
238238 {
239239 address : proxyAddress ,
240- balance : ( await iexecPoco . balanceOf ( proxyAddress ) ) . toNumber ( ) ,
241240 frozen : ( await iexecPoco . frozenOf ( proxyAddress ) ) . toNumber ( ) ,
242241 } ,
243242 ] ;
244243 for ( const account of acounts ) {
245244 let address = account . address ;
246- let balance = ( await iexecPoco . balanceOf ( account . address ) ) . toNumber ( ) ;
247245 let frozen = ( await iexecPoco . frozenOf ( account . address ) ) . toNumber ( ) ;
248- accountsInitBalances . push ( { address, balance , frozen } ) ;
246+ accountsInitBalances . push ( { address, frozen } ) ;
249247 }
250248 for ( let i = 0 ; i < workerNumber ; i ++ ) {
251249 expect ( await iexecPoco . viewScore ( workers [ i ] . address ) ) . to . be . equal ( 0 ) ;
@@ -265,28 +263,36 @@ describe('Integration tests', function () {
265263 . reveal ( taskId , resultDigest )
266264 . then ( ( tx ) => tx . wait ( ) ) ;
267265 }
268- await iexecPoco
266+ const finalizeTx = await iexecPoco
269267 . connect ( scheduler )
270- . finalize ( taskId , results , '0x' )
271- . then ( ( tx ) => tx . wait ( ) ) ;
268+ . finalize ( taskId , results , '0x' ) ;
269+ expect ( finalizeTx ) . to . changeTokenBalances (
270+ iexecPoco ,
271+ [ proxyAddress , requester , scheduler , appProvider , datasetProvider ] ,
272+ [
273+ - ( dealPrice + schedulerStakePerDeal ) ,
274+ 0 ,
275+ schedulerStakePerTask + schedulerRewardPerTask ,
276+ appPrice ,
277+ datasetPrice ,
278+ ] ,
279+ ) ;
280+ for ( let i = 0 ; i < workerNumber ; i ++ ) {
281+ expect ( finalizeTx ) . to . changeTokenBalances (
282+ iexecPoco ,
283+ [ workers [ i ] ] ,
284+ [ workerStake + workerRewardPerTask / workerNumber ] ,
285+ ) ;
286+ }
272287 expect ( ( await iexecPoco . viewTask ( taskId ) ) . status ) . to . equal (
273288 TaskStatusEnum . COMPLETED ,
274289 ) ;
275- const expectedBalanceChanges = [
276- - ( dealPrice + schedulerStakePerDeal ) ,
277- 0 ,
278- schedulerStakePerTask + schedulerRewardPerTask ,
279- appPrice ,
280- datasetPrice ,
281- ] ;
282290 const expectedFrozenChanges = [ 0 , - taskPrice , - schedulerStakePerTask , 0 , 0 ] ;
283291 for ( let i = 0 ; i < workerNumber ; i ++ ) {
284- expectedBalanceChanges . push ( workerStake + workerRewardPerTask / workerNumber ) ;
285292 expectedFrozenChanges . push ( 0 ) ;
286293 }
287- await changesInBalancesAndFrozens ( {
294+ await changesInFrozen ( {
288295 accountsInitBalances,
289- balanceChanges : expectedBalanceChanges ,
290296 frozenChanges : expectedFrozenChanges ,
291297 } ) ;
292298 for ( let i = 0 ; i < workerNumber ; i ++ ) {
@@ -314,17 +320,12 @@ async function checkBalancesAndFrozens(args: {
314320 }
315321}
316322
317- async function changesInBalancesAndFrozens ( args : {
318- accountsInitBalances : { address : string ; balance : number ; frozen : number } [ ] ;
319- balanceChanges : number [ ] ;
323+ async function changesInFrozen ( args : {
324+ accountsInitBalances : { address : string ; frozen : number } [ ] ;
320325 frozenChanges : number [ ] ;
321326} ) {
322327 for ( let i = 0 ; i < args . accountsInitBalances . length ; i ++ ) {
323328 const message = `Failed with account at index ${ i } ` ;
324- expect ( await iexecPoco . balanceOf ( args . accountsInitBalances [ i ] . address ) ) . to . equal (
325- args . accountsInitBalances [ i ] . balance + args . balanceChanges [ i ] ,
326- message ,
327- ) ;
328329 expect ( await iexecPoco . frozenOf ( args . accountsInitBalances [ i ] . address ) ) . to . equal (
329330 args . accountsInitBalances [ i ] . frozen + args . frozenChanges [ i ] ,
330331 message ,
0 commit comments