Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
Check session validity in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abishekk92 committed Aug 3, 2023
1 parent a7188d4 commit 9568dc8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion programs/gpl_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub mod state;
use instructions::*;

declare_id!("6MhUAJtKdJx3RDCffUsJsQm8xy9YhhywjEmMYrxRc5j6");

#[cfg(not(feature = "no-entrypoint"))]
solana_security_txt::security_txt! {
name: "gpl_core",
Expand Down
2 changes: 1 addition & 1 deletion programs/gpl_session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn create_session_token_handler(
) -> Result<()> {
// Valid until can't be greater than a week
require!(
valid_until <= Clock::get()?.unix_timestamp + 7 * 60 * 60 * 24,
valid_until <= Clock::get()?.unix_timestamp + (60 * 60 * 24 * 7),
SessionError::ValidityTooLong
);

Expand Down
6 changes: 5 additions & 1 deletion tests/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ export async function new_session(
authority?: Keypair
): Promise<{ sessionPDA: PublicKey; sessionSigner: Keypair }> {
const sessionSigner = Keypair.generate();
const sessionTx = gpl_session.methods.createSession(true, null).accounts({
const validity = new anchor.BN(
Math.floor(Date.now() / 1000) + 60 * 60 * 24 * 6
);
// const validity = null;
const sessionTx = gpl_session.methods.createSession(true, validity).accounts({
authority: user,
sessionSigner: sessionSigner.publicKey,
targetProgram,
Expand Down

0 comments on commit 9568dc8

Please sign in to comment.