From d0c9fcdd9a33e15b01692189572416d304ace41b Mon Sep 17 00:00:00 2001 From: Sergey Timoshin Date: Mon, 18 Mar 2024 19:42:44 +0000 Subject: [PATCH 1/2] Update 'mint-to' test cases. --- cli/test/commands/mint-to/index.test.ts | 39 +++++++++++++++++++++++-- js/compressed-token/src/index.ts | 2 +- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/cli/test/commands/mint-to/index.test.ts b/cli/test/commands/mint-to/index.test.ts index a4d4d4b7d..b42e85780 100644 --- a/cli/test/commands/mint-to/index.test.ts +++ b/cli/test/commands/mint-to/index.test.ts @@ -3,11 +3,18 @@ import { initTestEnvIfNeeded } from "../../../src/utils/initTestEnv"; import { getPayer, getSolanaRpcUrl } from "../../../src"; import { Connection } from "@solana/web3.js"; import { createMint } from "@lightprotocol/compressed-token"; -import { confirmTx } from "@lightprotocol/stateless.js"; +import { byteArrayToKeypair, confirmTx } from "@lightprotocol/stateless.js"; import { requestAirdrop } from "../../helpers/helpers"; describe("mint-to", () => { - test.it(async () => { + const FIXED_BOB = byteArrayToKeypair([ + 23, 72, 199, 170, 152, 40, 30, 187, 91, 132, 88, 170, 94, 32, 89, 164, 164, + 38, 123, 3, 79, 17, 23, 83, 112, 91, 160, 140, 116, 9, 99, 38, 217, 144, 62, + 153, 200, 117, 213, 6, 62, 39, 186, 56, 34, 149, 58, 188, 99, 182, 87, 74, + 84, 182, 157, 45, 133, 253, 230, 193, 176, 160, 72, 249, + ]); + + test.it("Should mint token", async () => { await initTestEnvIfNeeded(); await requestAirdrop(getPayer().publicKey); @@ -32,6 +39,34 @@ describe("mint-to", () => { ); }); + test.it( + "Should allow authority that is not the payer to mint tokens", + async () => { + await initTestEnvIfNeeded(); + await requestAirdrop(getPayer().publicKey); + + const mintAmount = 100; + const mintAuthority = getPayer().publicKey.toBase58(); + const mintTo = FIXED_BOB.publicKey.toBase58(); + const mintAddress = await createTestMint(); + return test + .stdout() + .command([ + "mint-to", + `--amount=${mintAmount}`, + `--mint=${mintAddress}`, + `--mint-authority=${mintAuthority}`, + `--to=${mintTo}`, + ]) + .it( + `mint-to ${mintAmount} tokens to ${mintTo} from ${mintAddress} with authority ${mintAuthority}`, + (ctx: any) => { + expect(ctx.stdout).to.contain("mint-to successful"); + }, + ); + }, + ); + async function createTestMint() { const connection = new Connection(getSolanaRpcUrl(), "finalized"); const { mint, transactionSignature } = await createMint( diff --git a/js/compressed-token/src/index.ts b/js/compressed-token/src/index.ts index 03556f266..6e282eb1e 100644 --- a/js/compressed-token/src/index.ts +++ b/js/compressed-token/src/index.ts @@ -4,4 +4,4 @@ export * from './constants'; export * from './program'; export * from './token-serde'; export * from './types'; -export * from './actions'; \ No newline at end of file +export * from './actions'; From 8e205e024a3f326cdca1e5aa45c58c6b574ba0bb Mon Sep 17 00:00:00 2001 From: Sergey Timoshin Date: Mon, 18 Mar 2024 22:21:55 +0000 Subject: [PATCH 2/2] fix: mint-to test: update mint authority keypair --- cli/test/commands/mint-to/index.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cli/test/commands/mint-to/index.test.ts b/cli/test/commands/mint-to/index.test.ts index b42e85780..315796bf8 100644 --- a/cli/test/commands/mint-to/index.test.ts +++ b/cli/test/commands/mint-to/index.test.ts @@ -14,6 +14,13 @@ describe("mint-to", () => { 84, 182, 157, 45, 133, 253, 230, 193, 176, 160, 72, 249, ]); + const MINT_AUTHORITY = byteArrayToKeypair([ + 122, 239, 192, 18, 21, 29, 237, 120, 104, 95, 247, 150, 181, 218, 207, 60, + 158, 110, 200, 246, 74, 226, 30, 223, 142, 138, 133, 194, 30, 254, 132, 236, + 227, 130, 162, 184, 215, 227, 81, 211, 134, 73, 118, 71, 219, 163, 243, 41, + 118, 21, 155, 87, 11, 53, 153, 130, 178, 126, 151, 86, 225, 36, 251, 130, + ]); + test.it("Should mint token", async () => { await initTestEnvIfNeeded(); await requestAirdrop(getPayer().publicKey); @@ -46,7 +53,7 @@ describe("mint-to", () => { await requestAirdrop(getPayer().publicKey); const mintAmount = 100; - const mintAuthority = getPayer().publicKey.toBase58(); + const mintAuthority = MINT_AUTHORITY.publicKey.toBase58(); const mintTo = FIXED_BOB.publicKey.toBase58(); const mintAddress = await createTestMint(); return test