|
1 | 1 | #[cfg(test)] |
2 | 2 | mod tests { |
3 | | - use fuels::core::codec::EncoderConfig; |
4 | 3 | use fuels::{ |
5 | | - core::codec::DecoderConfig, |
| 4 | + core::codec::{DecoderConfig, EncoderConfig}, |
6 | 5 | prelude::{Config, LoadConfiguration, StorageConfiguration}, |
7 | | - types::{errors::Result, Bits256}, |
| 6 | + types::{ |
| 7 | + errors::{transaction::Reason, Result}, |
| 8 | + Bits256, |
| 9 | + }, |
8 | 10 | }; |
9 | 11 |
|
10 | 12 | #[tokio::test] |
@@ -403,7 +405,7 @@ mod tests { |
403 | 405 |
|
404 | 406 | assert!(matches!( |
405 | 407 | response, |
406 | | - Err(Error::RevertTransactionError { .. }) |
| 408 | + Err(Error::Transaction(Reason::Reverted { .. })) |
407 | 409 | )); |
408 | 410 | // ANCHOR_END: dependency_estimation_fail |
409 | 411 |
|
@@ -438,80 +440,32 @@ mod tests { |
438 | 440 | #[tokio::test] |
439 | 441 | #[allow(unused_variables)] |
440 | 442 | async fn get_contract_outputs() -> Result<()> { |
441 | | - use fuels::{prelude::*, tx::Receipt}; |
442 | | - { |
443 | | - abigen!(Contract( |
444 | | - name = "TestContract", |
445 | | - abi = |
446 | | - "packages/fuels/tests/contracts/contract_test/out/debug/contract_test-abi.json" |
447 | | - )); |
448 | | - let wallet = launch_provider_and_get_wallet().await?; |
449 | | - |
450 | | - let contract_id = Contract::load_from( |
451 | | - "../../packages/fuels/tests/contracts/contract_test/out/debug/contract_test.bin", |
452 | | - LoadConfiguration::default(), |
453 | | - )? |
454 | | - .deploy(&wallet, TxPolicies::default()) |
455 | | - .await?; |
| 443 | + use fuels::prelude::*; |
456 | 444 |
|
457 | | - let contract_methods = TestContract::new(contract_id, wallet).methods(); |
458 | | - |
459 | | - let response = contract_methods.increment_counter(162).call().await?; |
460 | | - let response = contract_methods.increment_counter(162).call().await; |
461 | | - match response { |
462 | | - // The transaction is valid and executes to completion |
463 | | - Ok(call_response) => { |
464 | | - let receipts: Vec<Receipt> = call_response.receipts; |
465 | | - // Do things with logs and receipts |
466 | | - } |
467 | | - // The transaction is malformed |
468 | | - Err(Error::ValidationError(e)) => { |
469 | | - println!("Transaction is malformed (ValidationError): {e}"); |
470 | | - } |
471 | | - // Failed request to provider |
472 | | - Err(Error::ProviderError(reason)) => { |
473 | | - println!("Provider request failed with reason: {reason}"); |
474 | | - } |
475 | | - // The transaction is valid but reverts |
476 | | - Err(Error::RevertTransactionError { |
477 | | - reason, receipts, .. |
478 | | - }) => { |
479 | | - println!("ContractCall failed with reason: {reason}"); |
480 | | - println!("Transaction receipts are: {receipts:?}"); |
481 | | - } |
482 | | - Err(_) => {} |
483 | | - } |
484 | | - } |
485 | | - { |
486 | | - // ANCHOR: deployed_contracts |
487 | | - abigen!(Contract( |
488 | | - name = "MyContract", |
489 | | - // Replace with your contract ABI.json path |
490 | | - abi = |
491 | | - "packages/fuels/tests/contracts/contract_test/out/debug/contract_test-abi.json" |
492 | | - )); |
493 | | - let wallet_original = launch_provider_and_get_wallet().await?; |
494 | | - |
495 | | - let wallet = wallet_original.clone(); |
496 | | - // Your bech32m encoded contract ID. |
497 | | - let contract_id: Bech32ContractId = |
498 | | - "fuel1vkm285ypjesypw7vhdlhnty3kjxxx4efckdycqh3ttna4xvmxtfs6murwy" |
499 | | - .parse() |
500 | | - .expect("Invalid ID"); |
501 | | - |
502 | | - let connected_contract_instance = MyContract::new(contract_id, wallet); |
503 | | - // You can now use the `connected_contract_instance` just as you did above! |
504 | | - // ANCHOR_END: deployed_contracts |
505 | | - |
506 | | - let wallet = wallet_original; |
507 | | - // ANCHOR: deployed_contracts_hex |
508 | | - let contract_id: ContractId = |
509 | | - "0x65b6a3d081966040bbccbb7f79ac91b48c635729c59a4c02f15ae7da999b32d3" |
510 | | - .parse() |
511 | | - .expect("Invalid ID"); |
512 | | - let connected_contract_instance = MyContract::new(contract_id, wallet); |
513 | | - // ANCHOR_END: deployed_contracts_hex |
514 | | - } |
| 445 | + // ANCHOR: deployed_contracts |
| 446 | + abigen!(Contract( |
| 447 | + name = "MyContract", |
| 448 | + // Replace with your contract ABI.json path |
| 449 | + abi = "packages/fuels/tests/contracts/contract_test/out/debug/contract_test-abi.json" |
| 450 | + )); |
| 451 | + let wallet_original = launch_provider_and_get_wallet().await?; |
| 452 | + |
| 453 | + let wallet = wallet_original.clone(); |
| 454 | + // Your bech32m encoded contract ID. |
| 455 | + let contract_id: Bech32ContractId = |
| 456 | + "fuel1vkm285ypjesypw7vhdlhnty3kjxxx4efckdycqh3ttna4xvmxtfs6murwy".parse()?; |
| 457 | + |
| 458 | + let connected_contract_instance = MyContract::new(contract_id, wallet); |
| 459 | + // You can now use the `connected_contract_instance` just as you did above! |
| 460 | + // ANCHOR_END: deployed_contracts |
| 461 | + |
| 462 | + let wallet = wallet_original; |
| 463 | + // ANCHOR: deployed_contracts_hex |
| 464 | + let contract_id: ContractId = |
| 465 | + "0x65b6a3d081966040bbccbb7f79ac91b48c635729c59a4c02f15ae7da999b32d3".parse()?; |
| 466 | + |
| 467 | + let connected_contract_instance = MyContract::new(contract_id, wallet); |
| 468 | + // ANCHOR_END: deployed_contracts_hex |
515 | 469 |
|
516 | 470 | Ok(()) |
517 | 471 | } |
|
0 commit comments