Tokio macro requires rt or rt-multi-thread in Solana program

1.5k views Asked by At

Anyone able to guide me on why I can be getting this error on my tests?

The #[tokio::test] macro requires rt or rt-multi-thread.

It is more a Rust question than a Solana one, but I have been following the examples (and I am learning Rust), so just felt here would be a good place to post hte quesiton.

I have solana-program-test = "1.6.2".

2

There are 2 answers

0
awesomeA On BEST ANSWER

Hrm... I'm not sure then. Maybe try adding https://github.com/solana-labs/solana/blob/364af3a3e01e258694e16aed57838d36305aa9c3/program-test/Cargo.toml#L25 explicitly?

Under dev-dependencies though.

0
alif On

You cargo.toml should have tokio and tokio-test

tokio = { version = "1.24.2", features = ["full"] }
tokio-test ="0.4.2"

This will install the optional rt-multi-thread dependency.