1
1
const { duration, latestTime } = require ( './helpers/latestTime.js' ) ;
2
+ const { logGasUsed } = require ( './helpers/gas.js' )
2
3
3
4
const Escrow = artifacts . require ( 'market/Escrow.sol' )
4
5
const Token = artifacts . require ( 'tokens/SingularityNetToken.sol' )
@@ -22,9 +23,11 @@ contract('Escrow', function ([payee, payer, validator]) {
22
23
const jobDescriptor = "0x01"
23
24
//Complete jobs
24
25
25
- await this . token . approve ( this . escrow . address , amount , { from : payer } )
26
+ const approveResult = await this . token . approve ( this . escrow . address , amount , { from : payer } )
27
+ logGasUsed ( 'token.approve' , approveResult )
28
+
26
29
const result = await this . escrow . deposit ( amount , jobDescriptor , { from : payer } )
27
-
30
+ logGasUsed ( 'escrow.deposit' , result )
28
31
29
32
const found2 = result . logs . find ( e => e . event === 'Deposited' )
30
33
assert . strictEqual ( found2 . event , 'Deposited' , 'Deposited event not fired' )
@@ -76,6 +79,7 @@ contract('Escrow', function ([payee, payer, validator]) {
76
79
await this . escrow . deposit ( amount , jobDescriptor , { from : payer } )
77
80
await this . escrow . setResult ( jobResult , { from : payee } )
78
81
const result = await this . escrow . accept ( { from : payer } )
82
+ logGasUsed ( 'escrow.setResult' , result )
79
83
80
84
const found = result . logs . find ( e => e . event === 'Accepted' )
81
85
assert . strictEqual ( found . event , 'Accepted' , 'Accepted event not fired' )
@@ -92,6 +96,7 @@ contract('Escrow', function ([payee, payer, validator]) {
92
96
const time = ( await this . escrow . end . call ( ) ) + duration . minutes ( 10 )
93
97
await increaseTimeTo ( time )
94
98
let result = await this . escrow . withdraw ( { from : payee } )
99
+ logGasUsed ( 'escrow.withdraw' , result )
95
100
const found = result . logs . find ( e => e . event === 'Withdrew' )
96
101
assert . strictEqual ( found . event , 'Withdrew' , 'Withdrew event not fired' )
97
102
0 commit comments