Skip to content

Commit e27425c

Browse files
committed
test: fetch actors bundle from github instead of using cargo
Primarily, this removes an annoying circular dependency between these utilities and the actors. Additionally, this makes it very clear that the actors we're building won't use the code in this repo. Unlike normal rust builds, actor bundle builds don't automatically patch workspaces. I've configured it to fetch v15 and we'll have to update that as we go. If you want to test with newer actors, you'll need to build a bundle yourself and drop it in `testing/bundles/builtin-actors.car`. Part of filecoin-project/builtin-actors#1664
1 parent f7a979a commit e27425c

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-13
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ Cargo.lock
1616
# Code coverage instrumentation
1717
coverage/
1818
*.profraw
19+
20+
testing/bundles/

Makefile

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ WASM_EXCLUSION = \
99
--exclude frc46_factory_token \
1010
--exclude frc53_test_actor
1111

12+
ACTORS_VERSION=v15.0.0
13+
ACTORS_NETWORK=mainnet
14+
ACTORS_BUNDLE_NAME=builtin-actors-${ACTORS_VERSION}-${ACTORS_NETWORK}.car
15+
ACTORS_URL=https://github.com/filecoin-project/builtin-actors/releases/download/${ACTORS_VERSION}/builtin-actors-${ACTORS_NETWORK}.car
16+
1217
# actors are built to WASM via the helix_test_actors crate and be built individually as standalone
1318
# crates so we exclude the from this convenience target
1419
build: install-toolchain
@@ -20,18 +25,30 @@ check: install-toolchain
2025

2126
check-build: check build
2227

28+
29+
testing/bundles/${ACTORS_BUNDLE_NAME}:
30+
curl -fL --create-dirs --output $@ ${ACTORS_URL}
31+
32+
fetch-bundle: testing/bundles/${ACTORS_BUNDLE_NAME}
33+
ln -sf ${ACTORS_BUNDLE_NAME} testing/bundles/builtin-actors.car
34+
.PHONY: fetch-bundle
35+
36+
37+
test-deps: install-toolchain fetch-bundle
38+
.PHONY: test-deps
39+
2340
# run all tests, this will not work if using RUSTFLAGS="-Zprofile" to generate profile info or coverage reports
2441
# as any WASM targets will fail to build
25-
test: install-toolchain
42+
test: test-deps
2643
cargo test
2744

2845
# tests excluding actors so we can generate coverage reports during CI build
2946
# WASM targets such as actors do not support this so are excluded
30-
test-coverage: install-toolchain
47+
test-coverage: test-deps
3148
cargo test --workspace $(WASM_EXCLUSION)
3249

3350
# separate actor testing stage to run from CI without coverage support
34-
test-actors: install-toolchain
51+
test-actors: test-deps
3552
cargo test --package greeter --package helix_integration_tests
3653

3754
install-toolchain:
@@ -44,6 +61,7 @@ clean:
4461
cargo clean
4562
find . -name '*.profraw' -delete
4663
rm Cargo.lock
64+
rm -r testing/bundles
4765

4866
# generate local coverage report in html format using grcov
4967
# install it with `cargo install grcov`

testing/integration/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ serde = { workspace = true }
2323
serde_tuple = { workspace = true }
2424

2525
[dev-dependencies]
26-
actors = { package = "fil_builtin_actors_bundle", git = "https://github.com/filecoin-project/builtin-actors", branch = "master" }
2726
helix_test_actors = { path = "../test_actors" }
27+
reqwest = "0.12.15"
2828
token_impl = { path = "../test_actors/actors/frc46_factory_token/token_impl" }

testing/integration/tests/common/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ use serde::Serialize;
1818
pub mod frc46_token_helpers;
1919
pub mod frc53_nft_helpers;
2020

21+
static BUNDLE_CAR: &'static [u8] = include_bytes!("../../../bundles/builtin-actors.car");
22+
2123
/// Helper routines to simplify common operations with a [`Tester`].
2224
pub trait TestHelpers {
2325
/// Call a method on an actor.
@@ -65,7 +67,7 @@ pub fn load_actor_wasm(path: &str) -> Vec<u8> {
6567
/// This mainly cuts down on noise with importing the built-in actor bundle and network/state tree
6668
/// versions.
6769
pub fn construct_tester<BS: Blockstore + Clone, E: Externs>(blockstore: &BS) -> Tester<BS, E> {
68-
let bundle_root = bundle::import_bundle(&blockstore, actors::BUNDLE_CAR).unwrap();
70+
let bundle_root = bundle::import_bundle(&blockstore, BUNDLE_CAR).unwrap();
6971

7072
Tester::new(NetworkVersion::V21, StateTreeVersion::V5, bundle_root, blockstore.clone()).unwrap()
7173
}

testing/integration/tests/frc46_tokens.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ use cid::Cid;
22
use frc42_dispatch::method_hash;
33
use frc46_token::token::{state::TokenState, types::MintReturn};
44
use fvm::executor::{ApplyKind, Executor};
5-
use fvm_integration_tests::bundle;
65
use fvm_integration_tests::dummy::DummyExterns;
7-
use fvm_integration_tests::tester::{Account, Tester};
6+
use fvm_integration_tests::tester::Account;
87
use fvm_ipld_blockstore::MemoryBlockstore;
98
use fvm_ipld_encoding::RawBytes;
109
use fvm_shared::address::Address;
1110
use fvm_shared::bigint::Zero;
1211
use fvm_shared::econ::TokenAmount;
1312
use fvm_shared::message::Message;
14-
use fvm_shared::state::StateTreeVersion;
15-
use fvm_shared::version::NetworkVersion;
1613
use helix_test_actors::BASIC_RECEIVING_ACTOR_BINARY;
1714
use helix_test_actors::BASIC_TOKEN_ACTOR_BINARY;
1815
use serde_tuple::{Deserialize_tuple, Serialize_tuple};
1916

17+
mod common;
18+
use common::construct_tester;
19+
2020
// Duplicated type from basic_token_actor
2121
#[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug)]
2222
pub struct MintParams {
@@ -28,10 +28,7 @@ pub struct MintParams {
2828
#[test]
2929
fn it_mints_tokens() {
3030
let blockstore = MemoryBlockstore::default();
31-
let bundle_root = bundle::import_bundle(&blockstore, actors::BUNDLE_CAR).unwrap();
32-
let mut tester =
33-
Tester::new(NetworkVersion::V21, StateTreeVersion::V5, bundle_root, blockstore.clone())
34-
.unwrap();
31+
let mut tester = construct_tester(&blockstore);
3532

3633
let minter: [Account; 1] = tester.create_accounts().unwrap();
3734

0 commit comments

Comments
 (0)