【发布时间】:2021-08-12 15:42:42
【问题描述】:
当我在此代码上运行 cargo test-bpf --manifest-path=./Cargo.toml 时
#[tokio::test]
async fn test_init_mapping() {
let program_id = Pubkey::new_unique();
let mut init_map_test = ProgramTest::new(
"simple", // Run the BPF version with `cargo test-bpf`
program_id,
processor!(process_instruction),
);
let main_pubkey = Pubkey::new_unique();
let main_account = Account {
lamports: 100,
owner: program_id,
..Account::default()
};
init_map_test.add_account(main_pubkey, main_account);
let (mut banks_client, payer, recent_blockhash) = init_map_test.start().await;
}
我收到此错误。
线程“test_init_mapping”在“未设置调用上下文!”时出现恐慌**
我不知道如何调试它,所以任何帮助都很棒。我已将问题缩小到最后一行。我一定是在我的项目中的某个地方设置了错误?
我认为这段代码不是问题,因为它是从 helloworld 示例粘贴的副本。
编辑:我留下了原始问题的重要细节。在最后一行之后我有 msg!("started"); ,我认为无关紧要,所以将其排除在外
【问题讨论】:
-
通常,当程序实际运行时会触发该错误。不幸的是,我复制了这段代码,它适用于我使用最新的 1.7.10 版本。您使用的是什么版本的 SDK 和 CLI?
-
嗨,乔恩。我使用 1.6.10 是因为我复制了 metaplex github 项目来尝试遵循该结构。你知道我可以克隆的 1.7.10 中的项目吗?当我尝试使用 1.7.10 再次运行此脚本时,我收到一条错误消息“无法安装 bpf-tools”
-
不确定是什么问题。我已经把这个放在 github 上,这对我有用github.com/antonnewcombe/nothing
标签: rust rust-cargo solana