11const assert = require ( 'assert' ) ;
22const util = require ( './../util/util.js' ) ;
33
4- const ganache = require ( 'ganache-core-sc ' ) ;
4+ const client = require ( 'ganache-cli ' ) ;
55const Coverage = require ( './../../lib/coverage' ) ;
6+ const Api = require ( './../../lib/api' )
67
78describe ( 'logical OR branches' , ( ) => {
89 let coverage ;
9- let provider ;
10- let collector ;
10+ let api ;
1111
12- before ( async ( ) => ( { provider, collector } = await util . initializeProvider ( ganache ) ) ) ;
12+ before ( async ( ) => {
13+ api = new Api ( { silent : true } ) ;
14+ await api . ganache ( client ) ;
15+ } )
1316 beforeEach ( ( ) => coverage = new Coverage ( ) ) ;
14- after ( ( done ) => provider . close ( done ) ) ;
17+ after ( async ( ) => await api . finish ( ) ) ;
1518
1619 // if (x == 1 || x == 2) { } else ...
1720 it ( 'should cover an if statement with a simple OR condition (single branch)' , async function ( ) {
18- const contract = await util . bootstrapCoverage ( 'or/if-or' , provider , collector ) ;
21+ const contract = await util . bootstrapCoverage ( 'or/if-or' , api ) ;
1922 coverage . addContract ( contract . instrumented , util . filePath ) ;
2023 await contract . instance . a ( 1 ) ;
2124 const mapping = coverage . generate ( contract . data , util . pathPrefix ) ;
@@ -36,7 +39,7 @@ describe('logical OR branches', () => {
3639
3740 // if (x == 1 || x == 2) { } else ...
3841 it ( 'should cover an if statement with a simple OR condition (both branches)' , async function ( ) {
39- const contract = await util . bootstrapCoverage ( 'or/if-or' , provider , collector ) ;
42+ const contract = await util . bootstrapCoverage ( 'or/if-or' , api ) ;
4043 coverage . addContract ( contract . instrumented , util . filePath ) ;
4144 await contract . instance . a ( 1 ) ;
4245 await contract . instance . a ( 2 ) ;
@@ -59,7 +62,7 @@ describe('logical OR branches', () => {
5962
6063 // require(x == 1 || x == 2)
6164 it ( 'should cover a require statement with a simple OR condition (single branch)' , async function ( ) {
62- const contract = await util . bootstrapCoverage ( 'or/require-or' , provider , collector ) ;
65+ const contract = await util . bootstrapCoverage ( 'or/require-or' , api ) ;
6366 coverage . addContract ( contract . instrumented , util . filePath ) ;
6467 await contract . instance . a ( 1 ) ;
6568
@@ -85,7 +88,7 @@ describe('logical OR branches', () => {
8588 // x == 3
8689 // )
8790 it ( 'should cover a require statement with multiline OR condition (two branches)' , async function ( ) {
88- const contract = await util . bootstrapCoverage ( 'or/require-multiline-or' , provider , collector ) ;
91+ const contract = await util . bootstrapCoverage ( 'or/require-multiline-or' , api ) ;
8992 coverage . addContract ( contract . instrumented , util . filePath ) ;
9093 await contract . instance . a ( 1 ) ;
9194 await contract . instance . a ( 3 ) ;
@@ -108,7 +111,7 @@ describe('logical OR branches', () => {
108111
109112 // require(x == 1 || x == 2)
110113 it ( 'should cover a require statement with a simple OR condition (both branches)' , async function ( ) {
111- const contract = await util . bootstrapCoverage ( 'or/require-or' , provider , collector ) ;
114+ const contract = await util . bootstrapCoverage ( 'or/require-or' , api ) ;
112115 coverage . addContract ( contract . instrumented , util . filePath ) ;
113116 await contract . instance . a ( 1 ) ;
114117 await contract . instance . a ( 2 ) ;
@@ -131,7 +134,7 @@ describe('logical OR branches', () => {
131134
132135 // while( (x == 1 || x == 2) && counter < 2 ){
133136 it ( 'should cover a while statement with a simple OR condition (single branch)' , async function ( ) {
134- const contract = await util . bootstrapCoverage ( 'or/while-or' , provider , collector ) ;
137+ const contract = await util . bootstrapCoverage ( 'or/while-or' , api ) ;
135138 coverage . addContract ( contract . instrumented , util . filePath ) ;
136139 await contract . instance . a ( 1 ) ;
137140
@@ -153,7 +156,7 @@ describe('logical OR branches', () => {
153156
154157 // while( (x == 1 || x == 2) && counter < 2 ){
155158 it ( 'should cover a while statement with a simple OR condition (both branches)' , async function ( ) {
156- const contract = await util . bootstrapCoverage ( 'or/while-or' , provider , collector ) ;
159+ const contract = await util . bootstrapCoverage ( 'or/while-or' , api ) ;
157160 coverage . addContract ( contract . instrumented , util . filePath ) ;
158161 await contract . instance . a ( 1 ) ;
159162 await contract . instance . a ( 2 ) ;
@@ -176,7 +179,7 @@ describe('logical OR branches', () => {
176179
177180 // return (x == 1 && true) || (x == 2 && true);
178181 it ( 'should cover a return statement with ANDED OR conditions (single branch)' , async function ( ) {
179- const contract = await util . bootstrapCoverage ( 'or/return-or' , provider , collector ) ;
182+ const contract = await util . bootstrapCoverage ( 'or/return-or' , api ) ;
180183 coverage . addContract ( contract . instrumented , util . filePath ) ;
181184 await contract . instance . a ( 1 ) ;
182185
@@ -198,7 +201,7 @@ describe('logical OR branches', () => {
198201
199202 // return (x == 1 && true) || (x == 2 && true);
200203 it ( 'should cover a return statement with ANDED OR conditions (both branches)' , async function ( ) {
201- const contract = await util . bootstrapCoverage ( 'or/return-or' , provider , collector ) ;
204+ const contract = await util . bootstrapCoverage ( 'or/return-or' , api ) ;
202205 coverage . addContract ( contract . instrumented , util . filePath ) ;
203206 await contract . instance . a ( 1 ) ;
204207 await contract . instance . a ( 2 ) ;
@@ -221,7 +224,7 @@ describe('logical OR branches', () => {
221224
222225 //if (x == 1 && true || x == 2) {
223226 it ( 'should cover an if statement with OR and AND conditions (single branch)' , async function ( ) {
224- const contract = await util . bootstrapCoverage ( 'or/and-or' , provider , collector ) ;
227+ const contract = await util . bootstrapCoverage ( 'or/and-or' , api ) ;
225228 coverage . addContract ( contract . instrumented , util . filePath ) ;
226229 await contract . instance . a ( 1 ) ;
227230
@@ -243,7 +246,7 @@ describe('logical OR branches', () => {
243246
244247 //if (x == 1 && true || x == 2) {
245248 it ( 'should cover an if statement with OR and AND conditions (both branches)' , async function ( ) {
246- const contract = await util . bootstrapCoverage ( 'or/and-or' , provider , collector ) ;
249+ const contract = await util . bootstrapCoverage ( 'or/and-or' , api ) ;
247250 coverage . addContract ( contract . instrumented , util . filePath ) ;
248251 await contract . instance . a ( 1 ) ;
249252 await contract . instance . a ( 2 ) ;
@@ -266,7 +269,7 @@ describe('logical OR branches', () => {
266269
267270 // if ((x == 1) && (x == 2 || true)) {
268271 it ( 'should cover an if statement with bracked ANDED OR conditions (rightmost sub-branch)' , async function ( ) {
269- const contract = await util . bootstrapCoverage ( 'or/and-or-brackets' , provider , collector ) ;
272+ const contract = await util . bootstrapCoverage ( 'or/and-or-brackets' , api ) ;
270273 coverage . addContract ( contract . instrumented , util . filePath ) ;
271274 await contract . instance . a ( 1 ) ;
272275
@@ -288,7 +291,7 @@ describe('logical OR branches', () => {
288291
289292 // if ((x == 1) || (x == 2 || true)) {
290293 it ( 'should cover an if statement with multiple (bracketed) OR conditions (branch 1)' , async function ( ) {
291- const contract = await util . bootstrapCoverage ( 'or/multi-or' , provider , collector ) ;
294+ const contract = await util . bootstrapCoverage ( 'or/multi-or' , api ) ;
292295 coverage . addContract ( contract . instrumented , util . filePath ) ;
293296 await contract . instance . a ( 1 ) ;
294297
@@ -310,7 +313,7 @@ describe('logical OR branches', () => {
310313
311314 // if ((x == 1) || (x == 2 || true)) {
312315 it ( 'should cover an if statement with multiple (bracketed) OR conditions (branch 2)' , async function ( ) {
313- const contract = await util . bootstrapCoverage ( 'or/multi-or' , provider , collector ) ;
316+ const contract = await util . bootstrapCoverage ( 'or/multi-or' , api ) ;
314317 coverage . addContract ( contract . instrumented , util . filePath ) ;
315318 await contract . instance . a ( 2 ) ;
316319
@@ -332,7 +335,7 @@ describe('logical OR branches', () => {
332335
333336 // if ((x == 1) || (x == 2 || true)) {
334337 it ( 'should cover an if statement with multiple (bracketed) OR conditions (branch 3)' , async function ( ) {
335- const contract = await util . bootstrapCoverage ( 'or/multi-or' , provider , collector ) ;
338+ const contract = await util . bootstrapCoverage ( 'or/multi-or' , api ) ;
336339 coverage . addContract ( contract . instrumented , util . filePath ) ;
337340 await contract . instance . a ( 3 ) ;
338341
@@ -353,7 +356,7 @@ describe('logical OR branches', () => {
353356 } ) ;
354357
355358 it ( 'should cover the bzx example' , async function ( ) {
356- const contract = await util . bootstrapCoverage ( 'or/bzx-or' , provider , collector ) ;
359+ const contract = await util . bootstrapCoverage ( 'or/bzx-or' , api ) ;
357360 coverage . addContract ( contract . instrumented , util . filePath ) ;
358361 await contract . instance . a ( 3 ) ;
359362
0 commit comments