Skip to content

Commit 51358ad

Browse files
committed
Fixed tests and added cases for deleting last ext with disallowed pubkey
1 parent 4458be0 commit 51358ad

File tree

3 files changed

+60
-11
lines changed

3 files changed

+60
-11
lines changed

tests/wallet-v5-extensions.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,8 @@ describe('Wallet V5 extensions auth', () => {
372372
const receipt = await walletV5.sendInternalMessageFromExtension(sender, {
373373
value: toNano('0.1'),
374374
body: packActionsList([
375-
new ActionRemoveExtension(sender.address!),
376-
new ActionSetSignatureAuthAllowed(true)
375+
new ActionSetSignatureAuthAllowed(true),
376+
new ActionRemoveExtension(sender.address!)
377377
])
378378
});
379379

@@ -461,8 +461,8 @@ describe('Wallet V5 extensions auth', () => {
461461
const receipt = await walletV5.sendInternalMessageFromExtension(sender, {
462462
value: toNano('0.1'),
463463
body: packActionsList([
464-
new ActionRemoveExtension(sender.address!),
465-
new ActionSetSignatureAuthAllowed(true)
464+
new ActionSetSignatureAuthAllowed(true),
465+
new ActionRemoveExtension(sender.address!)
466466
])
467467
});
468468

tests/wallet-v5-external.spec.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -800,15 +800,14 @@ describe('Wallet V5 sign auth external', () => {
800800
expect(contract_seqno).toEqual(seqno + 1);
801801
});
802802

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

807806
const actionsList = packActionsList([
808807
new ActionAddExtension(testExtension),
809808
new ActionSetSignatureAuthAllowed(false),
810-
new ActionRemoveExtension(testExtension),
811-
new ActionSetSignatureAuthAllowed(true)
809+
new ActionSetSignatureAuthAllowed(true),
810+
new ActionRemoveExtension(testExtension)
812811
]);
813812
const receipt = await walletV5.sendExternalSignedMessage(createBody(actionsList));
814813
accountForGas(receipt.transactions);
@@ -856,6 +855,28 @@ describe('Wallet V5 sign auth external', () => {
856855
expect(receiverBalanceAfter).toEqual(receiverBalanceBefore + forwardValue - fee);
857856
});
858857

858+
it('Should fail removing last extension with signature auth disabled', async () => {
859+
const testExtension = Address.parse('EQAvDfWFG0oYX19jwNDNBBL1rKNT9XfaGP9HyTb5nb2Eml6y');
860+
861+
const actionsList = packActionsList([
862+
new ActionAddExtension(testExtension),
863+
new ActionSetSignatureAuthAllowed(false),
864+
new ActionRemoveExtension(testExtension)
865+
]);
866+
const receipt = await walletV5.sendExternalSignedMessage(createBody(actionsList));
867+
accountForGas(receipt.transactions);
868+
869+
expect(
870+
(
871+
(receipt.transactions[0].description as TransactionDescriptionGeneric)
872+
.computePhase as TransactionComputeVm
873+
).exitCode
874+
).toEqual(44);
875+
876+
const isSignatureAuthAllowed = await walletV5.getIsSignatureAuthAllowed();
877+
expect(isSignatureAuthAllowed).toEqual(-1);
878+
});
879+
859880
it('Should fail disallowing signature auth twice in tx', async () => {
860881
const testExtension = Address.parse('EQAvDfWFG0oYX19jwNDNBBL1rKNT9XfaGP9HyTb5nb2Eml6y');
861882

tests/wallet-v5-internal.spec.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,15 +1011,14 @@ describe('Wallet V5 sign auth internal', () => {
10111011
expect(contract_seqno).toEqual(seqno + 1);
10121012
});
10131013

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

10181017
const actionsList = packActionsList([
10191018
new ActionAddExtension(testExtension),
10201019
new ActionSetSignatureAuthAllowed(false),
1020+
new ActionSetSignatureAuthAllowed(true),
10211021
new ActionRemoveExtension(testExtension),
1022-
new ActionSetSignatureAuthAllowed(true)
10231022
]);
10241023

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

1080+
it('Should fail removing last extension with signature auth disabled', async () => {
1081+
const testExtension = Address.parse('EQAvDfWFG0oYX19jwNDNBBL1rKNT9XfaGP9HyTb5nb2Eml6y');
1082+
1083+
const actionsList = packActionsList([
1084+
new ActionAddExtension(testExtension),
1085+
new ActionSetSignatureAuthAllowed(false),
1086+
new ActionRemoveExtension(testExtension)
1087+
]);
1088+
1089+
const receipt = await walletV5.sendInternal(sender, {
1090+
sendMode: SendMode.PAY_GAS_SEPARATELY,
1091+
value: toNano(0.1),
1092+
body: createBody(actionsList)
1093+
});
1094+
1095+
expect(receipt.transactions.length).toEqual(2);
1096+
accountForGas(receipt.transactions);
1097+
1098+
expect(
1099+
(
1100+
(receipt.transactions[1].description as TransactionDescriptionGeneric)
1101+
.computePhase as TransactionComputeVm
1102+
).exitCode
1103+
).toEqual(44);
1104+
1105+
const isSignatureAuthAllowed = await walletV5.getIsSignatureAuthAllowed();
1106+
expect(isSignatureAuthAllowed).toEqual(-1);
1107+
});
1108+
10811109
it('Should fail disallowing signature auth twice in tx', async () => {
10821110
const testExtension = Address.parse('EQAvDfWFG0oYX19jwNDNBBL1rKNT9XfaGP9HyTb5nb2Eml6y');
10831111

0 commit comments

Comments
 (0)