Skip to content

Commit 6c151fa

Browse files
authored
FIP-0050: Modify restriction tests to use EVM_ACTOR_CODE_ID (#1193)
* FIP-0050: Modify restriction tests to use EVM_ACTOR_CODE_ID * Runtime: Restrict internal API away from EVM actors
1 parent 4f5449d commit 6c151fa

15 files changed

+39
-33
lines changed

actors/account/tests/account_actor_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn token_receiver() {
7272
)
7373
.unwrap();
7474

75-
rt.set_caller(make_identity_cid(b"1234"), Address::new_id(1000));
75+
rt.set_caller(*EVM_ACTOR_CODE_ID, Address::new_id(1000));
7676
rt.expect_validate_caller_any();
7777
let ret = rt
7878
.call::<AccountActor>(

actors/market/tests/harness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub fn construct_and_verify(rt: &mut MockRuntime) {
124124
}
125125

126126
pub fn get_balance(rt: &mut MockRuntime, addr: &Address) -> GetBalanceReturn {
127-
rt.set_caller(make_identity_cid(b"1234"), Address::new_id(1234));
127+
rt.set_caller(*EVM_ACTOR_CODE_ID, Address::new_id(1234));
128128
rt.expect_validate_caller_any();
129129
let ret: GetBalanceReturn = rt
130130
.call::<MarketActor>(

actors/market/tests/market_actor_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,7 +2167,7 @@ fn add_balance_restricted_correctly() {
21672167
rt.set_value(amount);
21682168

21692169
// set caller to not-builtin
2170-
rt.set_caller(make_identity_cid(b"1234"), Address::new_id(1234));
2170+
rt.set_caller(*EVM_ACTOR_CODE_ID, Address::new_id(1234));
21712171

21722172
// cannot call the unexported method num
21732173
expect_abort_contains_message(
@@ -2233,7 +2233,7 @@ fn psd_restricted_correctly() {
22332233
};
22342234

22352235
// set caller to not-builtin
2236-
rt.set_caller(make_identity_cid(b"1234"), WORKER_ADDR);
2236+
rt.set_caller(*EVM_ACTOR_CODE_ID, WORKER_ADDR);
22372237

22382238
// cannot call the unexported method num
22392239
expect_abort_contains_message(

actors/miner/tests/change_beneficiary_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use fil_actor_miner::{Actor, BeneficiaryTerm, GetBeneficiaryReturn, Method};
22
use fil_actors_runtime::test_utils::{
3-
expect_abort, expect_abort_contains_message, make_identity_cid, MockRuntime,
3+
expect_abort, expect_abort_contains_message, MockRuntime, EVM_ACTOR_CODE_ID,
44
};
55
use fvm_shared::clock::ChainEpoch;
66
use fvm_shared::{address::Address, econ::TokenAmount, error::ExitCode, MethodNum};
@@ -449,7 +449,7 @@ fn get_beneficiary_correctly_restricted() {
449449
let (h, mut rt) = setup();
450450

451451
// set caller to not-builtin
452-
rt.set_caller(make_identity_cid(b"1234"), Address::new_id(1000));
452+
rt.set_caller(*EVM_ACTOR_CODE_ID, Address::new_id(1000));
453453

454454
// cannot call the unexported method num
455455
expect_abort_contains_message(

actors/miner/tests/change_owner_address_test.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use fil_actor_miner::{Actor, GetOwnerReturn, Method};
22
use fil_actors_runtime::test_utils::{
3-
expect_abort, expect_abort_contains_message, make_identity_cid, new_bls_addr, MockRuntime,
4-
ACCOUNT_ACTOR_CODE_ID, MULTISIG_ACTOR_CODE_ID,
3+
expect_abort, expect_abort_contains_message, new_bls_addr, MockRuntime, ACCOUNT_ACTOR_CODE_ID,
4+
EVM_ACTOR_CODE_ID, MULTISIG_ACTOR_CODE_ID,
55
};
66
use fvm_ipld_encoding::ipld_block::IpldBlock;
77
use fvm_shared::econ::TokenAmount;
@@ -42,7 +42,7 @@ fn successful_change() {
4242
h.change_owner_address(&mut rt, NEW_ADDRESS).unwrap();
4343

4444
// Set to non-builtin caller to confirm exported correctly
45-
rt.set_caller(make_identity_cid(b"1234"), OTHER_ADDRESS);
45+
rt.set_caller(*EVM_ACTOR_CODE_ID, OTHER_ADDRESS);
4646
rt.expect_validate_caller_any();
4747
let ret: GetOwnerReturn = rt
4848
.call::<Actor>(Method::GetOwnerExported as u64, None)
@@ -70,7 +70,7 @@ fn change_owner_address_restricted_correctly() {
7070
let (h, mut rt) = setup();
7171

7272
let params = IpldBlock::serialize_cbor(&NEW_ADDRESS).unwrap();
73-
rt.set_caller(make_identity_cid(b"1234"), h.owner);
73+
rt.set_caller(*EVM_ACTOR_CODE_ID, h.owner);
7474

7575
// fail to call the unexported method
7676

@@ -94,7 +94,7 @@ fn change_owner_address_restricted_correctly() {
9494
// new owner can also call the exported method
9595

9696
rt.expect_validate_caller_addr(vec![NEW_ADDRESS]);
97-
rt.set_caller(make_identity_cid(b"1234"), NEW_ADDRESS);
97+
rt.set_caller(*EVM_ACTOR_CODE_ID, NEW_ADDRESS);
9898
rt.call::<Actor>(Method::ChangeOwnerAddressExported as u64, params).unwrap();
9999

100100
rt.verify();

actors/miner/tests/change_peer_id_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use fil_actor_miner::{Actor, ChangePeerIDParams, GetPeerIDReturn, Method};
22
use fil_actors_runtime::test_utils::{
3-
expect_abort_contains_message, make_identity_cid, MockRuntime,
3+
expect_abort_contains_message, MockRuntime, EVM_ACTOR_CODE_ID,
44
};
55
use fvm_ipld_encoding::ipld_block::IpldBlock;
66
use fvm_shared::error::ExitCode;
@@ -39,7 +39,7 @@ fn change_peer_id_restricted_correctly() {
3939

4040
let params = IpldBlock::serialize_cbor(&ChangePeerIDParams { new_id: new_id.clone() }).unwrap();
4141

42-
rt.set_caller(make_identity_cid(b"1234"), h.worker);
42+
rt.set_caller(*EVM_ACTOR_CODE_ID, h.worker);
4343

4444
// fail to call the unexported setter
4545

actors/miner/tests/change_worker_address_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use fvm_shared::{address::Address, econ::TokenAmount, error::ExitCode};
1111

1212
mod util;
1313

14-
use fil_actors_runtime::test_utils::make_identity_cid;
14+
use fil_actors_runtime::test_utils::EVM_ACTOR_CODE_ID;
1515
use fvm_ipld_encoding::ipld_block::IpldBlock;
1616

1717
use itertools::Itertools;
@@ -91,7 +91,7 @@ fn change_and_confirm_worker_address_restricted_correctly() {
9191
})
9292
.unwrap();
9393

94-
rt.set_caller(make_identity_cid(b"1234"), h.owner);
94+
rt.set_caller(*EVM_ACTOR_CODE_ID, h.owner);
9595

9696
// fail to call the unexported method
9797

actors/miner/tests/exported_getters.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use fil_actor_miner::{
22
Actor, GetAvailableBalanceReturn, GetOwnerReturn, GetSectorSizeReturn,
33
IsControllingAddressParam, IsControllingAddressReturn, Method,
44
};
5-
use fil_actors_runtime::test_utils::make_identity_cid;
5+
use fil_actors_runtime::test_utils::EVM_ACTOR_CODE_ID;
66
use fil_actors_runtime::INIT_ACTOR_ADDR;
77
use fvm_ipld_encoding::ipld_block::IpldBlock;
88
use fvm_shared::address::Address;
@@ -27,7 +27,7 @@ fn info_getters() {
2727
h.construct_and_verify(&mut rt);
2828

2929
// set caller to not-builtin
30-
rt.set_caller(make_identity_cid(b"1234"), Address::new_id(1234));
30+
rt.set_caller(*EVM_ACTOR_CODE_ID, Address::new_id(1234));
3131

3232
// owner is good
3333
rt.expect_validate_caller_any();

actors/miner/tests/miner_actor_test_peer_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ fn get_and_change_multiaddrs_restricted_correctly() {
127127
})
128128
.unwrap();
129129

130-
rt.set_caller(make_identity_cid(b"1234"), h.worker);
130+
rt.set_caller(*EVM_ACTOR_CODE_ID, h.worker);
131131

132132
// fail to call the unexported setter
133133

actors/miner/tests/repay_debts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use fil_actor_miner::{locked_reward_from_reward, Actor, Method};
2-
use fil_actors_runtime::test_utils::{expect_abort_contains_message, make_identity_cid};
2+
use fil_actors_runtime::test_utils::{expect_abort_contains_message, EVM_ACTOR_CODE_ID};
33
use fil_actors_runtime::BURNT_FUNDS_ACTOR_ADDR;
44
use fvm_shared::bigint::Zero;
55
use fvm_shared::clock::ChainEpoch;
@@ -65,7 +65,7 @@ fn repay_debt_restricted_correctly() {
6565
st.fee_debt = fee_debt.clone();
6666
rt.replace_state(&st);
6767

68-
rt.set_caller(make_identity_cid(b"1234"), h.owner);
68+
rt.set_caller(*EVM_ACTOR_CODE_ID, h.owner);
6969

7070
// fail to call the unexported method
7171
expect_abort_contains_message(

0 commit comments

Comments
 (0)