Skip to main content
added 108 characters in body
Source Link
Serban
  • 1.5k
  • 3
  • 9

I looked at the code generated by the #[derive(Accounts)] macro from your example and I think the problem is that Anchor doesn't treat the case where you're using an Accounts item defined in a different file. It forgets to append crate:: when using the generated modules for that item.

To confirm this, if you add this line to your test.rs file, your code will compile fine: use crate::{__client_accounts_test_common, __cpi_client_accounts_test_common};

The solutionsolutions I can recommend is to define TestCommon in the same file as Test.:

  • define TestCommon in the same file as Test
  • or import everything from test_common not just TestCommon, so you'd use: use super::test_common::*;

I looked at the code generated by the #[derive(Accounts)] macro from your example and I think the problem is that Anchor doesn't treat the case where you're using an Accounts item defined in a different file. It forgets to append crate:: when using the generated modules for that item.

To confirm this, if you add this line to your test.rs file, your code will compile fine: use crate::{__client_accounts_test_common, __cpi_client_accounts_test_common};

The solution I can recommend is to define TestCommon in the same file as Test.

I looked at the code generated by the #[derive(Accounts)] macro from your example and I think the problem is that Anchor doesn't treat the case where you're using an Accounts item defined in a different file. It forgets to append crate:: when using the generated modules for that item.

To confirm this, if you add this line to your test.rs file, your code will compile fine: use crate::{__client_accounts_test_common, __cpi_client_accounts_test_common};

The solutions I can recommend:

  • define TestCommon in the same file as Test
  • or import everything from test_common not just TestCommon, so you'd use: use super::test_common::*;
Source Link
Serban
  • 1.5k
  • 3
  • 9

I looked at the code generated by the #[derive(Accounts)] macro from your example and I think the problem is that Anchor doesn't treat the case where you're using an Accounts item defined in a different file. It forgets to append crate:: when using the generated modules for that item.

To confirm this, if you add this line to your test.rs file, your code will compile fine: use crate::{__client_accounts_test_common, __cpi_client_accounts_test_common};

The solution I can recommend is to define TestCommon in the same file as Test.