Skip to content

Commit 0679eec

Browse files
authored
Export integration tests (#1345)
* move test related utils and code out of the test_vm crate * add utils into integration_tests folder * port authenticate message test * port withdraw balance test * batch_onboarding * batch_onboarding_deals * change beneficiary tests * change owner test * commit_post * datacap tests * evm tests * extend sectors tests * cargo updates: wip * market miner withdrawal * multisig test * power scenario * publish deals * replica update test * terminate test * test vm test * verified claim * verifreg tests * add back an accidentally deleted test * remove unecessary deps from test_vm * add TODO
1 parent ae4fa9a commit 0679eec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+7319
-6751
lines changed

Cargo.lock

Lines changed: 55 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ members = [
5656
"state",
5757
"runtime",
5858
"test_vm",
59-
"vm_api"
59+
"vm_api",
60+
"integration_tests"
6061
]
6162

6263
[workspace.dependencies]
@@ -141,7 +142,9 @@ fil_actor_verifreg = { version = "12.0.0", path = "actors/verifreg" }
141142
fil_actors_evm_shared = { version = "12.0.0", path = "actors/evm/shared" }
142143
fil_actors_runtime = { version = "12.0.0", path = "runtime" }
143144
fil_builtin_actors_state = { version = "12.0.0", path = "state"}
145+
fil_actors_integration_tests = { version = "1.0.0", path = "integration_tests" }
144146
vm_api = { version = "1.0.0", path = "vm_api" }
147+
test_vm = { version = "12.0.0", path = "test_vm" }
145148

146149
[patch.crates-io]
147150
#fvm_shared = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" }

integration_tests/Cargo.toml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
[package]
2+
name = "fil_actors_integration_tests"
3+
description = "Portable integration tests for FVM targets"
4+
version = "1.0.0"
5+
license = "MIT OR Apache-2.0"
6+
authors = ["Protocol Labs", "Filecoin Core Devs"]
7+
edition = "2021"
8+
keywords = ["filecoin", "web3", "wasm"]
9+
publish = false
10+
11+
[lib]
12+
13+
[dependencies]
14+
fil_builtin_actors_state = { workspace = true }
15+
fil_actors_runtime = { workspace = true, features = [ "test_utils" ] }
16+
fil_actor_init = { workspace = true }
17+
fil_actor_cron = { workspace = true }
18+
fil_actor_system = { workspace = true }
19+
fil_actor_account = { workspace = true }
20+
fil_actor_multisig = { workspace = true }
21+
fil_actor_paych = { workspace = true }
22+
fil_actor_reward = { workspace = true }
23+
fil_actor_power = { workspace = true }
24+
fil_actor_market = { workspace = true }
25+
fil_actor_verifreg = { workspace = true }
26+
fil_actor_miner = { workspace = true }
27+
fil_actor_datacap = { workspace = true }
28+
fil_actor_evm = { workspace = true }
29+
fil_actor_eam = { workspace = true }
30+
fil_actor_ethaccount = { workspace = true }
31+
fil_actors_evm_shared = { workspace = true }
32+
vm_api = { workspace = true }
33+
34+
anyhow = { workspace = true }
35+
bimap = { workspace = true }
36+
blake2b_simd = { workspace = true }
37+
cid = { workspace = true }
38+
ethers = { workspace = true }
39+
frc42_dispatch = { workspace = true }
40+
frc46_token = { workspace = true }
41+
fvm_actor_utils = { workspace = true }
42+
fvm_ipld_bitfield = { workspace = true }
43+
fvm_ipld_blockstore = { workspace = true }
44+
fvm_ipld_encoding = { workspace = true }
45+
fvm_ipld_hamt = { workspace = true }
46+
fvm_shared = { workspace = true }
47+
hex = { workspace = true }
48+
indexmap = { workspace = true }
49+
integer-encoding = { workspace = true }
50+
lazy_static = { workspace = true }
51+
log = { workspace = true }
52+
num-derive = { workspace = true }
53+
num-traits = { workspace = true }
54+
rand = { workspace = true }
55+
rand_chacha = { workspace = true }
56+
regex = { workspace = true }
57+
serde = { workspace = true }
58+
thiserror = { workspace = true }
59+
libsecp256k1 = { workspace = true }
60+
61+
[dev-dependencies]
62+
multihash = { workspace = true }
63+
test-case = { workspace = true }
64+
hex-literal = { workspace = true }
File renamed without changes.
File renamed without changes.

integration_tests/src/lib.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
use fvm_shared::{
2+
address::{Address, FIRST_NON_SINGLETON_ADDR},
3+
econ::TokenAmount,
4+
sector::StoragePower,
5+
smooth::FilterEstimate,
6+
ActorID,
7+
};
8+
9+
pub mod deals;
10+
pub mod expects;
11+
pub mod tests;
12+
pub mod util;
13+
14+
// accounts for verifreg root signer and msig
15+
pub const VERIFREG_ROOT_KEY: &[u8] = &[200; fvm_shared::address::BLS_PUB_LEN];
16+
pub const TEST_VERIFREG_ROOT_SIGNER_ADDR: Address = Address::new_id(FIRST_NON_SINGLETON_ADDR);
17+
pub const TEST_VERIFREG_ROOT_ADDR: Address = Address::new_id(FIRST_NON_SINGLETON_ADDR + 1);
18+
19+
// account actor seeding funds created by new_with_singletons
20+
pub const FAUCET_ROOT_KEY: &[u8] = &[153; fvm_shared::address::BLS_PUB_LEN];
21+
pub const TEST_FAUCET_ADDR: Address = Address::new_id(FIRST_NON_SINGLETON_ADDR + 2);
22+
pub const FIRST_TEST_USER_ADDR: ActorID = FIRST_NON_SINGLETON_ADDR + 3;
23+
24+
// static values for predictable testing
25+
pub const TEST_VM_RAND_ARRAY: [u8; 32] = [
26+
1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
27+
26, 27, 28, 29, 30, 31, 32,
28+
];
29+
pub const TEST_VM_INVALID_POST: &str = "i_am_invalid_post";
30+
31+
pub struct MinerBalances {
32+
pub available_balance: TokenAmount,
33+
pub vesting_balance: TokenAmount,
34+
pub initial_pledge: TokenAmount,
35+
pub pre_commit_deposit: TokenAmount,
36+
}
37+
38+
pub struct NetworkStats {
39+
pub total_raw_byte_power: StoragePower,
40+
pub total_bytes_committed: StoragePower,
41+
pub total_quality_adj_power: StoragePower,
42+
pub total_qa_bytes_committed: StoragePower,
43+
pub total_pledge_collateral: TokenAmount,
44+
pub this_epoch_raw_byte_power: StoragePower,
45+
pub this_epoch_quality_adj_power: StoragePower,
46+
pub this_epoch_pledge_collateral: TokenAmount,
47+
pub miner_count: i64,
48+
pub miner_above_min_power_count: i64,
49+
pub this_epoch_reward: TokenAmount,
50+
pub this_epoch_reward_smoothed: FilterEstimate,
51+
pub this_epoch_baseline_power: StoragePower,
52+
pub total_storage_power_reward: TokenAmount,
53+
pub total_client_locked_collateral: TokenAmount,
54+
pub total_provider_locked_collateral: TokenAmount,
55+
pub total_client_storage_fee: TokenAmount,
56+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
use fil_actor_account::types::AuthenticateMessageParams;
2+
use fil_actor_account::Method::AuthenticateMessageExported;
3+
use fvm_ipld_encoding::RawBytes;
4+
use fvm_shared::bigint::Zero;
5+
use fvm_shared::econ::TokenAmount;
6+
use fvm_shared::error::ExitCode;
7+
8+
use crate::util::{create_accounts, generate_deal_proposal};
9+
use vm_api::util::{apply_code, apply_ok};
10+
use vm_api::VM;
11+
12+
/// Using a deal proposal as a serialized message, we confirm that:
13+
/// - calls to Account::authenticate_message with valid signatures succeed
14+
/// - calls to Account::authenticate_message with invalid signatures fail
15+
pub fn account_authenticate_message_test(v: &dyn VM) {
16+
let addr = create_accounts(v, 1, &TokenAmount::from_whole(10_000))[0];
17+
18+
let proposal =
19+
generate_deal_proposal(&addr, &addr, &TokenAmount::zero(), &TokenAmount::zero(), 0, 0);
20+
let proposal_ser =
21+
RawBytes::serialize(proposal).expect("failed to marshal deal proposal").to_vec();
22+
23+
// With a good sig, message succeeds
24+
let authenticate_message_params = AuthenticateMessageParams {
25+
signature: proposal_ser.clone(),
26+
message: proposal_ser.clone(),
27+
};
28+
apply_ok(
29+
v,
30+
&addr,
31+
&addr,
32+
&TokenAmount::zero(),
33+
AuthenticateMessageExported as u64,
34+
Some(authenticate_message_params),
35+
);
36+
37+
// Bad, bad sig! message fails
38+
let authenticate_message_params =
39+
AuthenticateMessageParams { signature: vec![], message: proposal_ser };
40+
apply_code(
41+
v,
42+
&addr,
43+
&addr,
44+
&TokenAmount::zero(),
45+
AuthenticateMessageExported as u64,
46+
Some(authenticate_message_params),
47+
ExitCode::USR_ILLEGAL_ARGUMENT,
48+
);
49+
}

0 commit comments

Comments
 (0)