1
- import { initSimnet } from "@hirosystems/clarinet-sdk" ;
2
1
import { Cl , cvToValue } from "@stacks/transactions" ;
3
2
import { describe , expect , it } from "vitest" ;
4
3
@@ -46,9 +45,8 @@ const expectedBlock0Resource1 = Buffer.from(
46
45
) ;
47
46
48
47
describe ( "Adding a resource" , ( ) => {
49
- it ( "add-resource() fails if not called by deployer" , async ( ) => {
48
+ it ( "add-resource() fails if not called by deployer" , ( ) => {
50
49
// ARRANGE
51
- const simnet = await initSimnet ( ) ;
52
50
const accounts = simnet . getAccounts ( ) ;
53
51
const address1 = accounts . get ( "wallet_1" ) ! ;
54
52
// ACT
@@ -62,9 +60,8 @@ describe("Adding a resource", () => {
62
60
expect ( response . result ) . toBeErr ( Cl . uint ( ErrCode . ERR_UNAUTHORIZED ) ) ;
63
61
} ) ;
64
62
65
- it ( "add-resource() fails if name is blank" , async ( ) => {
63
+ it ( "add-resource() fails if name is blank" , ( ) => {
66
64
// ARRANGE
67
- const simnet = await initSimnet ( ) ;
68
65
const accounts = simnet . getAccounts ( ) ;
69
66
const deployer = accounts . get ( "deployer" ) ! ;
70
67
// ACT
@@ -78,9 +75,8 @@ describe("Adding a resource", () => {
78
75
expect ( response . result ) . toBeErr ( Cl . uint ( ErrCode . ERR_INVALID_PARAMS ) ) ;
79
76
} ) ;
80
77
81
- it ( "add-resource() fails if description is blank" , async ( ) => {
78
+ it ( "add-resource() fails if description is blank" , ( ) => {
82
79
// ARRANGE
83
- const simnet = await initSimnet ( ) ;
84
80
const accounts = simnet . getAccounts ( ) ;
85
81
const deployer = accounts . get ( "deployer" ) ! ;
86
82
// ACT
@@ -94,9 +90,8 @@ describe("Adding a resource", () => {
94
90
expect ( response . result ) . toBeErr ( Cl . uint ( ErrCode . ERR_INVALID_PARAMS ) ) ;
95
91
} ) ;
96
92
97
- it ( "add-resource() fails if price is 0" , async ( ) => {
93
+ it ( "add-resource() fails if price is 0" , ( ) => {
98
94
// ARRANGE
99
- const simnet = await initSimnet ( ) ;
100
95
const accounts = simnet . getAccounts ( ) ;
101
96
const deployer = accounts . get ( "deployer" ) ! ;
102
97
// ACT
@@ -109,9 +104,8 @@ describe("Adding a resource", () => {
109
104
// ASSERT
110
105
expect ( response . result ) . toBeErr ( Cl . uint ( ErrCode . ERR_INVALID_PARAMS ) ) ;
111
106
} ) ;
112
- it ( "add-resource() fails if name already used" , async ( ) => {
107
+ it ( "add-resource() fails if name already used" , ( ) => {
113
108
// ARRANGE
114
- const simnet = await initSimnet ( ) ;
115
109
const accounts = simnet . getAccounts ( ) ;
116
110
const deployer = accounts . get ( "deployer" ) ! ;
117
111
const expectedCount = 1 ;
@@ -135,9 +129,8 @@ describe("Adding a resource", () => {
135
129
) ;
136
130
} ) ;
137
131
138
- it ( "add-resource() succeeds and increments resource count" , async ( ) => {
132
+ it ( "add-resource() succeeds and increments resource count" , ( ) => {
139
133
// ARRANGE
140
- const simnet = await initSimnet ( ) ;
141
134
const accounts = simnet . getAccounts ( ) ;
142
135
const deployer = accounts . get ( "deployer" ) ! ;
143
136
const expectedCount = 1 ;
@@ -168,9 +161,8 @@ describe("Adding a resource", () => {
168
161
} ) ;
169
162
170
163
describe ( "Deleting a Resource" , ( ) => {
171
- it ( "delete-resource() fails if not called by deployer" , async ( ) => {
164
+ it ( "delete-resource() fails if not called by deployer" , ( ) => {
172
165
// ARRANGE
173
- const simnet = await initSimnet ( ) ;
174
166
const accounts = simnet . getAccounts ( ) ;
175
167
const deployer = accounts . get ( "deployer" ) ! ;
176
168
const address1 = accounts . get ( "wallet_1" ) ! ;
@@ -195,9 +187,8 @@ describe("Deleting a Resource", () => {
195
187
expect ( response . result ) . toBeErr ( Cl . uint ( ErrCode . ERR_UNAUTHORIZED ) ) ;
196
188
} ) ;
197
189
198
- it ( "delete-resource() fails if provided index is greater than current resource count" , async ( ) => {
190
+ it ( "delete-resource() fails if provided index is greater than current resource count" , ( ) => {
199
191
// ARRANGE
200
- const simnet = await initSimnet ( ) ;
201
192
const accounts = simnet . getAccounts ( ) ;
202
193
const deployer = accounts . get ( "deployer" ) ! ;
203
194
// ACT
@@ -211,9 +202,8 @@ describe("Deleting a Resource", () => {
211
202
expect ( response . result ) . toBeErr ( Cl . uint ( ErrCode . ERR_INVALID_PARAMS ) ) ;
212
203
} ) ;
213
204
214
- it ( "delete-resource() fails if executed twice on the same resource" , async ( ) => {
205
+ it ( "delete-resource() fails if executed twice on the same resource" , ( ) => {
215
206
// ARRANGE
216
- const simnet = await initSimnet ( ) ;
217
207
const accounts = simnet . getAccounts ( ) ;
218
208
const deployer = accounts . get ( "deployer" ) ! ;
219
209
// ACT
@@ -248,9 +238,8 @@ describe("Deleting a Resource", () => {
248
238
) ;
249
239
} ) ;
250
240
251
- it ( "delete-resource-by-name() fails if not called by deployer" , async ( ) => {
241
+ it ( "delete-resource-by-name() fails if not called by deployer" , ( ) => {
252
242
// ARRANGE
253
- const simnet = await initSimnet ( ) ;
254
243
const accounts = simnet . getAccounts ( ) ;
255
244
const deployer = accounts . get ( "deployer" ) ! ;
256
245
const address1 = accounts . get ( "wallet_1" ) ! ;
@@ -275,9 +264,8 @@ describe("Deleting a Resource", () => {
275
264
expect ( response . result ) . toBeErr ( Cl . uint ( ErrCode . ERR_UNAUTHORIZED ) ) ;
276
265
} ) ;
277
266
278
- it ( "delete-resource-by-name() fails if provided name is not found" , async ( ) => {
267
+ it ( "delete-resource-by-name() fails if provided name is not found" , ( ) => {
279
268
// ARRANGE
280
- const simnet = await initSimnet ( ) ;
281
269
const accounts = simnet . getAccounts ( ) ;
282
270
const deployer = accounts . get ( "deployer" ) ! ;
283
271
// ACT
@@ -291,9 +279,8 @@ describe("Deleting a Resource", () => {
291
279
expect ( response . result ) . toBeErr ( Cl . uint ( ErrCode . ERR_INVALID_PARAMS ) ) ;
292
280
} ) ;
293
281
294
- it ( "pay-invoice() fails for a deleted resource" , async ( ) => {
282
+ it ( "pay-invoice() fails for a deleted resource" , ( ) => {
295
283
// ARRANGE
296
- const simnet = await initSimnet ( ) ;
297
284
const accounts = simnet . getAccounts ( ) ;
298
285
const address1 = accounts . get ( "wallet_1" ) ! ;
299
286
const deployer = accounts . get ( "deployer" ) ! ;
@@ -332,9 +319,8 @@ describe("Deleting a Resource", () => {
332
319
} ) ;
333
320
334
321
describe ( "Setting a Payment Address" , ( ) => {
335
- it ( "set-payment-address() fails if not called by deployer" , async ( ) => {
322
+ it ( "set-payment-address() fails if not called by deployer" , ( ) => {
336
323
// ARRANGE
337
- const simnet = await initSimnet ( ) ;
338
324
const accounts = simnet . getAccounts ( ) ;
339
325
const address1 = accounts . get ( "wallet_1" ) ! ;
340
326
// ACT
@@ -363,9 +349,8 @@ describe("Setting a Payment Address", () => {
363
349
expect ( response . result ) . toBeErr ( Cl . uint ( ErrCode . ERR_UNAUTHORIZED ) ) ;
364
350
} ) ;
365
351
366
- it ( "set-payment-address() fails if old address param is incorrect" , async ( ) => {
352
+ it ( "set-payment-address() fails if old address param is incorrect" , ( ) => {
367
353
// ARRANGE
368
- const simnet = await initSimnet ( ) ;
369
354
const accounts = simnet . getAccounts ( ) ;
370
355
const address1 = accounts . get ( "wallet_1" ) ! ;
371
356
const deployer = accounts . get ( "deployer" ) ! ;
@@ -381,9 +366,8 @@ describe("Setting a Payment Address", () => {
381
366
expect ( response . result ) . toBeErr ( Cl . uint ( ErrCode . ERR_UNAUTHORIZED ) ) ;
382
367
} ) ;
383
368
384
- it ( "set-payment-address() succeeds if called by the deployer" , async ( ) => {
369
+ it ( "set-payment-address() succeeds if called by the deployer" , ( ) => {
385
370
// ARRANGE
386
- const simnet = await initSimnet ( ) ;
387
371
const accounts = simnet . getAccounts ( ) ;
388
372
const deployer = accounts . get ( "deployer" ) ! ;
389
373
const address1 = accounts . get ( "wallet_1" ) ! ;
@@ -414,9 +398,8 @@ describe("Setting a Payment Address", () => {
414
398
expect ( response . result ) . toBeOk ( Cl . bool ( true ) ) ;
415
399
} ) ;
416
400
417
- it ( "set-payment-address() succeeds if called by current payment address" , async ( ) => {
401
+ it ( "set-payment-address() succeeds if called by current payment address" , ( ) => {
418
402
// ARRANGE
419
- const simnet = await initSimnet ( ) ;
420
403
const accounts = simnet . getAccounts ( ) ;
421
404
const deployer = accounts . get ( "deployer" ) ! ;
422
405
const address1 = accounts . get ( "wallet_1" ) ! ;
@@ -472,9 +455,8 @@ describe("Setting a Payment Address", () => {
472
455
} ) ;
473
456
474
457
describe ( "Generating an invoice hash" , ( ) => {
475
- it ( "get-invoice-hash() returns none if resource is not found" , async ( ) => {
458
+ it ( "get-invoice-hash() returns none if resource is not found" , ( ) => {
476
459
// ARRANGE
477
- const simnet = await initSimnet ( ) ;
478
460
const accounts = simnet . getAccounts ( ) ;
479
461
const deployer = accounts . get ( "deployer" ) ! ;
480
462
// ACT
@@ -492,9 +474,8 @@ describe("Generating an invoice hash", () => {
492
474
expect ( response . result ) . toBeNone ( ) ;
493
475
} ) ;
494
476
495
- it ( "get-invoice-hash() succeeds and returns the correct value" , async ( ) => {
477
+ it ( "get-invoice-hash() succeeds and returns the correct value" , ( ) => {
496
478
// ARRANGE
497
- const simnet = await initSimnet ( ) ;
498
479
const accounts = simnet . getAccounts ( ) ;
499
480
const deployer = accounts . get ( "deployer" ) ! ;
500
481
// ACT
@@ -518,9 +499,8 @@ describe("Generating an invoice hash", () => {
518
499
expect ( response . result ) . toBeSome ( Cl . buffer ( expectedBlock0Resource1 ) ) ;
519
500
} ) ;
520
501
521
- it ( "get-invoice-hash() succeeds and returns the correct value after the chain progresses" , async ( ) => {
502
+ it ( "get-invoice-hash() succeeds and returns the correct value after the chain progresses" , ( ) => {
522
503
// ARRANGE
523
- const simnet = await initSimnet ( ) ;
524
504
const accounts = simnet . getAccounts ( ) ;
525
505
const deployer = accounts . get ( "deployer" ) ! ;
526
506
// ACT
@@ -545,9 +525,8 @@ describe("Generating an invoice hash", () => {
545
525
expect ( response . result ) . toBeSome ( Cl . buffer ( expectedBlock0Resource1 ) ) ;
546
526
} ) ;
547
527
548
- it ( "get-invoice-hash() succeeds and generates unique values for different users at different block heights" , async ( ) => {
528
+ it ( "get-invoice-hash() succeeds and generates unique values for different users at different block heights" , ( ) => {
549
529
// ARRANGE
550
- const simnet = await initSimnet ( ) ;
551
530
const accounts = simnet . getAccounts ( ) ;
552
531
const deployer = accounts . get ( "deployer" ) ! ;
553
532
const address1 = accounts . get ( "wallet_1" ) ! ;
@@ -588,9 +567,8 @@ describe("Generating an invoice hash", () => {
588
567
expect ( uniqueInvoiceHashes . size ) . toEqual ( invoiceHashes . length ) ;
589
568
} ) ;
590
569
591
- it ( "get-invoice-hash() succeeds and generates consistent values for different users at different block heights" , async ( ) => {
570
+ it ( "get-invoice-hash() succeeds and generates consistent values for different users at different block heights" , ( ) => {
592
571
// ARRANGE
593
- const simnet = await initSimnet ( ) ;
594
572
const accounts = simnet . getAccounts ( ) ;
595
573
const deployer = accounts . get ( "deployer" ) ! ;
596
574
const address1 = accounts . get ( "wallet_1" ) ! ;
@@ -651,9 +629,8 @@ describe("Generating an invoice hash", () => {
651
629
} ) ;
652
630
653
631
describe ( "Paying an invoice" , ( ) => {
654
- it ( "pay-invoice() fails if resource is not found" , async ( ) => {
632
+ it ( "pay-invoice() fails if resource is not found" , ( ) => {
655
633
// ARRANGE
656
- const simnet = await initSimnet ( ) ;
657
634
const accounts = simnet . getAccounts ( ) ;
658
635
const address1 = accounts . get ( "wallet_1" ) ! ;
659
636
// ACT
@@ -670,14 +647,13 @@ describe("Paying an invoice", () => {
670
647
expect ( response . result ) . toBeErr ( Cl . uint ( ErrCode . ERR_RESOURCE_NOT_FOUND ) ) ;
671
648
} ) ;
672
649
// not expecting ERR_USER_NOT_FOUND, not sure if we can force?
673
- // it("pay-invoice() fails if user cannot be created or found", async () => {})
650
+ // it("pay-invoice() fails if user cannot be created or found", () => {})
674
651
// not expecting ERR_INVOICE_HASH_NOT_FOUND, same as above
675
- // it("pay-invoice() fails if invoice hash cannot be found", async () => {})
652
+ // it("pay-invoice() fails if invoice hash cannot be found", () => {})
676
653
// not expecting ERR_SAVING_INVOICE in two spots, same as above
677
- // it("pay-invoice() fails if invoice cannot be saved", async () => {})
678
- it ( "pay-invoice() succeeds and returns invoice count without memo" , async ( ) => {
654
+ // it("pay-invoice() fails if invoice cannot be saved", () => {})
655
+ it ( "pay-invoice() succeeds and returns invoice count without memo" , ( ) => {
679
656
// ARRANGE
680
- const simnet = await initSimnet ( ) ;
681
657
const accounts = simnet . getAccounts ( ) ;
682
658
const deployer = accounts . get ( "deployer" ) ! ;
683
659
const address1 = accounts . get ( "wallet_1" ) ! ;
@@ -704,9 +680,8 @@ describe("Paying an invoice", () => {
704
680
expect ( response . result ) . toBeOk ( Cl . uint ( expectedCount ) ) ;
705
681
} ) ;
706
682
707
- it ( "pay-invoice() succeeds and returns invoice count with memo" , async ( ) => {
683
+ it ( "pay-invoice() succeeds and returns invoice count with memo" , ( ) => {
708
684
// ARRANGE
709
- const simnet = await initSimnet ( ) ;
710
685
const accounts = simnet . getAccounts ( ) ;
711
686
const deployer = accounts . get ( "deployer" ) ! ;
712
687
const address1 = accounts . get ( "wallet_1" ) ! ;
@@ -734,9 +709,8 @@ describe("Paying an invoice", () => {
734
709
expect ( response . result ) . toBeOk ( Cl . uint ( expectedCount ) ) ;
735
710
} ) ;
736
711
737
- it ( "pay-invoice() succeeds and returns invoice count with memo over several blocks" , async ( ) => {
712
+ it ( "pay-invoice() succeeds and returns invoice count with memo over several blocks" , ( ) => {
738
713
// ARRANGE
739
- const simnet = await initSimnet ( ) ;
740
714
const accounts = simnet . getAccounts ( ) ;
741
715
const deployer = accounts . get ( "deployer" ) ! ;
742
716
const address1 = accounts . get ( "wallet_1" ) ! ;
@@ -820,9 +794,8 @@ describe("Paying an invoice", () => {
820
794
}
821
795
} ) ;
822
796
823
- it ( "pay-invoice() succeeds and updates resource and user data" , async ( ) => {
797
+ it ( "pay-invoice() succeeds and updates resource and user data" , ( ) => {
824
798
// ARRANGE
825
- const simnet = await initSimnet ( ) ;
826
799
const accounts = simnet . getAccounts ( ) ;
827
800
const address1 = accounts . get ( "wallet_1" ) ! ;
828
801
const address2 = accounts . get ( "wallet_2" ) ! ;
0 commit comments