Skip to content

Commit

Permalink
Integration test for prove_commit_sectors2 (#1450)
Browse files Browse the repository at this point in the history
  • Loading branch information
anorth committed Dec 14, 2023
1 parent 04f3843 commit 39b488b
Show file tree
Hide file tree
Showing 10 changed files with 546 additions and 50 deletions.
4 changes: 2 additions & 2 deletions actors/market/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ impl State {
Ok(())
}

fn load_provider_sectors<BS>(&self, store: BS) -> Result<ProviderSectorsMap<BS>, ActorError>
pub fn load_provider_sectors<BS>(&self, store: BS) -> Result<ProviderSectorsMap<BS>, ActorError>
where
BS: Blockstore,
{
Expand Down Expand Up @@ -1128,7 +1128,7 @@ where
.context_code(ExitCode::USR_ILLEGAL_STATE, "failed to lookup pending deal")
}

fn load_provider_sector_deals<BS>(
pub fn load_provider_sector_deals<BS>(
store: BS,
provider_sectors: &ProviderSectorsMap<BS>,
provider: &Address,
Expand Down
7 changes: 5 additions & 2 deletions actors/miner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5358,8 +5358,11 @@ fn activate_sectors_pieces(
rt,
&activation_info.piece_manifests,
activation_info.sector_type,
)?;
if !declared_commd.eq(&computed_commd) {
)?
.get_cid(activation_info.sector_type)?;
// A declared zero CommD might be compact or fully computed,
// so normalize to the computed value before checking.
if !declared_commd.get_cid(activation_info.sector_type)?.eq(&computed_commd) {
return Err(actor_error!(
illegal_argument,
"unsealed CID does not match pieces for sector {}, computed {:?} declared {:?}",
Expand Down
46 changes: 44 additions & 2 deletions integration_tests/src/expects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ use fil_actor_miner::{IsControllingAddressParam, PowerPair};
use fil_actor_power::{UpdateClaimedPowerParams, UpdatePledgeTotalParams};
use fil_actor_verifreg::GetClaimsParams;
use fil_actors_runtime::{
BURNT_FUNDS_ACTOR_ADDR, REWARD_ACTOR_ADDR, STORAGE_MARKET_ACTOR_ADDR, STORAGE_POWER_ACTOR_ADDR,
STORAGE_POWER_ACTOR_ID, VERIFIED_REGISTRY_ACTOR_ADDR,
BURNT_FUNDS_ACTOR_ADDR, DATACAP_TOKEN_ACTOR_ADDR, DATACAP_TOKEN_ACTOR_ID, REWARD_ACTOR_ADDR,
STORAGE_MARKET_ACTOR_ADDR, STORAGE_POWER_ACTOR_ADDR, STORAGE_POWER_ACTOR_ID,
VERIFIED_REGISTRY_ACTOR_ADDR, VERIFIED_REGISTRY_ACTOR_ID,
};

use vm_api::trace::ExpectInvocation;
Expand Down Expand Up @@ -208,6 +209,47 @@ impl Expect {
..Default::default()
}
}
pub fn datacap_transfer_to_verifreg(
from: ActorID,
amount: TokenAmount,
operator_data: RawBytes,
burn: bool,
) -> ExpectInvocation {
let payload = IpldBlock::serialize_cbor(&FRC46TokenReceived {
from,
to: VERIFIED_REGISTRY_ACTOR_ADDR.id().unwrap(),
operator: from,
amount: amount.clone(),
operator_data,
token_data: RawBytes::default(),
})
.unwrap();
let burn_invocs = if burn {
vec![Expect::frc46_burn(VERIFIED_REGISTRY_ACTOR_ID, DATACAP_TOKEN_ACTOR_ADDR, amount)]
} else {
vec![]
};
ExpectInvocation {
from,
to: DATACAP_TOKEN_ACTOR_ADDR,
method: fil_actor_datacap::Method::TransferExported as u64,
subinvocs: Some(vec![ExpectInvocation {
from: DATACAP_TOKEN_ACTOR_ID,
to: VERIFIED_REGISTRY_ACTOR_ADDR,
method: fil_actor_verifreg::Method::UniversalReceiverHook as u64,
params: Some(
IpldBlock::serialize_cbor(&UniversalReceiverParams {
type_: FRC46_TOKEN_TYPE,
payload: payload.unwrap().data.into(),
})
.unwrap(),
),
subinvocs: Some(burn_invocs),
..Default::default()
}]),
..Default::default()
}
}
pub fn verifreg_get_claims(
from: ActorID,
miner: ActorID,
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ mod verifreg_remove_datacap_test;
pub use verifreg_remove_datacap_test::*;
mod withdraw_balance_test;
pub use withdraw_balance_test::*;
mod prove_commit2_test;
pub use prove_commit2_test::*;
Loading

0 comments on commit 39b488b

Please sign in to comment.