diff --git a/tests/wallet-v5-extensions.spec.ts b/tests/wallet-v5-extensions.spec.ts index 4d2f30d..ae91fdd 100644 --- a/tests/wallet-v5-extensions.spec.ts +++ b/tests/wallet-v5-extensions.spec.ts @@ -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!) ]) }); @@ -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!) ]) }); diff --git a/tests/wallet-v5-external.spec.ts b/tests/wallet-v5-external.spec.ts index 1dadade..3d17d1d 100644 --- a/tests/wallet-v5-external.spec.ts +++ b/tests/wallet-v5-external.spec.ts @@ -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); @@ -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'); diff --git a/tests/wallet-v5-internal.spec.ts b/tests/wallet-v5-internal.spec.ts index 8dc09e3..61f79f0 100644 --- a/tests/wallet-v5-internal.spec.ts +++ b/tests/wallet-v5-internal.spec.ts @@ -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, { @@ -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');