Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

show gas usage #216

Merged
merged 2 commits into from
Feb 8, 2023
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
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,34 +71,34 @@ test_integration: build build_builtin_actors
cd testing && cargo test

test_miner_integration: build build_builtin_actors
cd testing && cargo test miner_test
cd testing && cargo test miner_test -- --nocapture

test_market_integration: build build_builtin_actors
cd testing && cargo test market_test
cd testing && cargo test market_test -- --nocapture

test_power_integration: build build_builtin_actors
cd testing && cargo test power_test
cd testing && cargo test power_test -- --nocapture

test_verifreg_integration: build build_builtin_actors
cd testing && cargo test verifreg_test
cd testing && cargo test verifreg_test -- --nocapture

test_datacap_integration: build build_builtin_actors
cd testing && cargo test datacap_test
cd testing && cargo test datacap_test -- --nocapture

test_init_integration: build build_builtin_actors
cd testing && cargo test init_test
cd testing && cargo test init_test -- --nocapture

test_account_integration: build build_builtin_actors
cd testing && cargo test account_test
cd testing && cargo test account_test -- --nocapture

test_multisig_integration: build build_builtin_actors
cd testing && cargo test multisig_test
cd testing && cargo test multisig_test -- --nocapture

test_precompiles_integration: build build_builtin_actors
cd testing && cargo test precompiles_test
cd testing && cargo test precompiles_test -- --nocapture

test_send_integration: build build_builtin_actors
cd testing && cargo test send_test
cd testing && cargo test send_test -- --nocapture

################ DEPS ################

Expand Down
162 changes: 160 additions & 2 deletions testing/Cargo.lock

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

1 change: 1 addition & 0 deletions testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ libipld-core = { version = "0.13.1", features = ["serde-codec"] }
cid = "0.8.6"
rand_core = "0.6.4"
anyhow = "1.0.47"
prettytable-rs = "0.10"

fil_actors_runtime = { version = "10.0.0-alpha.1", git = "https://github.com/filecoin-project/builtin-actors", tag = "dev/20230114-pre-rc.3", features = ["m2-native"] }
fil_actor_eam = { version = "10.0.0-alpha.1", git = "https://github.com/filecoin-project/builtin-actors", tag = "dev/20230114-pre-rc.3" }
Expand Down
20 changes: 19 additions & 1 deletion testing/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
pub mod helpers;
#[macro_use]
extern crate prettytable;

pub mod helpers;
pub mod setup;

use prettytable::Table;

pub type GasResult = Vec<(String, i64)>;

pub fn create_gas_table(gas_result: GasResult) -> Table {
let mut table = Table::new();
table.add_row(row!["Function", "Gas"]);
gas_result.iter().for_each(|(description, gas)| {
table.add_row(row![description, gas]);
});

table
}
36 changes: 36 additions & 0 deletions testing/src/setup.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use cid::Cid;
use fvm::machine::Manifest;
use fvm_ipld_blockstore::MemoryBlockstore;
use fvm_integration_tests::tester::Tester;
use fvm_shared::state::StateTreeVersion;
use fvm_shared::version::NetworkVersion;
use fvm_integration_tests::bundle;
use fvm_ipld_encoding::CborStore;
use fvm_integration_tests::dummy::DummyExterns;

pub fn setup_tester() -> (Tester<MemoryBlockstore, DummyExterns>, Manifest) {
let bs = MemoryBlockstore::default();
let actors = std::fs::read("./builtin-actors/output/builtin-actors-devnet-wasm.car")
.expect("Unable to read actor devnet file");
let bundle_root = bundle::import_bundle(&bs, &actors).unwrap();

let (manifest_version, manifest_data_cid): (u32, Cid) =
bs.get_cbor(&bundle_root).unwrap().unwrap();
let manifest = Manifest::load(&bs, &manifest_data_cid, manifest_version).unwrap();

let tester =
Tester::new(NetworkVersion::V18, StateTreeVersion::V5, bundle_root, bs).unwrap();

return (tester, manifest)
}

pub fn load_evm(path: &str) -> Vec<u8> {
let wasm_path = std::env::current_dir()
.unwrap()
.join(path)
.canonicalize()
.unwrap();
let evm_hex = std::fs::read(wasm_path).expect("Unable to read file");

hex::decode(evm_hex).unwrap()
}
Loading