Skip to content

Commit

Permalink
Added a test for separate auth disable by extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Skydev0h committed Feb 15, 2024
1 parent 3f76dbb commit 7f786ea
Showing 1 changed file with 89 additions and 0 deletions.
89 changes: 89 additions & 0 deletions tests/wallet-v5-extensions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,4 +426,93 @@ describe('Wallet V5 extensions auth', () => {
const receiverBalanceAfter = (await blockchain.getContract(testReceiver)).balance;
expect(receiverBalanceAfter).toEqual(receiverBalanceBefore + forwardValue - fee);
});

it('Add ext; disallow signature auth by ext; re-allow and self-delete by extension; do signed transfer', async () => {
await walletV5.sendInternalSignedMessage(sender, {
value: toNano(0.1),
body: createBody(packActionsList([
new ActionAddExtension(sender.address!)
]))
});

const isSignatureAuthAllowed = await walletV5.getIsSignatureAuthAllowed();
expect(isSignatureAuthAllowed).toEqual(-1);

const receipt0 = await walletV5.sendInternalMessageFromExtension(sender, {
value: toNano('0.1'),
body: packActionsList([
new ActionSetSignatureAuthAllowed(false)
])
});

expect(receipt0.transactions.length).toEqual(2);
accountForGas(receipt0.transactions);

expect(
(
(receipt0.transactions[1].description as TransactionDescriptionGeneric)
.computePhase as TransactionComputeVm
).exitCode
).toEqual(0);

const isSignatureAuthAllowed0 = await walletV5.getIsSignatureAuthAllowed();
expect(isSignatureAuthAllowed0).toEqual(0);

const receipt = await walletV5.sendInternalMessageFromExtension(sender, {
value: toNano('0.1'),
body: packActionsList([
new ActionRemoveExtension(sender.address!),
new ActionSetSignatureAuthAllowed(true)
])
});

expect(receipt.transactions.length).toEqual(2);
accountForGas(receipt.transactions);

expect(
(
(receipt.transactions[1].description as TransactionDescriptionGeneric)
.computePhase as TransactionComputeVm
).exitCode
).toEqual(0);

const isSignatureAuthAllowed1 = await walletV5.getIsSignatureAuthAllowed();
expect(isSignatureAuthAllowed1).toEqual(-1);

const contract_seqno = await walletV5.getSeqno();
expect(contract_seqno).toEqual(seqno + 2);

// Allowing or disallowing signature auth increments seqno, need to re-read
seqno = contract_seqno;

const testReceiver = Address.parse('EQAvDfWFG0oYX19jwNDNBBL1rKNT9XfaGP9HyTb5nb2Eml6y');
const forwardValue = toNano(0.001);

const receiverBalanceBefore = (await blockchain.getContract(testReceiver)).balance;

const msg = createMsgInternal({ dest: testReceiver, value: forwardValue });

const actionsList2 = packActionsList([
new ActionSendMsg(SendMode.PAY_GAS_SEPARATELY, msg)
]);

const receipt2 = await walletV5.sendInternal(sender, {
sendMode: SendMode.PAY_GAS_SEPARATELY,
value: toNano(0.1),
body: createBody(actionsList2)
});

expect(receipt2.transactions.length).toEqual(3);
accountForGas(receipt2.transactions);

expect(receipt2.transactions).toHaveTransaction({
from: walletV5.address,
to: testReceiver,
value: forwardValue
});

const fee = receipt2.transactions[2].totalFees.coins;
const receiverBalanceAfter = (await blockchain.getContract(testReceiver)).balance;
expect(receiverBalanceAfter).toEqual(receiverBalanceBefore + forwardValue - fee);
});
});

0 comments on commit 7f786ea

Please sign in to comment.