-1

i am trying to run a test for the flip of the bool value but getting this error while testing it

this is my code

  it('Creates a Flipper', async () => {

    const switchAccount = anchor.web3.Keypair.generate();
    console.log(switchAccount.publicKey.toBase58())
    await program.rpc.initialize({
      accounts: {
        switchAccount: switchAccount.publicKey,
        user: provider.wallet.publicKey,
        system_program: SystemProgram.programId,
      },
      signers: [switchAccount],
    }); //Create RPC Closed

and this is the eroor i am getting


  0 passing (11ms)
  2 failing

  1) light
       Creates a Flipper:
     TypeError: Cannot read properties of undefined (reading 'rpc')
      at Context.<anonymous> (tests/light.js:16:19)
      at processImmediate (node:internal/timers:466:21)
vinit
  • 1

1 Answers1

0
  const anchor = require("@project-serum/anchor");

  // provider is an abstraction of a connection to solana 
  const provider = anchor.Provider.local();
  anchor.setProvider(provider);
  const switchAccount = anchor.web3.Keypair.generate();
  // initial letter must be capital letter
  const program = anchor.workspace.Yourdappname;
Yilmaz
  • 35,338
  • 10
  • 157
  • 202