Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Updating all templates to rust v0.62.0 #6067

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion templates/sway-predicate-test-rs/template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["{{authors}}"]
license = "Apache-2.0"

[dev-dependencies]
fuels = { version = "0.53", features = ["fuel-core-lib"] }
fuels = { version = "0.62", features = ["fuel-core-lib"] }
tokio = { version = "1.12", features = ["rt", "macros"] }

[[test]]
Expand Down
12 changes: 7 additions & 5 deletions templates/sway-predicate-test-rs/template/tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ abigen!(Predicate(
abi = "out/debug/{{project-name}}-abi.json"
));

async fn get_predicate_instance() -> (WalletUnlocked, Predicate) {
async fn get_predicate_instance() -> (WalletUnlocked, Predicate, AssetId) {
let mut wallets = launch_custom_provider_and_get_wallets(
WalletsConfig::new(
Some(1), /* Single wallet */
Expand All @@ -23,11 +23,13 @@ async fn get_predicate_instance() -> (WalletUnlocked, Predicate) {

let provider = wallet.provider().clone().unwrap();

let base_asset_id = provider.base_asset_id().clone();

let bin_path = "./out/debug/{{project-name}}.bin";

let instance: Predicate = Predicate::load_from(bin_path).unwrap().with_provider(provider.clone());

(wallet, instance)
(wallet, instance, base_asset_id)
}

async fn check_balances(
Expand All @@ -52,19 +54,19 @@ async fn check_balances(

#[tokio::test]
async fn can_get_predicate_instance() {
let (wallet, instance) = get_predicate_instance().await;
let (wallet, instance, base_asset_id) = get_predicate_instance().await;
let predicate_root = instance.address();

// Check balances before funding predicate
check_balances(&wallet, &instance, Some(1_000_000_000u64), None).await;

// Fund predicate from wallet
let _ = wallet.transfer(predicate_root, 1234, BASE_ASSET_ID, TxPolicies::default()).await;
let _ = wallet.transfer(predicate_root, 1234, base_asset_id, TxPolicies::default()).await;

// Check balances after funding predicate
check_balances(&wallet, &instance, Some(999_998_766u64), Some(1234u64)).await;

let _ = instance.transfer(wallet.address(), 1234, BASE_ASSET_ID, TxPolicies::default()).await;
let _ = instance.transfer(wallet.address(), 1234, base_asset_id, TxPolicies::default()).await;

// Check balances after transferring funds out of predicate
check_balances(&wallet, &instance, Some(1_000_000_000u64), Some(0u64)).await;
Expand Down
2 changes: 1 addition & 1 deletion templates/sway-script-test-rs/template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["{{authors}}"]
license = "Apache-2.0"

[dev-dependencies]
fuels = { version = "0.53", features = ["fuel-core-lib"] }
fuels = { version = "0.62", features = ["fuel-core-lib"] }
tokio = { version = "1.12", features = ["rt", "macros"] }

[[test]]
Expand Down
6 changes: 3 additions & 3 deletions templates/sway-script-test-rs/template/tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ abigen!(Script(

async fn get_script_instance() -> MyScript<WalletUnlocked> {
// Launch a local network
let mut wallets = launch_custom_provider_and_get_wallets(
let wallets = launch_custom_provider_and_get_wallets(
WalletsConfig::new(
Some(1), /* Single wallet */
Some(1), /* Single coin (UTXO) */
Expand All @@ -18,7 +18,7 @@ async fn get_script_instance() -> MyScript<WalletUnlocked> {
None,
)
.await;
let wallet = wallets.pop().unwrap();
let wallet = wallets.unwrap().pop().unwrap();

let bin_path = "./out/debug/{{project-name}}.bin";

Expand All @@ -30,7 +30,7 @@ async fn get_script_instance() -> MyScript<WalletUnlocked> {
#[tokio::test]
async fn can_get_script_instance() {
const LUCKY_NUMBER: u64 = 777;
let configurables = MyScriptConfigurables::new().with_SECRET_NUMBER(LUCKY_NUMBER.clone());
let configurables = MyScriptConfigurables::default().with_SECRET_NUMBER(LUCKY_NUMBER.clone()).unwrap();

let instance = get_script_instance().await;

Expand Down
2 changes: 1 addition & 1 deletion templates/sway-test-rs/template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["{{authors}}"]
license = "Apache-2.0"

[dev-dependencies]
fuels = { version = "0.54.0", features = ["fuel-core-lib"] }
fuels = { version = "0.62.0", features = ["fuel-core-lib"] }
tokio = { version = "1.12", features = ["rt", "macros"] }

[[test]]
Expand Down
Loading