This repository was archived by the owner on Mar 23, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +35
-9
lines changed Expand file tree Collapse file tree 6 files changed +35
-9
lines changed Original file line number Diff line number Diff line change 1
1
// A helper file to configure chai with all the plugins we need
2
2
// This is to reduce noise in our actual test files
3
3
4
+ import chaiBn = require( "bn-chai" ) ;
4
5
import { tv4 , use } from "chai" ;
5
6
import chaiAsPromised from "chai-as-promised" ;
6
7
import chaiEach = require( "chai-each" ) ;
7
8
import chaiHttp = require( "chai-http" ) ;
8
9
import chaiJsonSchema = require( "chai-json-schema" ) ;
9
10
import chaiSubset = require( "chai-subset" ) ;
11
+ import { BigNumber } from "ethers/utils" ;
10
12
import * as sirenJsonSchema from "../siren.schema.json" ;
11
13
12
14
use ( chaiAsPromised ) ;
13
15
use ( chaiHttp ) ;
14
16
use ( chaiSubset ) ;
15
17
use ( chaiEach ) ;
16
18
use ( chaiJsonSchema ) ;
19
+ use ( chaiBn ( BigNumber ) ) ;
17
20
18
21
tv4 . addSchema ( "http://sirenspec.org/schema" , sirenJsonSchema ) ;
Original file line number Diff line number Diff line change @@ -204,6 +204,16 @@ export class Actor {
204
204
}
205
205
206
206
public async assertSwapped ( ) {
207
+ this . logger . debug ( "Checking if cnd reports status 'SWAPPED'" ) ;
208
+
209
+ while ( true ) {
210
+ await sleep ( 200 ) ;
211
+ const entity = await this . swap . fetchDetails ( ) ;
212
+ if ( entity . properties . status === "SWAPPED" ) {
213
+ break ;
214
+ }
215
+ }
216
+
207
217
for ( const [
208
218
assetKind ,
209
219
expectedBalanceChange ,
@@ -222,15 +232,10 @@ export class Actor {
222
232
) . add ( expectedBalanceChange ) ;
223
233
const maximumFee = wallet . MaximumFee ;
224
234
225
- await expect (
226
- wallet
227
- . getBalance ( )
228
- . then ( balance =>
229
- new BigNumber ( balance ) . gte (
230
- expectedBalance . sub ( maximumFee )
231
- )
232
- )
233
- ) . to . eventually . be . true ;
235
+ const balanceInclFees = expectedBalance . sub ( maximumFee ) ;
236
+ const currentWalletBalance = await wallet . getBalance ( ) ;
237
+
238
+ expect ( currentWalletBalance ) . to . be . gte . BN ( balanceInclFees ) ;
234
239
}
235
240
}
236
241
Original file line number Diff line number Diff line change 35
35
"bignumber.js" : " ^9.0.0" ,
36
36
"bitcoin-core" : " ^3.0.0" ,
37
37
"bitcoinjs-lib" : " ^5.1.6" ,
38
+ "bn-chai" : " ^1.0.1" ,
38
39
"chai" : " ^4.2.0" ,
39
40
"chai-as-promised" : " ^7.1.1" ,
40
41
"chai-each" : " ^0.0.1" ,
Original file line number Diff line number Diff line change 13
13
"no-shadowed-variable" : false ,
14
14
"object-literal-sort-keys" : false ,
15
15
"no-reference" : false ,
16
+ "no-namespace" : false ,
16
17
"only-arrow-functions" : false ,
17
18
"file-name-casing" : [true , " snake-case" ]
18
19
},
Original file line number Diff line number Diff line change
1
+ declare module "bn-chai" {
2
+ function bnChaiFn ( ctor : any ) : Chai . ChaiPlugin ;
3
+
4
+ export = bnChaiFn ;
5
+ }
6
+
7
+ declare namespace Chai {
8
+ interface NumberComparer {
9
+ BN ( value : any ) : void ;
10
+ }
11
+ }
Original file line number Diff line number Diff line change @@ -590,6 +590,11 @@ bmutex@~0.1.6:
590
590
dependencies :
591
591
bsert "~0.0.10"
592
592
593
+ bn-chai@^1.0.1 :
594
+ version "1.0.1"
595
+ resolved "https://registry.yarnpkg.com/bn-chai/-/bn-chai-1.0.1.tgz#5d6e9654162602a527b08a1546e60cfb44213725"
596
+ integrity sha512-7rJXt21DwYiLLpvzLaACixBBoUGkRV1iuFD3wElEhw8Ji9IiY/QsJRtvW+c7ChRgEOyLQkGaSGFUUqBKm21SNA==
597
+
593
598
bn.js@^4.11.8, bn.js@^4.4.0 :
594
599
version "4.11.8"
595
600
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f"
You can’t perform that action at this time.
0 commit comments