From 22283763bb82d083cbf3440156e394973344f4f6 Mon Sep 17 00:00:00 2001 From: dankelleher Date: Tue, 27 Jun 2023 13:05:22 +0200 Subject: [PATCH] Solana: Test for update-expiry bugfix --- solana/gateway-ts/scripts/burn.ts | 60 ------------------- solana/program/Cargo.toml | 2 +- .../tests/update_gateway_token_expiry.rs | 7 +++ 3 files changed, 8 insertions(+), 61 deletions(-) delete mode 100644 solana/gateway-ts/scripts/burn.ts diff --git a/solana/gateway-ts/scripts/burn.ts b/solana/gateway-ts/scripts/burn.ts deleted file mode 100644 index 72c8a0109..000000000 --- a/solana/gateway-ts/scripts/burn.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { - clusterApiUrl, - Connection, - Keypair, - PublicKey, - Transaction, -} from "@solana/web3.js"; -import { - burn, - expireToken, - findGatewayToken, - getGatekeeperAccountAddress, - getGatewayToken, -} from "../src"; -import * as os from "os"; - -const gatewayToken = new PublicKey(process.argv[2]); -const keypair = Keypair.fromSecretKey( - Buffer.from(require(os.homedir() + "/.config/solana/id.json")) -); -const gatekeeperNetwork = new PublicKey( - "tgnuXXNMDLK8dy7Xm1TdeGyc95MDym4bvAQCwcW21Bf" -); -const gatekeeperKey = Keypair.fromSecretKey( - Buffer.from( - require("/Users/daniel/code/identity-com/on-chain-identity-gateway/solana/gatekeeper-cli/src/util/test-gatekeeper.json") - ) -); - -(async () => { - const endpoint = process.env.CLUSTER_ENDPOINT || clusterApiUrl("devnet"); - const connection = new Connection(endpoint, "confirmed"); - - const token = await getGatewayToken(connection, gatewayToken); - - console.log(token); - - if (!token) throw new Error("Token not found"); - - console.log("gatekeeperNetwork", token.gatekeeperNetwork.toBase58()); - - const gatekeeperAccount = getGatekeeperAccountAddress( - token.issuingGatekeeper, - gatekeeperNetwork - ); - - const instruction = burn( - gatewayToken, - token.issuingGatekeeper, - gatekeeperAccount, - keypair.publicKey - ); - - const tx = await connection.sendTransaction( - new Transaction().add(instruction), - [gatekeeperKey] - ); - - console.log(tx); -})().catch(console.error); diff --git a/solana/program/Cargo.toml b/solana/program/Cargo.toml index a7f196979..91488fd92 100644 --- a/solana/program/Cargo.toml +++ b/solana/program/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-gateway" -version = "0.3.0" +version = "0.3.1" description = "OCIV Gateway Program" authors = ["Daniel Kelleher "] repository = "https://github.com/identity-com/on-chain-identity-gateway" diff --git a/solana/program/tests/update_gateway_token_expiry.rs b/solana/program/tests/update_gateway_token_expiry.rs index 65f671796..3bad86abb 100644 --- a/solana/program/tests/update_gateway_token_expiry.rs +++ b/solana/program/tests/update_gateway_token_expiry.rs @@ -209,6 +209,13 @@ async fn expire_token_should_succeed() { .process_transaction(expire_tx) .await .unwrap(); + + let now = GatewayContext::now(); + let gateway_token = context + .get_gateway_token(&context.owner.pubkey()) + .await + .unwrap(); + assert!(gateway_token.expire_time.unwrap() <= now); } #[tokio::test]