Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions clients/typescript/test/delegation-security.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('Delegation Security', () => {
nonce: 1n,
});

const signature = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.transferFixed({
delegatee,
delegator: t.payerKeypair.address,
Expand All @@ -139,7 +139,6 @@ describe('Delegation Security', () => {
tokenProgram: t.tokenProgram,
})
.sendTransaction();
expect(signature).toBeDefined();
});

test('close SubscriptionAuthority kills all transfers', async () => {
Expand Down Expand Up @@ -313,7 +312,7 @@ describe('Delegation Security', () => {
nonce: 0n,
});

const signature = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.transferFixed({
delegatee,
delegator: t.payerKeypair.address,
Expand All @@ -325,7 +324,6 @@ describe('Delegation Security', () => {
tokenProgram: t.tokenProgram,
})
.sendTransaction();
expect(signature).toBeDefined();

await t.timeTravel(Number(expiryTs) + 200);

Expand Down Expand Up @@ -390,7 +388,7 @@ describe('Delegation Security', () => {
nonce: 0n,
});

const signature = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.transferRecurring({
delegatee,
delegator: t.payerKeypair.address,
Expand All @@ -402,7 +400,6 @@ describe('Delegation Security', () => {
tokenProgram: t.tokenProgram,
})
.sendTransaction();
expect(signature).toBeDefined();

await t.timeTravel(Number(expiryTs) + 200);

Expand Down Expand Up @@ -482,7 +479,7 @@ describe('Delegation Security', () => {
);

const legitimateAta = await t.createAtaWithBalance(t.tokenMint, legitimateDelegatee.address, 0n);
const signature = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.transferFixed({
delegatee: legitimateDelegatee,
delegator: t.payerKeypair.address,
Expand All @@ -494,7 +491,6 @@ describe('Delegation Security', () => {
tokenProgram: t.tokenProgram,
})
.sendTransaction();
expect(signature).toBeDefined();
});

test('wrong signer rejected on recurring delegation', async () => {
Expand Down Expand Up @@ -558,7 +554,7 @@ describe('Delegation Security', () => {
);

const legitimateAta = await t.createAtaWithBalance(t.tokenMint, legitimateDelegatee.address, 0n);
const signature = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.transferRecurring({
delegatee: legitimateDelegatee,
delegator: t.payerKeypair.address,
Expand All @@ -570,7 +566,6 @@ describe('Delegation Security', () => {
tokenProgram: t.tokenProgram,
})
.sendTransaction();
expect(signature).toBeDefined();
});

test('skipped periods do not accumulate allowance', async () => {
Expand Down Expand Up @@ -636,7 +631,7 @@ describe('Delegation Security', () => {
SUBSCRIPTIONS_ERROR__AMOUNT_EXCEEDS_PERIOD_LIMIT,
);

const signature = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.transferRecurring({
delegatee,
delegator: t.payerKeypair.address,
Expand All @@ -648,7 +643,6 @@ describe('Delegation Security', () => {
tokenProgram: t.tokenProgram,
})
.sendTransaction();
expect(signature).toBeDefined();
});

test('exceed per-period limit is blocked', async () => {
Expand Down Expand Up @@ -724,7 +718,7 @@ describe('Delegation Security', () => {
SUBSCRIPTIONS_ERROR__AMOUNT_EXCEEDS_PERIOD_LIMIT,
);

const signature = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.transferRecurring({
delegatee,
delegator: t.payerKeypair.address,
Expand All @@ -736,7 +730,6 @@ describe('Delegation Security', () => {
tokenProgram: t.tokenProgram,
})
.sendTransaction();
expect(signature).toBeDefined();
});

test('transfer before recurring start time is blocked', async () => {
Expand Down Expand Up @@ -801,7 +794,7 @@ describe('Delegation Security', () => {

await t.timeTravel(Number(startTs) + 60);

const signature = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.transferRecurring({
delegatee,
delegator: t.payerKeypair.address,
Expand All @@ -813,7 +806,6 @@ describe('Delegation Security', () => {
tokenProgram: t.tokenProgram,
})
.sendTransaction();
expect(signature).toBeDefined();
});

test('cross-type nonce collision: fixed then recurring same nonce', async () => {
Expand Down Expand Up @@ -938,7 +930,7 @@ describe('Delegation Security', () => {
}),
);

const signature = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.transferFixed({
delegatee,
delegator: subscriber.address,
Expand All @@ -950,7 +942,6 @@ describe('Delegation Security', () => {
tokenProgram: t.tokenProgram,
})
.sendTransaction();
expect(signature).toBeDefined();
});

test('nonce collision is blocked', async () => {
Expand Down Expand Up @@ -995,7 +986,7 @@ describe('Delegation Security', () => {
SUBSCRIPTIONS_ERROR__DELEGATION_ALREADY_EXISTS,
);

const signature = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.createFixedDelegation({
delegator: t.payerKeypair,
tokenMint: t.tokenMint,
Expand All @@ -1005,7 +996,6 @@ describe('Delegation Security', () => {
expiryTs: currentTs + BigInt(ONE_HOUR_IN_SECONDS),
})
.sendTransaction();
expect(signature).toBeDefined();
});
});

Expand Down
15 changes: 5 additions & 10 deletions clients/typescript/test/multi-wallet-scenarios.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe('Multi-Wallet Scenarios', () => {
SUBSCRIPTIONS_ERROR__SUBSCRIPTION_CANCELLED,
);

const sigA = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.transferSubscription({
caller: t.payerKeypair,
delegator: subscribers[0].address,
Expand All @@ -140,9 +140,8 @@ describe('Multi-Wallet Scenarios', () => {
tokenProgram: t.tokenProgram,
})
.sendTransaction();
expect(sigA).toBeDefined();

const sigB = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.transferSubscription({
caller: t.payerKeypair,
delegator: subscribers[1].address,
Expand All @@ -154,7 +153,6 @@ describe('Multi-Wallet Scenarios', () => {
tokenProgram: t.tokenProgram,
})
.sendTransaction();
expect(sigB).toBeDefined();

// Time travel moved past C's grace period (~2 hours), advancing A and B
// into a new billing period. amountPulledInPeriod resets, so only the
Expand Down Expand Up @@ -218,7 +216,7 @@ describe('Multi-Wallet Scenarios', () => {

const merchantAta = await t.createAtaWithBalance(t.tokenMint, t.payerKeypair.address, 0n);

const chargeSig = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.transferSubscription({
caller: t.payerKeypair,
delegator: subscriber.address,
Expand All @@ -230,7 +228,6 @@ describe('Multi-Wallet Scenarios', () => {
tokenProgram: t.tokenProgram,
})
.sendTransaction();
expect(chargeSig).toBeDefined();

await t.client.subscriptions.instructions
.closeSubscriptionAuthority({
Expand Down Expand Up @@ -290,7 +287,7 @@ describe('Multi-Wallet Scenarios', () => {
nonce: 0n,
});

const newTransferSig = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.transferFixed({
delegatee: trustedDelegatee,
delegator: subscriber.address,
Expand All @@ -302,7 +299,6 @@ describe('Multi-Wallet Scenarios', () => {
tokenProgram: t.tokenProgram,
})
.sendTransaction();
expect(newTransferSig).toBeDefined();
});

test('multi-mint kill-switch isolation', async () => {
Expand Down Expand Up @@ -402,7 +398,7 @@ describe('Multi-Wallet Scenarios', () => {
SUBSCRIPTIONS_ERROR__INVALID_SUBSCRIPTION_AUTHORITY_PDA,
);

const signature = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.transferFixed({
delegatee,
delegator: t.payerKeypair.address,
Expand All @@ -414,6 +410,5 @@ describe('Multi-Wallet Scenarios', () => {
tokenProgram: t.tokenProgram,
})
.sendTransaction();
expect(signature).toBeDefined();
});
});
10 changes: 3 additions & 7 deletions clients/typescript/test/subscription-lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,12 @@ describe('Subscription Lifecycle', () => {
// 6. Time-travel past endTs, then delete the plan
await t.timeTravel(Number(endTs) + 60);

const deleteSig = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.deletePlan({
owner: t.payerKeypair,
planPda,
})
.sendTransaction();
expect(deleteSig).toBeDefined();

const planAfterDelete = await fetchMaybePlan(t.rpc, planPda);
expect(planAfterDelete.exists).toBe(false);
Expand Down Expand Up @@ -197,7 +196,7 @@ describe('Subscription Lifecycle', () => {
const pullerAta = await t.createAtaWithBalance(t.tokenMint, puller.address, 0n);

const pullAmount = 100_000n;
const signature = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.transferSubscription({
caller: puller,
delegator: subscriber.address,
Expand All @@ -210,8 +209,6 @@ describe('Subscription Lifecycle', () => {
})
.sendTransaction();

expect(signature).toBeDefined();

const balance = await t.rpc.getTokenAccountBalance(pullerAta).send();
expect(balance.value.amount).toBe(pullAmount.toString());
});
Expand Down Expand Up @@ -408,14 +405,13 @@ describe('Subscription Lifecycle', () => {
expect(subAfterCancel.expiresAtTs).not.toBe(0n);

// 7. Subscriber revokes delegation, getting rent back
const revokeSig = await t.client.subscriptions.instructions
await t.client.subscriptions.instructions
.revokeSubscription({
authority: subscriber,
subscriptionPda,
planPda,
})
.sendTransaction();
expect(revokeSig).toBeDefined();

// Subscription account should be closed
const subAfterRevoke = await fetchMaybeSubscriptionDelegation(t.rpc, subscriptionPda);
Expand Down
Loading
Loading