Skip to content

Commit

Permalink
Fixed tests and added cases for deleting last ext with disallowed pubkey
Browse files Browse the repository at this point in the history
  • Loading branch information
Skydev0h committed Feb 23, 2024
1 parent 4458be0 commit 51358ad
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 11 deletions.
8 changes: 4 additions & 4 deletions tests/wallet-v5-extensions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ describe('Wallet V5 extensions auth', () => {
const receipt = await walletV5.sendInternalMessageFromExtension(sender, {
value: toNano('0.1'),
body: packActionsList([
new ActionRemoveExtension(sender.address!),
new ActionSetSignatureAuthAllowed(true)
new ActionSetSignatureAuthAllowed(true),
new ActionRemoveExtension(sender.address!)
])
});

Expand Down Expand Up @@ -461,8 +461,8 @@ describe('Wallet V5 extensions auth', () => {
const receipt = await walletV5.sendInternalMessageFromExtension(sender, {
value: toNano('0.1'),
body: packActionsList([
new ActionRemoveExtension(sender.address!),
new ActionSetSignatureAuthAllowed(true)
new ActionSetSignatureAuthAllowed(true),
new ActionRemoveExtension(sender.address!)
])
});

Expand Down
29 changes: 25 additions & 4 deletions tests/wallet-v5-external.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -800,15 +800,14 @@ describe('Wallet V5 sign auth external', () => {
expect(contract_seqno).toEqual(seqno + 1);
});

it('Should add ext, disallow sign, remove ext, allow sign in one tx; send in other', async () => {
// N.B. Test that zero extensions do not prevent re-allowing the signature authentication
it('Should add ext, disallow sign, allow sign, remove ext in one tx; send in other', async () => {
const testExtension = Address.parse('EQAvDfWFG0oYX19jwNDNBBL1rKNT9XfaGP9HyTb5nb2Eml6y');

const actionsList = packActionsList([
new ActionAddExtension(testExtension),
new ActionSetSignatureAuthAllowed(false),
new ActionRemoveExtension(testExtension),
new ActionSetSignatureAuthAllowed(true)
new ActionSetSignatureAuthAllowed(true),
new ActionRemoveExtension(testExtension)
]);
const receipt = await walletV5.sendExternalSignedMessage(createBody(actionsList));
accountForGas(receipt.transactions);
Expand Down Expand Up @@ -856,6 +855,28 @@ describe('Wallet V5 sign auth external', () => {
expect(receiverBalanceAfter).toEqual(receiverBalanceBefore + forwardValue - fee);
});

it('Should fail removing last extension with signature auth disabled', async () => {
const testExtension = Address.parse('EQAvDfWFG0oYX19jwNDNBBL1rKNT9XfaGP9HyTb5nb2Eml6y');

const actionsList = packActionsList([
new ActionAddExtension(testExtension),
new ActionSetSignatureAuthAllowed(false),
new ActionRemoveExtension(testExtension)
]);
const receipt = await walletV5.sendExternalSignedMessage(createBody(actionsList));
accountForGas(receipt.transactions);

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

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

it('Should fail disallowing signature auth twice in tx', async () => {
const testExtension = Address.parse('EQAvDfWFG0oYX19jwNDNBBL1rKNT9XfaGP9HyTb5nb2Eml6y');

Expand Down
34 changes: 31 additions & 3 deletions tests/wallet-v5-internal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1011,15 +1011,14 @@ describe('Wallet V5 sign auth internal', () => {
expect(contract_seqno).toEqual(seqno + 1);
});

it('Should add ext, disallow sign, remove ext, allow sign in one tx; send in other', async () => {
// N.B. Test that zero extensions do not prevent re-allowing the signature authentication
it('Should add ext, disallow sign, allow sign, remove ext in one tx; send in other', async () => {
const testExtension = Address.parse('EQAvDfWFG0oYX19jwNDNBBL1rKNT9XfaGP9HyTb5nb2Eml6y');

const actionsList = packActionsList([
new ActionAddExtension(testExtension),
new ActionSetSignatureAuthAllowed(false),
new ActionSetSignatureAuthAllowed(true),
new ActionRemoveExtension(testExtension),
new ActionSetSignatureAuthAllowed(true)
]);

const receipt = await walletV5.sendInternal(sender, {
Expand Down Expand Up @@ -1078,6 +1077,35 @@ describe('Wallet V5 sign auth internal', () => {
expect(receiverBalanceAfter).toEqual(receiverBalanceBefore + forwardValue - fee);
});

it('Should fail removing last extension with signature auth disabled', async () => {
const testExtension = Address.parse('EQAvDfWFG0oYX19jwNDNBBL1rKNT9XfaGP9HyTb5nb2Eml6y');

const actionsList = packActionsList([
new ActionAddExtension(testExtension),
new ActionSetSignatureAuthAllowed(false),
new ActionRemoveExtension(testExtension)
]);

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

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

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

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

it('Should fail disallowing signature auth twice in tx', async () => {
const testExtension = Address.parse('EQAvDfWFG0oYX19jwNDNBBL1rKNT9XfaGP9HyTb5nb2Eml6y');

Expand Down

0 comments on commit 51358ad

Please sign in to comment.