Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
arajasek authored and shamb0 committed Jan 31, 2023
1 parent 47fee6b commit aa083b4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 35 deletions.
13 changes: 2 additions & 11 deletions actors/account/tests/account_actor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,10 @@ fn authenticate_message() {
});
expect_abort_contains_message(
ExitCode::USR_ILLEGAL_ARGUMENT,
rt.call::<AccountActor>(3, params).unwrap_err().exit_code()
"bad signature",
rt.call::<AccountActor>(Method::AuthenticateMessageExported as MethodNum, params),
);
rt.verify();

// Ok to call exported method number
rt.expect_validate_caller_any();
rt.expect_verify_signature(ExpectedVerifySig {
sig: Signature::new_secp256k1(vec![]),
signer: addr,
plaintext: vec![],
result: Ok(()),
});
rt.call::<AccountActor>(Method::AuthenticateMessageExported as MethodNum, &params).unwrap();
}

fn check_state(rt: &MockRuntime) {
Expand Down
2 changes: 0 additions & 2 deletions actors/datacap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ lazy_static! {
}

/// Datacap actor methods available
/// Some methods are available under 2 method nums -- a static number for "private" builtin actor usage,
/// and via FRC-0042 calling convention, with number determined by method name.
#[derive(FromPrimitive)]
#[repr(u64)]
pub enum Method {
Expand Down
22 changes: 21 additions & 1 deletion actors/datacap/tests/datacap_actor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,27 @@ mod construction {
.deserialize()
.unwrap();
rt.verify();
assert_eq!(ret.granularity, DATACAP_GRANULARITY)
assert_eq!(ret.granularity, DATACAP_GRANULARITY);

rt.expect_validate_caller_any();
let ret: String = rt
.call::<Actor>(Method::NameExported as MethodNum, None)
.unwrap()
.unwrap()
.deserialize()
.unwrap();
rt.verify();
assert_eq!(ret, "DataCap");

rt.expect_validate_caller_any();
let ret: String = rt
.call::<Actor>(Method::SymbolExported as MethodNum, None)
.unwrap()
.unwrap()
.deserialize()
.unwrap();
rt.verify();
assert_eq!(ret, "DCAP")
}
}

Expand Down
10 changes: 5 additions & 5 deletions actors/market/tests/deal_api_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use fvm_ipld_encoding::RawBytes;
use fvm_shared::clock::ChainEpoch;
use fvm_ipld_encoding::ipld_block::IpldBlock;
use fvm_shared::clock::{ChainEpoch, EPOCH_UNDEFINED};
use fvm_shared::error::ExitCode;
use fvm_shared::METHOD_SEND;
use serde::de::DeserializeOwned;
Expand Down Expand Up @@ -102,8 +102,8 @@ fn activation() {

let activation: GetDealActivationReturn =
query_deal(&mut rt, Method::GetDealActivationExported, id);
assert_eq!(-1, activation.activated);
assert_eq!(-1, activation.terminated);
assert_eq!(EPOCH_UNDEFINED, activation.activated);
assert_eq!(EPOCH_UNDEFINED, activation.terminated);

// activate the deal
let activate_epoch = start_epoch - 2;
Expand All @@ -112,7 +112,7 @@ fn activation() {
let activation: GetDealActivationReturn =
query_deal(&mut rt, Method::GetDealActivationExported, id);
assert_eq!(activate_epoch, activation.activated);
assert_eq!(-1, activation.terminated);
assert_eq!(EPOCH_UNDEFINED, activation.terminated);

// terminate early
let terminate_epoch = activate_epoch + 100;
Expand Down
2 changes: 1 addition & 1 deletion actors/paych/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl Actor {

let from = Self::resolve_address(rt, &params.from)
.with_context_code(ExitCode::USR_ILLEGAL_ARGUMENT, || {
format!("to address not found {}", params.to)
format!("from address not found {}", params.to)
})?;

let empty_arr_cid =
Expand Down
15 changes: 0 additions & 15 deletions runtime/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -933,21 +933,6 @@ impl<BS: Blockstore> Runtime for MockRuntime<BS> {
&& expected_msg.method == method
&& expected_msg.params == params
&& expected_msg.value == value,
"message sent does not match expectation.\n\
message - to: {:?}, method: {:?}, value: {:?}, params: {:?}\n\
expected - to: {:?}, method: {:?}, value: {:?}, params: {:?}\n\
method match {}, params match {}, value match {}",
to,
method,
value,
params,
expected_msg.to,
expected_msg.method,
expected_msg.value,
expected_msg.params,
expected_msg.method == method,
expected_msg.params == params,
expected_msg.value == value,
);

{
Expand Down

0 comments on commit aa083b4

Please sign in to comment.