![](/img/trans.png)
[英]Failing tests -> Cannot read properties of undefined (reading '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.