Skip to content

Commit

Permalink
remove fuels-abigen-macro dependency (FuelLabs#2007)
Browse files Browse the repository at this point in the history
* add remove fuels-abigen-macro dependency

* add change dep. versions

* add fuel 0.16

* add fuel-core-lib flag

* add fuel-core-lib flag fix

* add fuel-core-lib flag fix

* add fuel-core-lib flag fix

* add fuel-core-lib flag fix

* add remove -- form forc test command

* add replace constants

* add expand CI command

* add fix tests

* add fix tests

* Update test/src/sdk-harness/Cargo.toml

Co-authored-by: John Adler <[email protected]>

* Update test/src/sdk-harness/Cargo.toml

Co-authored-by: John Adler <[email protected]>

* Update test/src/sdk-harness/Cargo.toml

Co-authored-by: John Adler <[email protected]>

* add return -- cmd

* add remove fuels-abigen-macro from tests

* add remove fuel-core-lib flag

* add fuel-core-lib flag

* add reverte CI file

* add remove features

* add remove [features]

* add merge master

Co-authored-by: Mohammad Fawaz <[email protected]>
Co-authored-by: John Adler <[email protected]>
  • Loading branch information
3 people authored Jun 28, 2022
1 parent 1958617 commit 719310d
Show file tree
Hide file tree
Showing 27 changed files with 47 additions and 58 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion forc-pkg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description = "Building, locking, fetching and updating Sway projects as Forc pa
[dependencies]
anyhow = "1"
forc-util = { version = "0.16.2", path = "../forc-util" }
fuel-tx = "0.12"
fuel-tx = "0.13"
fuels-types = "0.12"
git2 = { version = "0.14", features = ["vendored-libgit2", "vendored-openssl"] }
petgraph = { version = "0.6", features = ["serde-1"] }
Expand Down
6 changes: 3 additions & 3 deletions forc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ forc-util = { version = "0.16.2", path = "../forc-util" }
fs_extra = "1.2"
fuel-asm = "0.5"
fuel-crypto = "0.5"
fuel-gql-client = { version = "0.8", default-features = false }
fuel-tx = "0.12"
fuel-vm = "0.11"
fuel-gql-client = { version = "0.9", default-features = false }
fuel-tx = "0.13"
fuel-vm = "0.12"
futures = "0.3"
hex = "0.4.3"
serde = { version = "1.0", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion forc/src/ops/forc_deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fn create_contract_tx(
storage_slots: Vec<StorageSlot>,
) -> (Transaction, fuel_tx::ContractId) {
let gas_price = 0;
let gas_limit = fuel_tx::default_parameters::MAX_GAS_PER_TX;
let gas_limit = fuel_tx::ConsensusParameters::default().max_gas_per_tx;
let byte_price = 0;
let maturity = 0;
let bytecode_witness_index = 0;
Expand Down
4 changes: 1 addition & 3 deletions forc/src/utils/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ edition = "2021"
license = "Apache-2.0"
[dependencies]
fuels = "0.15"
fuels-abigen-macro = "0.15"
fuels = {{ version = "0.16", features = ["fuel-core-lib"] }}
tokio = {{ version = "1.12", features = ["rt", "macros"] }}
[[test]]
Expand Down Expand Up @@ -93,7 +92,6 @@ pub(crate) fn default_test_program(project_name: &str) -> String {
format!(
"{}{}{}{}{}",
r#"use fuels::{prelude::*, tx::ContractId};
use fuels_abigen_macro::abigen;
// Load abi from json
abigen!(MyContract, "out/debug/"#,
Expand Down
2 changes: 1 addition & 1 deletion forc/src/utils/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub(crate) struct TxParameters {
impl TxParameters {
pub const DEFAULT: Self = Self {
byte_price: 0,
gas_limit: fuel_tx::default_parameters::MAX_GAS_PER_TX,
gas_limit: fuel_tx::ConsensusParameters::DEFAULT.max_gas_per_tx,
gas_price: 0,
};

Expand Down
4 changes: 2 additions & 2 deletions sway-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ dirs = "3.0"
either = "1.6"
fuel-asm = "0.5"
fuel-crypto = "0.5"
fuel-tx = "0.12"
fuel-tx = "0.13"
fuel-types = "0.5"
fuel-vm = "0.11"
fuel-vm = "0.12"
fuels-types = "0.12"
hex = { version = "0.4", optional = true }
im = "15.0"
Expand Down
2 changes: 1 addition & 1 deletion sway-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ description = "Sway core types."
[dependencies]
fuel-asm = "0.5"
fuel-crypto = "0.5"
fuel-tx = "0.12"
fuel-tx = "0.13"
lazy_static = "1.4"
serde = { version = "1.0", features = ["derive"] }
4 changes: 2 additions & 2 deletions test-sig-gen-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ publish = false
[dependencies]
anyhow = "1.0.39"
fuel-crypto = "0.5"
fuel-tx = "0.12"
fuel-tx = "0.13"
fuel-types = { version = "0.5", default-features = false }
fuel-vm = "0.11"
fuel-vm = "0.12"
hex = "0.4"
secp256k1 = { version = "0.20", features = ["recovery"] }
sha3 = "0.10"
Expand Down
4 changes: 2 additions & 2 deletions test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ forc = { path = "../forc", features = ["test"], default-features = false }
forc-pkg = { path = "../forc-pkg" }
forc-util = { path = "../forc-util" }
fuel-asm = "0.5"
fuel-tx = "0.12"
fuel-vm = { version = "0.11", features = ["random"] }
fuel-tx = "0.13"
fuel-vm = { version = "0.12", features = ["random"] }
gag = "1.0"
rand = "0.8"
regex = "1"
Expand Down
2 changes: 1 addition & 1 deletion test/src/e2e_vm_tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub(crate) fn runs_in_vm(file_name: &str, locked: bool) -> (ProgramState, Compil

let script = compile_to_bytes(file_name, locked).unwrap();
let gas_price = 10;
let gas_limit = fuel_tx::default_parameters::MAX_GAS_PER_TX;
let gas_limit = fuel_tx::ConsensusParameters::DEFAULT.max_gas_per_tx;
let byte_price = 0;
let maturity = 0;
let script_data = vec![];
Expand Down
9 changes: 4 additions & 5 deletions test/src/sdk-harness/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ version = "0.0.0"

[dependencies]
assert_matches = "1.5.0"
fuel-core = { version = "0.8", default-features = false }
fuel-gql-client = { version = "0.8", default-features = false }
fuel-core = { version = "0.9", default-features = false }
fuel-gql-client = { version = "0.9", default-features = false }
fuel-types = "0.5"
fuel-vm = "0.11"
fuels = "0.15"
fuels-abigen-macro = "0.15"
fuel-vm = "0.12"
fuels = { version = "0.16", features = ["fuel-core-lib"] }
hex = "0.4.3"
sha2 = "0.10"
sha3 = "0.10.1"
Expand Down
1 change: 0 additions & 1 deletion test/src/sdk-harness/test_projects/auth/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use fuels::{prelude::*, tx::ContractId};
use fuels_abigen_macro::abigen;

abigen!(
AuthContract,
Expand Down
1 change: 0 additions & 1 deletion test/src/sdk-harness/test_projects/call_frames/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use fuel_vm::consts::VM_MAX_RAM;
use fuels::{prelude::*, tx::ContractId};
use fuels_abigen_macro::abigen;

abigen!(
CallFramesTestContract,
Expand Down
1 change: 0 additions & 1 deletion test/src/sdk-harness/test_projects/context/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use fuel_vm::consts::VM_MAX_RAM;
use fuels::{prelude::*, tx::ContractId};
use fuels_abigen_macro::abigen;

abigen!(
TestContextContract,
Expand Down
1 change: 0 additions & 1 deletion test/src/sdk-harness/test_projects/exponentiation/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use fuels::prelude::*;
use fuels::signers::LocalWallet;
use fuels::tx::ContractId;
use fuels_abigen_macro::abigen;

abigen!(TestPowContract, "test_artifacts/pow/out/debug/pow-abi.json");

Expand Down
2 changes: 1 addition & 1 deletion test/src/sdk-harness/test_projects/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ mod context;
mod exponentiation;
mod hashing;
mod logging;
mod methods;
mod reentrancy;
mod registers;
mod script_data;
mod storage;
mod storage_map;
mod token_ops;
mod tx_fields;
mod methods;
1 change: 0 additions & 1 deletion test/src/sdk-harness/test_projects/hashing/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use fuels::{prelude::*, tx::ContractId};
use fuels_abigen_macro::abigen;
use sha2::{Digest, Sha256};
use sha3::Keccak256;

Expand Down
4 changes: 2 additions & 2 deletions test/src/sdk-harness/test_projects/logging/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use fuel_core::service::{Config, FuelService};
use fuel_gql_client::client::FuelClient;
use fuels::contract::script::Script;
use fuels::tx::{default_parameters::MAX_GAS_PER_TX, Transaction};
use fuels::tx::{ConsensusParameters, Transaction};
use hex;

#[tokio::test]
Expand All @@ -12,7 +12,7 @@ async fn run_valid() {

let tx = Transaction::Script {
gas_price: 0,
gas_limit: MAX_GAS_PER_TX,
gas_limit: ConsensusParameters::DEFAULT.max_gas_per_tx,
maturity: 0,
byte_price: 0,
receipts_root: Default::default(),
Expand Down
8 changes: 1 addition & 7 deletions test/src/sdk-harness/test_projects/methods/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use fuels::prelude::*;
use fuels::signers::wallet::Wallet;
use fuels::tx::{default_parameters::MAX_GAS_PER_TX, ContractId};
use fuels_abigen_macro::abigen;

abigen!(
MethodsContract,
Expand All @@ -13,11 +11,7 @@ async fn run_methods_test() {
let wallet = launch_provider_and_get_single_wallet().await;
let instance = get_methods_instance(wallet).await;

let result = instance
.test_function()
.call()
.await
.unwrap();
let result = instance.test_function().call().await.unwrap();
assert_eq!(result.value, true);
}

Expand Down
10 changes: 7 additions & 3 deletions test/src/sdk-harness/test_projects/reentrancy/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use fuels::prelude::*;
use fuels::signers::wallet::Wallet;
use fuels::tx::{default_parameters::MAX_GAS_PER_TX, ContractId};
use fuels_abigen_macro::abigen;
use fuels::tx::{ConsensusParameters, ContractId};

abigen!(
AttackerContract,
Expand All @@ -22,7 +21,12 @@ async fn can_detect_reentrancy() {
let result = attacker_instance
.launch_attack(target_id)
.set_contracts(&[target_id])
.tx_params(TxParameters::new(Some(0), Some(MAX_GAS_PER_TX), None, None))
.tx_params(TxParameters::new(
Some(0),
Some(ConsensusParameters::DEFAULT.max_gas_per_tx),
None,
None,
))
.call()
.await
.unwrap();
Expand Down
1 change: 0 additions & 1 deletion test/src/sdk-harness/test_projects/registers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use fuel_vm::consts::VM_MAX_RAM;
use fuels::prelude::*;
use fuels_abigen_macro::abigen;

abigen!(
TestRegistersContract,
Expand Down
4 changes: 2 additions & 2 deletions test/src/sdk-harness/test_projects/script_data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use assert_matches::assert_matches;
use fuel_core::service::{Config, FuelService};
use fuel_gql_client::client::FuelClient;
use fuels::contract::script::Script;
use fuels::tx::{default_parameters::MAX_GAS_PER_TX, Receipt, Transaction};
use fuels::tx::{ConsensusParameters, Receipt, Transaction};

async fn call_script(script_data: Vec<u8>) -> Result<Vec<Receipt>, fuels::prelude::Error> {
let bin = std::fs::read("test_projects/script_data/out/debug/script_data.bin");
Expand All @@ -11,7 +11,7 @@ async fn call_script(script_data: Vec<u8>) -> Result<Vec<Receipt>, fuels::prelud

let tx = Transaction::Script {
gas_price: 0,
gas_limit: MAX_GAS_PER_TX,
gas_limit: ConsensusParameters::DEFAULT.max_gas_per_tx,
maturity: 0,
byte_price: 0,
receipts_root: Default::default(),
Expand Down
1 change: 0 additions & 1 deletion test/src/sdk-harness/test_projects/storage/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use fuels::prelude::*;
use fuels_abigen_macro::abigen;

abigen!(
TestStorageContract,
Expand Down
1 change: 0 additions & 1 deletion test/src/sdk-harness/test_projects/storage_map/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use fuels::prelude::*;
use fuels_abigen_macro::abigen;

abigen!(
TestStorageMapContract,
Expand Down
1 change: 0 additions & 1 deletion test/src/sdk-harness/test_projects/token_ops/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use fuels::prelude::*;
use fuels::signers::wallet::Wallet;
use fuels::tx::{AssetId, ContractId};
use fuels_abigen_macro::abigen;

abigen!(
TestFuelCoinContract,
Expand Down
15 changes: 9 additions & 6 deletions test/src/sdk-harness/test_projects/tx_fields/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use fuel_types::bytes::WORD_SIZE;
use fuel_vm::consts::VM_TX_MEMORY;
use fuel_vm::fuel_tx::ConsensusParameters;
use fuels::prelude::*;
use fuels::signers::wallet::Wallet;
use fuels::tx::{Bytes32, ContractId};
use fuels_abigen_macro::abigen;
use std::str::FromStr;

abigen!(
TxContractTest,
Expand Down Expand Up @@ -92,7 +92,7 @@ async fn can_get_maturity() {
async fn can_get_script_length() {
let (contract_instance, _, _) = get_contracts().await;
// TODO use programmatic script length https://github.com/FuelLabs/fuels-rs/issues/181
let script_length = 24;
let script_length = 32;

let result = contract_instance
.get_tx_script_length()
Expand All @@ -106,7 +106,7 @@ async fn can_get_script_length() {
async fn can_get_script_data_length() {
let (contract_instance, _, _) = get_contracts().await;
// TODO make this programmatic.
let script_data_length = 80;
let script_data_length = 88;

let result = contract_instance
.get_tx_script_data_length()
Expand Down Expand Up @@ -158,7 +158,9 @@ async fn can_get_witnesses_count() {
#[tokio::test]
async fn can_get_receipts_root() {
let (contract_instance, _, _) = get_contracts().await;
let zero_receipts_root = Bytes32::default();
let zero_receipts_root =
Bytes32::from_str("4be973feb50f1dabb9b2e451229135add52f9c0973c11e556fe5bce4a19df470")
.unwrap();

let result = contract_instance
.get_tx_receipts_root()
Expand Down Expand Up @@ -187,7 +189,8 @@ async fn can_get_script_start_offset() {
+ WORD_SIZE // Outputs size
+ WORD_SIZE // Witnesses size
+ Bytes32::LEN; // Receipts root
let script_start_offset = VM_TX_MEMORY + TRANSACTION_SCRIPT_FIXED_SIZE;
let script_start_offset =
ConsensusParameters::DEFAULT.tx_offset() + TRANSACTION_SCRIPT_FIXED_SIZE;

let result = contract_instance
.get_tx_script_start_offset()
Expand Down

0 comments on commit 719310d

Please sign in to comment.