Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Unit Testing for Sponsored Transactions in Simnet #1694

Open
ronoel opened this issue Feb 24, 2025 · 0 comments
Open

Enable Unit Testing for Sponsored Transactions in Simnet #1694

ronoel opened this issue Feb 24, 2025 · 0 comments

Comments

@ronoel
Copy link

ronoel commented Feb 24, 2025

Currently, it is not possible to perform unit testing for sponsored transactions using Simnet in Clarinet. This limitation makes it difficult to test scenarios where transactions are sponsored by another account, requiring manual workarounds outside of the Simnet environment.

To support unit testing for sponsored transactions, I propose adding a sponsorPrivateKey parameter in the constructor of CallFnArgs. This way, when calling callPublicFn with a sponsor key, the transaction will be considered a sponsored transaction.

Current Implementation:

callPublicFn(args: CallFnArgs): TransactionRes;

export class CallFnArgs {
  free(): void;
  constructor(contract: string, method: string, args: (Uint8Array)[], sender: string);
}

Proposed Implementation:

export class CallFnArgs {
  free(): void;
  constructor(contract: string, method: string, args: (Uint8Array)[], sender: string, sponsorPrivateKey: string = null);
}

By including this optional parameter, developers can write unit tests that simulate sponsored transactions directly in Simnet.

Alternatives solution:

  • Implementing a separate method to explicitly handle sponsored transactions in the Simnet testing environment.
  • Using workarounds like manually crafting and signing sponsored transactions before sending them to Simnet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant