@@ -64,6 +64,16 @@ describe("aibtc-ext002-bank-account", () => {
64
64
) ;
65
65
expect ( response . result ) . toBeErr ( Cl . uint ( ErrCode . ERR_INVALID ) ) ;
66
66
} ) ;
67
+
68
+ it ( "succeeds when deployer sets a contract principal as account holder" , ( ) => {
69
+ const response = simnet . callPublicFn (
70
+ contractAddress ,
71
+ "set-account-holder" ,
72
+ [ Cl . principal ( `${ addressDeployer } .test-proxy` ) ] ,
73
+ addressDeployer
74
+ ) ;
75
+ expect ( response . result ) . toBeOk ( Cl . bool ( true ) ) ;
76
+ } ) ;
67
77
} ) ;
68
78
69
79
describe ( "set-withdrawal-period" , ( ) => {
@@ -160,6 +170,16 @@ describe("aibtc-ext002-bank-account", () => {
160
170
) ;
161
171
expect ( response . result ) . toBeErr ( Cl . uint ( ErrCode . ERR_INVALID ) ) ;
162
172
} ) ;
173
+
174
+ it ( "fails when deployer sets a block height less than deployed height" , ( ) => {
175
+ const response = simnet . callPublicFn (
176
+ contractAddress ,
177
+ "override-last-withdrawal-block" ,
178
+ [ Cl . uint ( 1 ) ] ,
179
+ addressDeployer
180
+ ) ;
181
+ expect ( response . result ) . toBeErr ( Cl . uint ( ErrCode . ERR_INVALID ) ) ;
182
+ } ) ;
163
183
} ) ;
164
184
165
185
describe ( "deposit-stx" , ( ) => {
@@ -296,6 +316,43 @@ describe("aibtc-ext002-bank-account", () => {
296
316
} ) ;
297
317
} ) ;
298
318
319
+ describe ( "get-account-terms" , ( ) => {
320
+ it ( "succeeds and returns all account terms" , ( ) => {
321
+ // First set up some state
322
+ simnet . callPublicFn (
323
+ contractAddress ,
324
+ "deposit-stx" ,
325
+ [ Cl . uint ( 100000000 ) ] ,
326
+ address1
327
+ ) ;
328
+ simnet . callPublicFn (
329
+ contractAddress ,
330
+ "set-account-holder" ,
331
+ [ Cl . principal ( address1 ) ] ,
332
+ addressDeployer
333
+ ) ;
334
+
335
+ const expectedResponse = {
336
+ accountBalance : Cl . uint ( 100000000 ) ,
337
+ accountHolder : Cl . principal ( address1 ) ,
338
+ contractName : Cl . principal ( contractAddress ) ,
339
+ deployedAt : Cl . uint ( 0 ) , // In test environment this is 0
340
+ lastWithdrawalBlock : Cl . uint ( 0 ) ,
341
+ withdrawalAmount : Cl . uint ( withdrawalAmount ) ,
342
+ withdrawalPeriod : Cl . uint ( withdrawalPeriod ) ,
343
+ } ;
344
+
345
+ const response = simnet . callReadOnlyFn (
346
+ contractAddress ,
347
+ "get-account-terms" ,
348
+ [ ] ,
349
+ address1
350
+ ) . result ;
351
+
352
+ expect ( response ) . toBeTuple ( expectedResponse ) ;
353
+ } ) ;
354
+ } ) ;
355
+
299
356
describe ( "get-all-vars" , ( ) => {
300
357
it ( "succeeds and returns all the variables" , ( ) => {
301
358
const expectedResponse = {
0 commit comments