Skip to content

Commit

Permalink
Update to latest Fuel versions (#16)
Browse files Browse the repository at this point in the history
* Update to latest Fuel versions

* Update tests

* fmt

* Use latest fuel-core in ci

* Newer rust install

* Clippy

* Install fuel-core binary correctly

* Fix some minor errors
  • Loading branch information
Dentosal authored Nov 27, 2023
1 parent fc07a64 commit 68b3a3c
Show file tree
Hide file tree
Showing 7 changed files with 292 additions and 145 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ jobs:
args: --verbose --all-targets

- name: Install fuel-core for tests
uses: baptiste0928/cargo-install@v1
uses: baptiste0928/cargo-install@v2
with:
crate: fuel-core
version: "0.8"
crate: fuel-core-bin
version: "0.21"

- name: Run tests
uses: actions-rs/cargo@v1
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ edition = "2021"

[dependencies]
clap = { version = "3.1", features = ["env", "derive"] }
fuel-gql-client = { version = "0.9" }
fuel-types = { version = "0.3", features = ["serde-types"] }
fuel-vm = { version = "0.12", features = ["serde"] }
fuel-core-client = { version = "0.21" }
fuel-types = { version = "0.43", features = ["serde"] }
fuel-vm = { version = "0.43", features = ["serde"] }
serde_json = "1.0"
shellfish = { version = "0.6.0", features = ["rustyline", "async", "tokio"] }
surf = "2.3"
Expand Down
219 changes: 94 additions & 125 deletions docs/walkthrough.md

Large diffs are not rendered by default.

187 changes: 180 additions & 7 deletions examples/example_tx.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,187 @@
{
"Script": {
"byte_price": 0,
"gas_price": 0,
"gas_limit": 1000000,
"maturity": 0,
"script": [80,64,0,202,80,68,0,186,51,65,16,0,36,4,0,0],
"script_gas_limit": 1000000,
"script": [
144,
0,
0,
4,
71,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
68,
93,
252,
192,
1,
16,
255,
243,
0,
26,
72,
16,
0,
26,
68,
0,
0,
93,
67,
240,
0,
22,
65,
20,
0,
115,
64,
0,
13,
51,
72,
0,
0,
36,
0,
0,
0,
16,
69,
16,
64,
27,
73,
36,
64,
144,
0,
0,
8,
71,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
5
],
"script_data": [],
"inputs": [],
"policies": {
"bits": "GasPrice",
"values": [
0,
0,
0,
0
]
},
"inputs": [
{
"CoinSigned": {
"utxo_id": {
"tx_id": "c49d65de61cf04588a764b557d25cc6c6b4bc0d7429227e2a21e61c213b3a3e2",
"output_index": 18
},
"owner": "f1e92c42b90934aa6372e30bc568a326f6e66a1a0288595e6e3fbd392a4f3e6e",
"amount": 10599410012256088338,
"asset_id": "2cafad611543e0265d89f1c2b60d9ebf5d56ad7e23d9827d6b522fd4d6e44bc3",
"tx_pointer": {
"block_height": 0,
"tx_index": 0
},
"witness_index": 0,
"maturity": 0,
"predicate_gas_used": null,
"predicate": null,
"predicate_data": null
}
}
],
"outputs": [],
"witnesses": [],
"witnesses": [
{
"data": [
156,
254,
34,
102,
65,
96,
133,
170,
254,
105,
147,
35,
196,
199,
179,
133,
132,
240,
208,
149,
11,
46,
30,
96,
44,
91,
121,
195,
145,
184,
159,
235,
117,
82,
135,
41,
84,
154,
102,
61,
61,
16,
99,
123,
58,
173,
75,
226,
219,
139,
62,
33,
41,
176,
16,
18,
132,
178,
8,
125,
130,
169,
32,
108
]
}
],
"receipts_root": "0000000000000000000000000000000000000000000000000000000000000000"
}
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod names;

// Re-exports
pub use fuel_gql_client::client::{schema::RunResult, FuelClient};
pub use fuel_core_client::client::{schema::RunResult, FuelClient};
pub use fuel_vm::prelude::{ContractId, Transaction};
13 changes: 8 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async fn cmd_step(state: &mut State, mut args: Vec<String>) -> Result<(), Box<dy
.client
.set_single_stepping(
&state.session_id,
args.get(0)
args.first()
.map(|v| !["off", "no", "disable"].contains(&v.as_str()))
.unwrap_or(true),
)
Expand Down Expand Up @@ -198,21 +198,24 @@ async fn cmd_registers(state: &mut State, mut args: Vec<String>) -> Result<(), B

if args.is_empty() {
for r in 0..VM_REGISTER_COUNT {
let value = state.client.register(&state.session_id, r).await?;
let value = state.client.register(&state.session_id, r as u32).await?;
println!("reg[{:#x}] = {:<8} # {}", r, value, register_name(r));
}
} else {
for arg in &args {
if let Some(v) = parse_int(arg) {
if v < VM_REGISTER_COUNT {
let value = state.client.register(&state.session_id, v).await?;
let value = state.client.register(&state.session_id, v as u32).await?;
println!("reg[{:#02x}] = {:<8} # {}", v, value, register_name(v));
} else {
println!("Register index too large {}", v);
return Ok(());
}
} else if let Some(index) = names::register_index(arg) {
let value = state.client.register(&state.session_id, index).await?;
let value = state
.client
.register(&state.session_id, index as u32)
.await?;
println!("reg[{:#02x}] = {:<8} # {}", index, value, arg);
} else {
println!("Unknown register name {}", arg);
Expand Down Expand Up @@ -245,7 +248,7 @@ async fn cmd_memory(state: &mut State, mut args: Vec<String>) -> Result<(), Box<

let mem = state
.client
.memory(&state.session_id, offset, limit)
.memory(&state.session_id, offset as u32, limit as u32)
.await?;

for (i, chunk) in mem.chunks(WORD_SIZE).enumerate() {
Expand Down
4 changes: 3 additions & 1 deletion tests/cli_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ fn test_cli() {
let port = portpicker::pick_unused_port().expect("No ports free");

let mut fuel_core = Command::new("fuel-core")
.arg("run")
.arg("--debug")
.arg("--db-type")
.arg("in-memory")
.arg("--port")
Expand Down Expand Up @@ -43,7 +45,7 @@ fn test_cli() {
cmd.send_line("step on").unwrap();
cmd.exp_regex(r">> ").unwrap();
cmd.send_line("continue").unwrap();
cmd.exp_regex(r"Stopped on breakpoint at address 4 of contract 0x0{64}")
cmd.exp_regex(r"Stopped on breakpoint at address 16 of contract 0x0{64}")
.unwrap();
cmd.send_line("step off").unwrap();
cmd.exp_regex(r">> ").unwrap();
Expand Down

0 comments on commit 68b3a3c

Please sign in to comment.