Skip to content

Commit b9eeccd

Browse files
committed
Tests cosmetic improvements
1 parent 06d536b commit b9eeccd

File tree

2 files changed

+40
-17
lines changed

2 files changed

+40
-17
lines changed

tests/Governor.spec.ts

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ describe('Governor actions tests', () => {
8989

9090
const poolDeployResult = await pool.sendDeploy(deployer.getSender(), toNano('11'));
9191

92+
const poolJettonDeployResult = await poolJetton.sendDeploy(deployer.getSender(), toNano('1.05'));
93+
const adminTransferResult = await poolJetton.sendChangeAdmin(deployer.getSender(), pool.address);
94+
95+
9296
// Preparation for the post update execution test
9397
const sendSlice = Cell.fromBase64("te6ccgEBAQEAJgAASHCAGMjLBVjPFoIQO5rKAPoCy2pwgQU5yMsfyz/J0M8WyXD7AA==").beginParse();
9498
/*<{
@@ -339,6 +343,7 @@ describe('Governor actions tests', () => {
339343
// Let's test random address too just in case
340344
res = await pool.sendDeposit(bc.sender(randomAddress()), depoAmount);
341345
assertExitCode(res.transactions, Errors.depossits_are_closed);
346+
await pool.sendSetDepositSettings(governor, toNano('1'), true, true);
342347
});
343348
});
344349
describe('Governance fee setting', () => {
@@ -372,7 +377,7 @@ describe('Governor actions tests', () => {
372377
let res = await pool.sendSetInterest(randomUser, newInterest);
373378

374379
assertExitCode(res.transactions, Errors.wrong_sender);
375-
// Makre sure those are separate roles
380+
// Make sure those are separate roles
376381
res = await pool.sendSetInterest(governor, newInterest);
377382
assertExitCode(res.transactions, Errors.wrong_sender);
378383
});
@@ -394,12 +399,19 @@ describe('Governor actions tests', () => {
394399

395400
let res = await pool.sendHaltMessage(bc.sender(notHalter));
396401
assertExitCode(res.transactions, Errors.wrong_sender);
397-
// Makre sure it's separate role
402+
// Make sure it's separate role
398403
res = await pool.sendHaltMessage(bc.sender(newGovernor));
399404
assertExitCode(res.transactions, Errors.wrong_sender);
400405
});
401406
it('Halter should be able to halt pool', async () => {
402407
const poolBefore = await pool.getFullData();
408+
// deposit while we can
409+
const depositResult = await pool.sendDeposit(deployer.getSender(), toNano('10'));
410+
expect(depositResult.transactions).toHaveTransaction({
411+
on: deployer.address,
412+
op: Op.jetton.transfer_notification
413+
});
414+
403415
expect(poolBefore.halted).toBe(false);
404416

405417
const res = await pool.sendHaltMessage(bc.sender(newHalter));
@@ -410,13 +422,7 @@ describe('Governor actions tests', () => {
410422
});
411423
it('Pool in halted state should prevent haltable ops', async () => {
412424
const haltedOps = [
413-
// Withdraw
414-
async () => bc.sendMessage(internal({
415-
from: poolJetton.address,
416-
to: pool.address,
417-
value: toNano('1'),
418-
body: beginCell().storeUint(Op.pool.withdraw, 32).storeUint(0, 64).endCell()
419-
})),
425+
// Withdraw is not haltable since in any case we need handle and send jettons back
420426
async () => pool.sendDeposit(bc.sender(randomAddress()), getRandomTon(100000, 200000)),
421427
// Loan request
422428
async () => bc.sendMessage(internal({
@@ -454,8 +460,25 @@ describe('Governor actions tests', () => {
454460
exitCode: Errors.halted
455461
});
456462
}
463+
464+
//Check remint on withdrawal for halted pool
465+
let myPoolJettonWalletAddress = await poolJetton.getWalletAddress(deployer.address);
466+
let myPoolJettonWallet = bc.openContract(PoolJettonWallet.createFromAddress(myPoolJettonWalletAddress));
467+
let oldJettonAmount = await myPoolJettonWallet.getJettonBalance();
468+
let oldBalance = (await bc.getContract(deployer.address)).balance;
469+
let burnResult = await myPoolJettonWallet.sendBurnWithParams(deployer.getSender(), toNano('1.0'), toNano('1.0'), deployer.address, true, true);
470+
expect(burnResult.transactions).toHaveTransaction({
471+
on: pool.address,
472+
success: true
473+
});
474+
expect(burnResult.transactions).toHaveTransaction({
475+
on: deployer.address,
476+
op: Op.jetton.transfer_notification
477+
});
478+
expect((await bc.getContract(deployer.address)).balance - oldBalance < 0n).toBeTruthy();
479+
expect(oldJettonAmount - await myPoolJettonWallet.getJettonBalance()).toEqual(0n);
457480
});
458-
it('Governance ops should be possibl when halted', async() => {
481+
it('Governance ops should be possible when halted', async() => {
459482
const rollBack = bc.snapshot();
460483
const governor = bc.sender(newGovernor);
461484
const notHaltable = [

tests/Integrational.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,9 @@ describe('Integrational tests', () => {
507507
});
508508
if(mintTx === undefined) {
509509
// No action phase failures
510-
console.log(`Pool:${pool.address}`);
511-
console.log(`Minter:${poolJetton.address}`);
512-
console.log(txs.map(x => flattenTransaction(x)));
510+
//console.log(`Pool:${pool.address}`);
511+
//console.log(`Minter:${poolJetton.address}`);
512+
//console.log(txs.map(x => flattenTransaction(x)));
513513
expect(txs).not.toHaveTransaction({
514514
actionResultCode: (x) => x! !== undefined && x! !== 0
515515
});
@@ -1997,11 +1997,11 @@ describe('Integrational tests', () => {
19971997
let actingController = myControllers[i];
19981998
const hashUpd = await actingController.sendUpdateHash(vSender);
19991999
if((i & 1) == shouldAct) {
2000-
console.log(`Acting on ${i}`);
2000+
//console.log(`Acting on ${i}`);
20012001
const controllerData = await actingController.getControllerData();
20022002
if(controllerData.state == ControllerState.FUNDS_STAKEN) {
20032003
waitUnlock(hashUpd.transactions[1].now);
2004-
console.log(`Recovering loan ${i}`);
2004+
//console.log(`Recovering loan ${i}`);
20052005
await elector.sendTickTock("tick");
20062006
await elector.sendTickTock("tick");
20072007
const res = await actingController.sendRecoverStake(vSender);
@@ -2013,7 +2013,7 @@ describe('Integrational tests', () => {
20132013
});
20142014
}
20152015
const curElect = await announceElections();
2016-
console.log(`Requesting loan ${i}`);
2016+
//console.log(`Requesting loan ${i}`);
20172017
await assertGetLoan(actingController, sConf.min_stake, true);
20182018
const res = await actingController.sendNewStake(vSender, sConf.min_stake + toNano('1'),
20192019
validator.keys.publicKey,
@@ -2175,7 +2175,7 @@ describe('Integrational tests', () => {
21752175
});
21762176
poolAfter = await pool.getFullDataRaw();
21772177
expect(poolAfter.currentRound.activeBorrowers).toEqual(poolBefore.currentRound.activeBorrowers);
2178-
console.log(`Profit after:${poolAfter.currentRound.profit}`);
2178+
//console.log(`Profit after:${poolAfter.currentRound.profit}`);
21792179
});
21802180
});
21812181
describe.skip('Attacks', () => {

0 commit comments

Comments
 (0)