Skip to content

Commit 75b4884

Browse files
Seulgi Kimmergify[bot]
authored andcommitted
Allow struct/array to overflow
1 parent 4b7569d commit 75b4884

File tree

14 files changed

+122
-188
lines changed

14 files changed

+122
-188
lines changed

core/src/client/importer.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,11 @@ impl Importer {
237237
cdebug!(CLIENT, "Epoch transition at block {}", header.hash());
238238

239239
let mut batch = DBTransaction::new();
240-
chain.insert_epoch_transition(
241-
&mut batch,
242-
header.number(),
243-
EpochTransition {
244-
block_hash: header.hash(),
245-
block_number: header.number(),
246-
proof,
247-
},
248-
);
240+
chain.insert_epoch_transition(&mut batch, header.number(), EpochTransition {
241+
block_hash: header.hash(),
242+
block_number: header.number(),
243+
proof,
244+
});
249245

250246
// always write the batch directly since epoch transition proofs are
251247
// fetched from a DB iterator and DB iterators are only available on

core/src/consensus/tendermint/worker.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -918,16 +918,13 @@ impl Worker {
918918
}
919919

920920
fn backup(&self) {
921-
backup(
922-
self.client().get_kvdb().as_ref(),
923-
BackupView {
924-
height: &self.height,
925-
view: &self.view,
926-
step: &self.step.to_step(),
927-
votes: &self.votes.get_all(),
928-
last_confirmed_view: &self.last_confirmed_view,
929-
},
930-
);
921+
backup(self.client().get_kvdb().as_ref(), BackupView {
922+
height: &self.height,
923+
view: &self.view,
924+
step: &self.step.to_step(),
925+
votes: &self.votes.get_all(),
926+
last_confirmed_view: &self.last_confirmed_view,
927+
});
931928
}
932929

933930
fn restore(&mut self) {

core/src/miner/mem_pool.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,14 +1447,10 @@ pub mod test {
14471447
let mut inputs: Vec<MemPoolInput> = Vec::new();
14481448

14491449
inputs.push(create_mempool_input_with_pay(1u64, keypair, no_timelock));
1450-
inputs.push(create_mempool_input_with_pay(
1451-
3u64,
1452-
keypair,
1453-
TxTimelock {
1454-
block: Some(10),
1455-
timestamp: None,
1456-
},
1457-
));
1450+
inputs.push(create_mempool_input_with_pay(3u64, keypair, TxTimelock {
1451+
block: Some(10),
1452+
timestamp: None,
1453+
}));
14581454
inputs.push(create_mempool_input_with_pay(5u64, keypair, no_timelock));
14591455
mem_pool.add(inputs, inserted_block_number, inserted_timestamp, &fetch_account);
14601456

core/src/miner/work_notify.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,15 @@ impl NotifyWork for WorkPoster {
6969
let body = format!(r#"{{ "result": ["0x{:x}","0x{:x}"] }}"#, pow_hash, target);
7070
let mut client = self.client.lock();
7171
for u in &self.urls {
72-
if let Err(e) = client.request(
73-
u.clone(),
74-
PostHandler {
75-
body: body.clone(),
76-
},
77-
) {
72+
if let Err(e) = client.request(u.clone(), PostHandler {
73+
body: body.clone(),
74+
}) {
7875
cwarn!(MINER, "Error sending HTTP notification to {} : {}, retrying", u, e);
7976
// TODO: remove this once https://github.com/hyperium/hyper/issues/848 is fixed
8077
*client = WorkPoster::create_client();
81-
if let Err(e) = client.request(
82-
u.clone(),
83-
PostHandler {
84-
body: body.clone(),
85-
},
86-
) {
78+
if let Err(e) = client.request(u.clone(), PostHandler {
79+
body: body.clone(),
80+
}) {
8781
cwarn!(MINER, "Error sending HTTP notification to {} : {}", u, e);
8882
}
8983
}

json/src/hash.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,10 @@ mod test {
109109
fn hash_deserialization() {
110110
let s = r#"["", "5a39ed1020c04d4d84539975b893a4e7c53eab6c2965db8bc3468093a31bc5ae"]"#;
111111
let deserialized: Vec<H256> = serde_json::from_str(s).unwrap();
112-
assert_eq!(
113-
deserialized,
114-
vec![
115-
H256(primitives::H256::from(0)),
116-
H256(primitives::H256::from("5a39ed1020c04d4d84539975b893a4e7c53eab6c2965db8bc3468093a31bc5ae")),
117-
]
118-
);
112+
assert_eq!(deserialized, vec![
113+
H256(primitives::H256::from(0)),
114+
H256(primitives::H256::from("5a39ed1020c04d4d84539975b893a4e7c53eab6c2965db8bc3468093a31bc5ae")),
115+
]);
119116
}
120117

121118
#[test]

json/src/uint.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,14 @@ mod test {
151151
fn uint_deserialization() {
152152
let s = r#"["0xa", "10", "", "0x", 0, "0xffffffffffffffff"]"#;
153153
let deserialized: Vec<Uint> = serde_json::from_str(s).unwrap();
154-
assert_eq!(
155-
deserialized,
156-
vec![
157-
Uint(U256::from(10)),
158-
Uint(U256::from(10)),
159-
Uint(U256::from(0)),
160-
Uint(U256::from(0)),
161-
Uint(U256::from(0)),
162-
::std::u64::MAX.into(),
163-
]
164-
);
154+
assert_eq!(deserialized, vec![
155+
Uint(U256::from(10)),
156+
Uint(U256::from(10)),
157+
Uint(U256::from(0)),
158+
Uint(U256::from(0)),
159+
Uint(U256::from(0)),
160+
::std::u64::MAX.into(),
161+
]);
165162
}
166163

167164
#[test]

keystore/tests/api.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ fn ciphertext_path() -> &'static str {
109109
fn secret_store_load_pat_files() {
110110
let dir = RootDiskDirectory::at(pat_path());
111111
let store = KeyStore::open(Box::new(dir)).unwrap();
112-
assert_eq!(
113-
store.accounts().unwrap(),
114-
vec!["0x3fc74504d2b491d73079975e302279540bf6e44e".into(), "0x41178717678e402bdb663d98fe47669d93b29603".into()]
115-
);
112+
assert_eq!(store.accounts().unwrap(), vec![
113+
"0x3fc74504d2b491d73079975e302279540bf6e44e".into(),
114+
"0x41178717678e402bdb663d98fe47669d93b29603".into()
115+
]);
116116
}
117117

118118
#[test]
@@ -128,10 +128,10 @@ fn decrypting_files_with_short_ciphertext() {
128128
let dir = RootDiskDirectory::at(ciphertext_path());
129129
let store = KeyStore::open(Box::new(dir)).unwrap();
130130
let accounts = store.accounts().unwrap();
131-
assert_eq!(
132-
accounts,
133-
vec!["0x77a477c745390977a72f44437ac1dac19b705571".into(), "0x8267cb8df20e1dc57fef31322e16bddd83d4cc3d".into()]
134-
);
131+
assert_eq!(accounts, vec![
132+
"0x77a477c745390977a72f44437ac1dac19b705571".into(),
133+
"0x8267cb8df20e1dc57fef31322e16bddd83d4cc3d".into()
134+
]);
135135

136136
let message = Default::default();
137137

rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use_try_shorthand = true # false
4949
# format_doc_comments = false
5050
wrap_comments = false
5151
match_arm_blocks = true
52-
overflow_delimited_expr = false
52+
overflow_delimited_expr = true
5353
blank_lines_upper_bound = 2 # 1
5454
blank_lines_lower_bound = 0
5555
# required_version

state/src/impls/top_level.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,10 +2470,9 @@ mod tests_tx {
24702470
let asset_type = H160::zero();
24712471
let transfer = transfer_asset!(
24722472
inputs:
2473-
asset_transfer_inputs![(
2474-
asset_out_point!(H256::random(), 0, asset_type, shard_id, 30),
2475-
vec![0x30, 0x01]
2476-
)],
2473+
asset_transfer_inputs![(asset_out_point!(H256::random(), 0, asset_type, shard_id, 30), vec![
2474+
0x30, 0x01
2475+
])],
24772476
asset_transfer_outputs![
24782477
(H160::random(), vec![vec![1]], asset_type, shard_id, 10),
24792478
(H160::random(), vec![], asset_type, shard_id, 5),

types/src/transaction/shard.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -920,16 +920,13 @@ mod tests {
920920
fn fail_if_output_has_more_asset() {
921921
let asset_type = H160::random();
922922
let output_quantity = 100;
923-
assert!(!is_input_and_output_consistent(
924-
&[],
925-
&[AssetTransferOutput {
926-
lock_script_hash: H160::random(),
927-
parameters: vec![],
928-
asset_type,
929-
shard_id: 0,
930-
quantity: output_quantity,
931-
}]
932-
));
923+
assert!(!is_input_and_output_consistent(&[], &[AssetTransferOutput {
924+
lock_script_hash: H160::random(),
925+
parameters: vec![],
926+
asset_type,
927+
shard_id: 0,
928+
quantity: output_quantity,
929+
}]));
933930
}
934931

935932
#[test]

0 commit comments

Comments
 (0)