I have this simple solana/anchor app written in Rust
use anchor_lang::prelude::*;
declare_id!("4ahwNyytPQ9cUguDLz9fcjbzEBMM4jsaVfYxTUV4Sf7r");
#[program]
mod myanchorapp {
use super::*;
pub fn create(ctx: Context<Create>, name: String, description: String) -> Result<()> { //Result<()>
let campaign = &mut ctx.accounts.campaign;
campaign.name = name;
campaign.description = description;
campaign.amount_donated = 0;
campaign.admin = *ctx.accounts.user.key;
Ok(())
}
}
// Transaction instructions
#[derive(Accounts)]
pub struct Create<'info> {
#[account(init, payer=user, space=9000, seeds=[b"CAMPAIGN_DEMO".as_ref(), user.key().as_ref()], bump)]
pub campaign: Account<'info, Campaign>,
#[account(mut)]
pub user: Signer<'info>,
pub system_program: Program<'info, System>
}
// An account that goes inside a transaction instruction
#[account]
pub struct Campaign {
pub admin: Pubkey,
pub name: String,
pub description: String,
pub amount_donated: u64
}
Here is my test file
const assert = require("assert");
const anchor = require("@coral-xyz/anchor");
const { SystemProgram } = anchor.web3;
describe("myanchorapp", () => {
/* create and set a Provider */
const provider = anchor.AnchorProvider.env();
anchor.setProvider(provider);
const program = anchor.workspace.Myanchorapp;
let _campaign;
it("Create campaign", async () => {
/* Call the create function via RPC */
const campaign = anchor.web3.Keypair.generate();
const testName = "Campaign1";
const testDescription = "A new campaign.";
await program.rpc.create(
testName,
testDescription,
{
accounts: {
campaign: campaign.publicKey,
user: provider.wallet.publicKey,
systemProgram: SystemProgram.programId,
},
signers: [campaign],
});
/* Fetch the account and check the value of count */
const account = await program.account.campaign.fetch(campaign.publicKey);
console.log('Campaign name: ', account.name)
assert.ok(account.name == testName);
_campaign = campaign;
});
});
No matter what I try I receive the following error:
myanchorapp
1) Creates a counter
0 passing (61ms)
1 failing
1) myanchorapp
Creates a counter:
Error: unknown signer: GbgASb46CEkk83VS22UWhYcMawAQ15EVbhnWySmAGcVM
I'm not able to find anything to help me fix this issue online.
Would anyone be able to point me in the right direction of a solution?