Skip to content

Commit 89bf664

Browse files
committed
fix more clippy warning from toolchain upgrade
1 parent ad4248a commit 89bf664

File tree

11 files changed

+58
-65
lines changed

11 files changed

+58
-65
lines changed

actors/account/tests/account_actor_test.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,8 @@ fn token_receiver() {
6868
rt.expect_validate_caller_addr(vec![SYSTEM_ACTOR_ADDR]);
6969

7070
let param = Address::new_secp256k1(&[2; fvm_shared::address::SECP_PUB_LEN]).unwrap();
71-
rt.call::<AccountActor>(
72-
Method::Constructor as MethodNum,
73-
&RawBytes::serialize(&param).unwrap(),
74-
)
75-
.unwrap();
71+
rt.call::<AccountActor>(Method::Constructor as MethodNum, &RawBytes::serialize(param).unwrap())
72+
.unwrap();
7673

7774
rt.expect_validate_caller_any();
7875
let ret = rt.call::<AccountActor>(

actors/cron/tests/cron_actor_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn epoch_tick_with_entries() {
115115

116116
fn construct_and_verify(rt: &mut MockRuntime, params: &ConstructorParams) {
117117
rt.expect_validate_caller_addr(vec![SYSTEM_ACTOR_ADDR]);
118-
let ret = rt.call::<CronActor>(1, &RawBytes::serialize(&params).unwrap()).unwrap();
118+
let ret = rt.call::<CronActor>(1, &RawBytes::serialize(params).unwrap()).unwrap();
119119
assert_eq!(RawBytes::default(), ret);
120120
rt.verify();
121121
}

actors/datacap/tests/datacap_actor_test.rs

+24-24
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ mod mint {
4747
let (mut rt, h) = make_harness();
4848

4949
let amt = TokenAmount::from_whole(1);
50-
let ret = h.mint(&mut rt, &*ALICE, &amt, vec![]).unwrap();
50+
let ret = h.mint(&mut rt, &ALICE, &amt, vec![]).unwrap();
5151
assert_eq!(amt, ret.supply);
5252
assert_eq!(amt, ret.balance);
5353
assert_eq!(amt, h.get_supply(&rt));
54-
assert_eq!(amt, h.get_balance(&rt, &*ALICE));
54+
assert_eq!(amt, h.get_balance(&rt, &ALICE));
5555

56-
let ret = h.mint(&mut rt, &*BOB, &amt, vec![]).unwrap();
56+
let ret = h.mint(&mut rt, &BOB, &amt, vec![]).unwrap();
5757
assert_eq!(&amt * 2, ret.supply);
5858
assert_eq!(amt, ret.balance);
5959
assert_eq!(&amt * 2, h.get_supply(&rt));
60-
assert_eq!(amt, h.get_balance(&rt, &*BOB));
60+
assert_eq!(amt, h.get_balance(&rt, &BOB));
6161

6262
h.check_state(&rt);
6363
}
@@ -85,7 +85,7 @@ mod mint {
8585
expect_abort_contains_message(
8686
ExitCode::USR_ILLEGAL_ARGUMENT,
8787
"must be a multiple of 1000000000000000000",
88-
h.mint(&mut rt, &*ALICE, &amt, vec![]),
88+
h.mint(&mut rt, &ALICE, &amt, vec![]),
8989
);
9090
h.check_state(&rt);
9191
}
@@ -94,25 +94,25 @@ mod mint {
9494
fn auto_allowance_on_mint() {
9595
let (mut rt, h) = make_harness();
9696
let amt = TokenAmount::from_whole(42);
97-
h.mint(&mut rt, &*ALICE, &amt, vec![*BOB]).unwrap();
98-
let allowance = h.get_allowance_between(&rt, &*ALICE, &*BOB);
97+
h.mint(&mut rt, &ALICE, &amt, vec![*BOB]).unwrap();
98+
let allowance = h.get_allowance_between(&rt, &ALICE, &BOB);
9999
assert!(allowance.eq(&INFINITE_ALLOWANCE));
100100

101101
// mint again
102-
h.mint(&mut rt, &*ALICE, &amt, vec![*BOB]).unwrap();
103-
let allowance2 = h.get_allowance_between(&rt, &*ALICE, &*BOB);
102+
h.mint(&mut rt, &ALICE, &amt, vec![*BOB]).unwrap();
103+
let allowance2 = h.get_allowance_between(&rt, &ALICE, &BOB);
104104
assert!(allowance2.eq(&INFINITE_ALLOWANCE));
105105

106106
// transfer of an allowance *does* deduct allowance even though it is too small to matter in practice
107107
let operator_data = RawBytes::new(vec![1, 2, 3, 4]);
108-
h.transfer_from(&mut rt, &*BOB, &*ALICE, &h.governor, &(2 * amt.clone()), operator_data)
108+
h.transfer_from(&mut rt, &BOB, &ALICE, &h.governor, &(2 * amt.clone()), operator_data)
109109
.unwrap();
110-
let allowance3 = h.get_allowance_between(&rt, &*ALICE, &*BOB);
110+
let allowance3 = h.get_allowance_between(&rt, &ALICE, &BOB);
111111
assert!(allowance3.eq(&INFINITE_ALLOWANCE.clone().sub(2 * amt.clone())));
112112

113113
// minting any amount to this address at the same operator resets at infinite
114-
h.mint(&mut rt, &*ALICE, &TokenAmount::from_whole(1), vec![*BOB]).unwrap();
115-
let allowance = h.get_allowance_between(&rt, &*ALICE, &*BOB);
114+
h.mint(&mut rt, &ALICE, &TokenAmount::from_whole(1), vec![*BOB]).unwrap();
115+
let allowance = h.get_allowance_between(&rt, &ALICE, &BOB);
116116
assert!(allowance.eq(&INFINITE_ALLOWANCE));
117117

118118
h.check_state(&rt);
@@ -134,20 +134,20 @@ mod transfer {
134134
let operator_data = RawBytes::new(vec![1, 2, 3, 4]);
135135

136136
let amt = TokenAmount::from_whole(1);
137-
h.mint(&mut rt, &*ALICE, &amt, vec![]).unwrap();
137+
h.mint(&mut rt, &ALICE, &amt, vec![]).unwrap();
138138

139139
expect_abort_contains_message(
140140
ExitCode::USR_FORBIDDEN,
141141
"transfer not allowed",
142-
h.transfer(&mut rt, &*ALICE, &*BOB, &amt, operator_data.clone()),
142+
h.transfer(&mut rt, &ALICE, &BOB, &amt, operator_data.clone()),
143143
);
144144
rt.reset();
145145

146146
// Transfer to governor is allowed.
147-
h.transfer(&mut rt, &*ALICE, &h.governor, &amt, operator_data.clone()).unwrap();
147+
h.transfer(&mut rt, &ALICE, &h.governor, &amt, operator_data.clone()).unwrap();
148148

149149
// The governor can transfer out.
150-
h.transfer(&mut rt, &h.governor, &*BOB, &amt, operator_data).unwrap();
150+
h.transfer(&mut rt, &h.governor, &BOB, &amt, operator_data).unwrap();
151151
}
152152

153153
#[test]
@@ -156,21 +156,21 @@ mod transfer {
156156
let operator_data = RawBytes::new(vec![1, 2, 3, 4]);
157157

158158
let amt = TokenAmount::from_whole(1);
159-
h.mint(&mut rt, &*ALICE, &amt, vec![*BOB]).unwrap();
159+
h.mint(&mut rt, &ALICE, &amt, vec![*BOB]).unwrap();
160160

161161
// operator can't transfer out to third address
162162
expect_abort_contains_message(
163163
ExitCode::USR_FORBIDDEN,
164164
"transfer not allowed",
165-
h.transfer_from(&mut rt, &*BOB, &*ALICE, &*CARLA, &amt, operator_data.clone()),
165+
h.transfer_from(&mut rt, &BOB, &ALICE, &CARLA, &amt, operator_data.clone()),
166166
);
167167
rt.reset();
168168

169169
// operator can't transfer out to self
170170
expect_abort_contains_message(
171171
ExitCode::USR_FORBIDDEN,
172172
"transfer not allowed",
173-
h.transfer_from(&mut rt, &*BOB, &*ALICE, &*BOB, &amt, operator_data.clone()),
173+
h.transfer_from(&mut rt, &BOB, &ALICE, &BOB, &amt, operator_data.clone()),
174174
);
175175
rt.reset();
176176
// even if governor has a delegate operator and enough tokens, delegated transfer
@@ -179,7 +179,7 @@ mod transfer {
179179
expect_abort_contains_message(
180180
ExitCode::USR_FORBIDDEN,
181181
"transfer not allowed",
182-
h.transfer_from(&mut rt, &*BOB, &h.governor, &*ALICE, &amt, operator_data),
182+
h.transfer_from(&mut rt, &BOB, &h.governor, &ALICE, &amt, operator_data),
183183
);
184184
rt.reset();
185185
}
@@ -202,7 +202,7 @@ mod destroy {
202202
let (mut rt, h) = make_harness();
203203

204204
let amt = TokenAmount::from_whole(1);
205-
h.mint(&mut rt, &*ALICE, &(2 * amt.clone()), vec![*BOB]).unwrap();
205+
h.mint(&mut rt, &ALICE, &(2 * amt.clone()), vec![*BOB]).unwrap();
206206

207207
// destroying from operator does not work
208208
let params = DestroyParams { owner: *ALICE, amount: amt.clone() };
@@ -216,8 +216,8 @@ mod destroy {
216216
);
217217

218218
// Destroying from 0 allowance having governor works
219-
assert!(h.get_allowance_between(&rt, &*ALICE, &h.governor).is_zero());
220-
let ret = h.destroy(&mut rt, &*ALICE, &amt).unwrap();
219+
assert!(h.get_allowance_between(&rt, &ALICE, &h.governor).is_zero());
220+
let ret = h.destroy(&mut rt, &ALICE, &amt).unwrap();
221221
assert_eq!(ret.balance, amt); // burned 2 amt - amt = amt
222222
h.check_state(&rt)
223223
}

actors/evm/src/interpreter/instructions/ext.rs

+20-24
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,12 @@ pub fn extcodecopy(
6060
) -> Result<(), StatusCode> {
6161
let bytecode = match get_cid_type(system.rt, addr) {
6262
CodeCid::EVM(addr) => get_evm_bytecode(system.rt, &addr)?,
63-
CodeCid::NotFound |
64-
CodeCid::Account => Vec::new(),
63+
CodeCid::NotFound | CodeCid::Account => Vec::new(),
6564
// calling EXTCODECOPY on native actors results with a single byte 0xFE which solidtiy uses for its `assert`/`throw` methods
6665
// and in general invalid EVM bytecode
67-
_ => vec![0xFE]
66+
_ => vec![0xFE],
6867
};
69-
68+
7069
copy_to_memory(&mut state.memory, dest_offset, size, data_offset, bytecode.as_slice(), true)
7170
}
7271

@@ -95,30 +94,27 @@ pub fn get_cid_type(rt: &impl Runtime, addr: U256) -> CodeCid {
9594

9695
if let Ok(addr) = addr.try_into() {
9796
rt.resolve_address(&addr)
98-
.and_then(|id| {
99-
rt.get_actor_code_cid(&id).map(|cid| {
100-
let code_cid = rt
101-
.resolve_builtin_actor_type(&cid)
102-
.map(|t| {
103-
match t {
104-
Type::Account => CodeCid::Account,
105-
// TODO part of current account abstraction hack where emryos are accounts
106-
Type::Embryo => CodeCid::Account,
107-
Type::EVM => CodeCid::EVM(addr),
108-
// remaining builtin actors are native
109-
_ => CodeCid::Native(cid),
110-
}
111-
// not a builtin actor, so it is probably a native actor
112-
})
113-
.unwrap_or(CodeCid::Native(cid));
114-
code_cid
97+
.and_then(|id| {
98+
rt.get_actor_code_cid(&id).map(|cid| {
99+
rt.resolve_builtin_actor_type(&cid)
100+
.map(|t| {
101+
match t {
102+
Type::Account => CodeCid::Account,
103+
// TODO part of current account abstraction hack where emryos are accounts
104+
Type::Embryo => CodeCid::Account,
105+
Type::EVM => CodeCid::EVM(addr),
106+
// remaining builtin actors are native
107+
_ => CodeCid::Native(cid),
108+
}
109+
// not a builtin actor, so it is probably a native actor
110+
})
111+
.unwrap_or(CodeCid::Native(cid))
112+
})
115113
})
116-
})
117-
.unwrap_or(CodeCid::NotFound)
114+
.unwrap_or(CodeCid::NotFound)
118115
} else {
119116
CodeCid::NotFound
120117
}
121-
122118
}
123119

124120
pub fn get_evm_bytecode(rt: &impl Runtime, addr: &Address) -> Result<Vec<u8>, StatusCode> {

actors/evm/tests/ext_opcodes.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ native_account:
9898
evm::Method::GetBytecode as u64,
9999
Default::default(),
100100
TokenAmount::zero(),
101-
RawBytes::serialize(&bytecode_cid).unwrap(),
101+
RawBytes::serialize(bytecode_cid).unwrap(),
102102
ExitCode::OK,
103103
);
104104

@@ -187,7 +187,7 @@ native_actor:
187187
evm::Method::GetBytecode as u64,
188188
Default::default(),
189189
TokenAmount::zero(),
190-
RawBytes::serialize(&bytecode_cid).unwrap(),
190+
RawBytes::serialize(bytecode_cid).unwrap(),
191191
ExitCode::OK,
192192
);
193193

@@ -278,7 +278,7 @@ invalid_address:
278278
evm::Method::GetBytecode as u64,
279279
Default::default(),
280280
TokenAmount::zero(),
281-
RawBytes::serialize(&bytecode_cid).unwrap(),
281+
RawBytes::serialize(bytecode_cid).unwrap(),
282282
ExitCode::OK,
283283
);
284284

actors/market/tests/market_actor_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ fn fail_when_balance_is_zero() {
517517
ExitCode::USR_ILLEGAL_ARGUMENT,
518518
rt.call::<MarketActor>(
519519
Method::AddBalance as u64,
520-
&RawBytes::serialize(&PROVIDER_ADDR).unwrap(),
520+
&RawBytes::serialize(PROVIDER_ADDR).unwrap(),
521521
),
522522
);
523523

actors/miner/tests/aggregate_network_fee_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn fee_increases_if_basefee_crosses_threshold() {
2424
let at_no_base_fee = fee_func(10, &zero());
2525
let at_balance_minus_one_base_fee =
2626
fee_func(10, &(&*BATCH_BALANCER - TokenAmount::from_atto(1)));
27-
let at_balance_base_fee = fee_func(10, &*BATCH_BALANCER);
27+
let at_balance_base_fee = fee_func(10, &BATCH_BALANCER);
2828
let at_balance_plus_one_base_fee =
2929
fee_func(10, &(&*BATCH_BALANCER + TokenAmount::from_nano(1)));
3030
let at_balance_plus_two_base_fee =

actors/miner/tests/repay_debts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ fn pay_debt_partially_from_vested_funds() {
8888
// send 1 FIL and repay all debt from vesting funds and balance
8989
h.repay_debts(
9090
&mut rt,
91-
&*BIG_BALANCE, // send 1 FIL
91+
&BIG_BALANCE, // send 1 FIL
9292
&amount_locked, // 3 FIL comes from vesting funds
93-
&*BIG_BALANCE, // 1 FIL sent from balance
93+
&BIG_BALANCE, // 1 FIL sent from balance
9494
)
9595
.unwrap();
9696

actors/miner/tests/withdraw_balance.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ fn fails_if_miner_cant_repay_fee_debt() {
4545
h.withdraw_funds(
4646
&mut rt,
4747
h.owner,
48-
&*ONE_PERCENT_BALANCE,
49-
&*ONE_PERCENT_BALANCE,
48+
&ONE_PERCENT_BALANCE,
49+
&ONE_PERCENT_BALANCE,
5050
&TokenAmount::zero(),
5151
),
5252
);

actors/power/tests/power_actor_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ fn given_no_miner_claim_update_pledge_total_should_abort() {
596596
h.create_miner_basic(&mut rt, *OWNER, *OWNER, *MINER).unwrap();
597597

598598
// explicitly delete miner claim
599-
h.delete_claim(&mut rt, &*MINER);
599+
h.delete_claim(&mut rt, &MINER);
600600

601601
rt.set_caller(*MINER_ACTOR_CODE_ID, *MINER);
602602
rt.expect_validate_caller_type(vec![Type::Miner]);

actors/verifreg/tests/harness/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl Harness {
102102
rt.expect_send(
103103
DATACAP_TOKEN_ACTOR_ADDR,
104104
ext::datacap::Method::BalanceOf as MethodNum,
105-
RawBytes::serialize(&verifier_resolved).unwrap(),
105+
RawBytes::serialize(verifier_resolved).unwrap(),
106106
TokenAmount::zero(),
107107
serialize(&BigIntSer(&(cap * TOKEN_PRECISION)), "").unwrap(),
108108
ExitCode::OK,

0 commit comments

Comments
 (0)