繁体   English   中英

无法读取未定义的属性(读取 rpc )

[英]cannot read properties of undefined (reading rpc )

我正在尝试对 bool 值的翻转进行测试,但在测试时出现此错误

这是我的代码

  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

这是我得到的 eroor


  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)
  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;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM