Skip to content

Commit 0ccffa8

Browse files
authored
Merge pull request #4529 from va-an/chore/replace-u32-max_value
refactor: replace `u32::max_value()` with `u32::MAX`
2 parents 33c05d1 + b3a5071 commit 0ccffa8

File tree

10 files changed

+81
-81
lines changed

10 files changed

+81
-81
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ is responsible for:
5959
6. Merging the new PR.
6060

6161
For an example of this process, see PRs
62-
[#3598](https://github.com/stacks-network/stacks-blockchain/pull/3598) and
63-
[#3626](https://github.com/stacks-network/stacks-blockchain/pull/3626).
62+
[#3598](https://github.com/stacks-network/stacks-core/pull/3598) and
63+
[#3626](https://github.com/stacks-network/stacks-core/pull/3626).
6464

6565

6666
### Documentation Updates
@@ -226,7 +226,7 @@ Contributions should not contain `unsafe` blocks if at all possible.
226226
## Documentation
227227

228228
* Each file must have a **copyright statement**.
229-
* Any new non-test modules should have **module-level documentation** explaining what the module does, and how it fits into the blockchain as a whole ([example](https://github.com/stacks-network/stacks-blockchain/blob/4852d6439b473e24705f14b8af637aded33cb422/testnet/stacks-node/src/neon_node.rs#L17)).
229+
* Any new non-test modules should have **module-level documentation** explaining what the module does, and how it fits into the blockchain as a whole ([example](https://github.com/stacks-network/stacks-core/blob/4852d6439b473e24705f14b8af637aded33cb422/testnet/stacks-node/src/neon_node.rs#L17)).
230230
* Any new files must have some **top-of-file documentation** that describes what the contained code does, and how it fits into the overall module.
231231

232232
Within the source files, the following **code documentation** standards are expected:
@@ -247,7 +247,7 @@ Within the source files, the following **code documentation** standards are expe
247247
handle I/O reads and writes in an "outer" function. The "outer"
248248
function only does the needful I/O and passes the data into the
249249
"inner" function. The "inner" function is often private, whereas
250-
the "outer" function is often public. For example, [`inner_try_mine_microblock` and `try_mine_microblock`](https://github.com/stacks-network/stacks-blockchain/blob/4852d6439b473e24705f14b8af637aded33cb422/testnet/stacks-node/src/neon_node.rs#L1148-L1216).
250+
the "outer" function is often public. For example, [`inner_try_mine_microblock` and `try_mine_microblock`](https://github.com/stacks-network/stacks-core/blob/4852d6439b473e24705f14b8af637aded33cb422/testnet/stacks-node/src/neon_node.rs#L1148-L1216).
251251

252252
## Refactoring
253253

@@ -281,7 +281,7 @@ Within the source files, the following **code documentation** standards are expe
281281
does not decode with the allotted resources, then no further
282282
processing may be done and the data is discarded. For an example, see
283283
how the parsing functions in the http module use `BoundReader` and
284-
`MAX_PAYLOAD_LEN` in [http.rs](https://github.com/stacks-network/stacks-blockchain/blob/4852d6439b473e24705f14b8af637aded33cb422/src/net/http.rs#L2260-L2285).
284+
`MAX_PAYLOAD_LEN` in [http.rs](https://github.com/stacks-network/stacks-core/blob/4852d6439b473e24705f14b8af637aded33cb422/src/net/http.rs#L2260-L2285).
285285

286286
* **All network input reception is time-bound.** Every piece of code that ingests data _from the network_ must impose a maximum amount of time that ingestion can take. If the data takes too long to arrive, then it must be discarded without any further processing. There is no time bound for data ingested from disk or passed as an argument; this requirement is meant by the space-bound requirement.
287287

@@ -303,7 +303,7 @@ Changes to the peer network should be deployed incrementally and tested by multi
303303

304304
Any PRs that claim to improve performance **must ship with reproducible benchmarks** that accurately measure the improvement. This data must also be reported in the PR submission.
305305

306-
For an example, see [PR #3075](https://github.com/stacks-network/stacks-blockchain/pull/3075).
306+
For an example, see [PR #3075](https://github.com/stacks-network/stacks-core/pull/3075).
307307

308308
## Error Handling
309309

@@ -597,7 +597,7 @@ Keep in mind that better variable names can reduce the need for comments, e.g.:
597597

598598
# Licensing and contributor license agreement
599599

600-
`stacks-blockchain` is released under the terms of the GPL version 3. Contributions
600+
`stacks-core` is released under the terms of the GPL version 3. Contributions
601601
that are not licensed under compatible terms will be rejected. Moreover,
602602
contributions will not be accepted unless _all_ authors accept the project's
603603
contributor license agreement.

stackslib/src/chainstate/coordinator/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4854,7 +4854,7 @@ fn test_epoch_verify_active_pox_contract() {
48544854
let _r = std::fs::remove_dir_all(path);
48554855

48564856
let pox_v1_unlock_ht = 12;
4857-
let pox_v2_unlock_ht = u32::max_value();
4857+
let pox_v2_unlock_ht = u32::MAX;
48584858
let sunset_ht = 8000;
48594859
let pox_consts = Some(PoxConstants::new(
48604860
6,

testnet/stacks-node/src/tests/bitcoin_regtest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ fn bitcoind_integration(segwit_flag: bool) {
141141
conf.burnchain.password = Some("secret".to_string());
142142
conf.burnchain.local_mining_public_key = Some("04ee0b1602eb18fef7986887a7e8769a30c9df981d33c8380d255edef003abdcd243a0eb74afdf6740e6c423e62aec631519a24cf5b1d62bf8a3e06ddc695dcb77".to_string());
143143

144-
conf.miner.first_attempt_time_ms = i64::max_value() as u64;
145-
conf.miner.subsequent_attempt_time_ms = i64::max_value() as u64;
144+
conf.miner.first_attempt_time_ms = i64::MAX as u64;
145+
conf.miner.subsequent_attempt_time_ms = i64::MAX as u64;
146146
conf.miner.segwit = segwit_flag;
147147

148148
conf.initial_balances.push(InitialBalance {

testnet/stacks-node/src/tests/epoch_205.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -982,8 +982,8 @@ fn bigger_microblock_streams_in_2_05() {
982982
conf.node.max_microblocks = 65536;
983983
conf.burnchain.max_rbf = 1000000;
984984

985-
conf.miner.first_attempt_time_ms = i64::max_value() as u64;
986-
conf.miner.subsequent_attempt_time_ms = i64::max_value() as u64;
985+
conf.miner.first_attempt_time_ms = i64::MAX as u64;
986+
conf.miner.subsequent_attempt_time_ms = i64::MAX as u64;
987987

988988
conf.burnchain.epochs = Some(vec![
989989
StacksEpoch {

testnet/stacks-node/src/tests/epoch_21.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ fn advance_to_2_1(
9797
4 * prepare_phase_len / 5,
9898
5,
9999
15,
100-
u64::max_value() - 2,
101-
u64::max_value() - 1,
102-
u32::max_value(),
100+
u64::MAX - 2,
101+
u64::MAX - 1,
102+
u32::MAX,
103103
u32::MAX,
104104
u32::MAX,
105105
));
@@ -600,7 +600,7 @@ fn transition_fixes_bitcoin_rigidity() {
600600
15,
601601
(16 * reward_cycle_len - 1).into(),
602602
(17 * reward_cycle_len).into(),
603-
u32::max_value(),
603+
u32::MAX,
604604
u32::MAX,
605605
u32::MAX,
606606
);
@@ -1042,8 +1042,8 @@ fn transition_adds_get_pox_addr_recipients() {
10421042
4 * prepare_phase_len / 5,
10431043
1,
10441044
1,
1045-
u64::max_value() - 2,
1046-
u64::max_value() - 1,
1045+
u64::MAX - 2,
1046+
u64::MAX - 1,
10471047
v1_unlock_height,
10481048
u32::MAX,
10491049
u32::MAX,
@@ -1806,8 +1806,8 @@ fn transition_empty_blocks() {
18061806
4 * prepare_phase_len / 5,
18071807
5,
18081808
15,
1809-
u64::max_value() - 2,
1810-
u64::max_value() - 1,
1809+
u64::MAX - 2,
1810+
u64::MAX - 1,
18111811
(epoch_2_1 + 1) as u32,
18121812
u32::MAX,
18131813
u32::MAX,
@@ -4752,7 +4752,7 @@ fn trait_invocation_cross_epoch() {
47524752
15,
47534753
(16 * reward_cycle_len - 1).into(),
47544754
(17 * reward_cycle_len).into(),
4755-
u32::max_value(),
4755+
u32::MAX,
47564756
u32::MAX,
47574757
u32::MAX,
47584758
);
@@ -4969,8 +4969,8 @@ fn test_v1_unlock_height_with_current_stackers() {
49694969
conf.node.wait_time_for_blocks = 1_000;
49704970
conf.miner.wait_for_block_download = false;
49714971

4972-
conf.miner.first_attempt_time_ms = i64::max_value() as u64;
4973-
conf.miner.subsequent_attempt_time_ms = i64::max_value() as u64;
4972+
conf.miner.first_attempt_time_ms = i64::MAX as u64;
4973+
conf.miner.subsequent_attempt_time_ms = i64::MAX as u64;
49744974

49754975
test_observer::spawn();
49764976

@@ -4995,8 +4995,8 @@ fn test_v1_unlock_height_with_current_stackers() {
49954995
4 * prepare_phase_len / 5,
49964996
5,
49974997
15,
4998-
u64::max_value() - 2,
4999-
u64::max_value() - 1,
4998+
u64::MAX - 2,
4999+
u64::MAX - 1,
50005000
v1_unlock_height as u32,
50015001
u32::MAX,
50025002
u32::MAX,
@@ -5233,8 +5233,8 @@ fn test_v1_unlock_height_with_delay_and_current_stackers() {
52335233
conf.node.wait_time_for_blocks = 1_000;
52345234
conf.miner.wait_for_block_download = false;
52355235

5236-
conf.miner.first_attempt_time_ms = i64::max_value() as u64;
5237-
conf.miner.subsequent_attempt_time_ms = i64::max_value() as u64;
5236+
conf.miner.first_attempt_time_ms = i64::MAX as u64;
5237+
conf.miner.subsequent_attempt_time_ms = i64::MAX as u64;
52385238

52395239
test_observer::spawn();
52405240

@@ -5259,8 +5259,8 @@ fn test_v1_unlock_height_with_delay_and_current_stackers() {
52595259
4 * prepare_phase_len / 5,
52605260
5,
52615261
15,
5262-
u64::max_value() - 2,
5263-
u64::max_value() - 1,
5262+
u64::MAX - 2,
5263+
u64::MAX - 1,
52645264
v1_unlock_height as u32,
52655265
u32::MAX,
52665266
u32::MAX,

testnet/stacks-node/src/tests/epoch_22.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ fn disable_pox() {
130130
conf.node.wait_time_for_blocks = 1_000;
131131
conf.miner.wait_for_block_download = false;
132132

133-
conf.miner.first_attempt_time_ms = i64::max_value() as u64;
134-
conf.miner.subsequent_attempt_time_ms = i64::max_value() as u64;
133+
conf.miner.first_attempt_time_ms = i64::MAX as u64;
134+
conf.miner.subsequent_attempt_time_ms = i64::MAX as u64;
135135

136136
test_observer::spawn();
137137

@@ -160,8 +160,8 @@ fn disable_pox() {
160160
4 * prepare_phase_len / 5,
161161
5,
162162
15,
163-
u64::max_value() - 2,
164-
u64::max_value() - 1,
163+
u64::MAX - 2,
164+
u64::MAX - 1,
165165
v1_unlock_height as u32,
166166
epoch_2_2 as u32 + 1,
167167
u32::MAX,
@@ -662,8 +662,8 @@ fn pox_2_unlock_all() {
662662
conf.node.wait_time_for_blocks = 1_000;
663663
conf.miner.wait_for_block_download = false;
664664

665-
conf.miner.first_attempt_time_ms = i64::max_value() as u64;
666-
conf.miner.subsequent_attempt_time_ms = i64::max_value() as u64;
665+
conf.miner.first_attempt_time_ms = i64::MAX as u64;
666+
conf.miner.subsequent_attempt_time_ms = i64::MAX as u64;
667667

668668
test_observer::spawn();
669669

@@ -692,8 +692,8 @@ fn pox_2_unlock_all() {
692692
4 * prepare_phase_len / 5,
693693
5,
694694
15,
695-
u64::max_value() - 2,
696-
u64::max_value() - 1,
695+
u64::MAX - 2,
696+
u64::MAX - 1,
697697
v1_unlock_height as u32,
698698
epoch_2_2 as u32 + 1,
699699
u32::MAX,

testnet/stacks-node/src/tests/epoch_23.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ fn trait_invocation_behavior() {
9696
conf.node.wait_time_for_blocks = 1_000;
9797
conf.miner.wait_for_block_download = false;
9898

99-
conf.miner.first_attempt_time_ms = i64::max_value() as u64;
100-
conf.miner.subsequent_attempt_time_ms = i64::max_value() as u64;
99+
conf.miner.first_attempt_time_ms = i64::MAX as u64;
100+
conf.miner.subsequent_attempt_time_ms = i64::MAX as u64;
101101

102102
test_observer::spawn();
103103

@@ -128,8 +128,8 @@ fn trait_invocation_behavior() {
128128
4 * prepare_phase_len / 5,
129129
5,
130130
15,
131-
u64::max_value() - 2,
132-
u64::max_value() - 1,
131+
u64::MAX - 2,
132+
u64::MAX - 1,
133133
v1_unlock_height as u32,
134134
epoch_2_2 as u32 + 1,
135135
u32::MAX,

testnet/stacks-node/src/tests/epoch_24.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ fn fix_to_pox_contract() {
148148
conf.node.wait_time_for_blocks = 1_000;
149149
conf.miner.wait_for_block_download = false;
150150

151-
conf.miner.first_attempt_time_ms = i64::max_value() as u64;
152-
conf.miner.subsequent_attempt_time_ms = i64::max_value() as u64;
151+
conf.miner.first_attempt_time_ms = i64::MAX as u64;
152+
conf.miner.subsequent_attempt_time_ms = i64::MAX as u64;
153153

154154
test_observer::spawn();
155155

@@ -182,8 +182,8 @@ fn fix_to_pox_contract() {
182182
4 * prepare_phase_len / 5,
183183
5,
184184
15,
185-
u64::max_value() - 2,
186-
u64::max_value() - 1,
185+
u64::MAX - 2,
186+
u64::MAX - 1,
187187
v1_unlock_height as u32,
188188
epoch_2_2 as u32 + 1,
189189
pox_3_activation_height as u32,
@@ -786,8 +786,8 @@ fn verify_auto_unlock_behavior() {
786786
conf.node.wait_time_for_blocks = 1_000;
787787
conf.miner.wait_for_block_download = false;
788788

789-
conf.miner.first_attempt_time_ms = i64::max_value() as u64;
790-
conf.miner.subsequent_attempt_time_ms = i64::max_value() as u64;
789+
conf.miner.first_attempt_time_ms = i64::MAX as u64;
790+
conf.miner.subsequent_attempt_time_ms = i64::MAX as u64;
791791

792792
test_observer::spawn();
793793

@@ -820,8 +820,8 @@ fn verify_auto_unlock_behavior() {
820820
4 * prepare_phase_len / 5,
821821
5,
822822
15,
823-
u64::max_value() - 2,
824-
u64::max_value() - 1,
823+
u64::MAX - 2,
824+
u64::MAX - 1,
825825
v1_unlock_height as u32,
826826
epoch_2_2 as u32 + 1,
827827
pox_3_activation_height as u32,

testnet/stacks-node/src/tests/integrations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ fn integration_test_get_info() {
181181
});
182182

183183
conf.burnchain.commit_anchor_block_within = 5000;
184-
conf.miner.first_attempt_time_ms = i64::max_value() as u64;
185-
conf.miner.subsequent_attempt_time_ms = i64::max_value() as u64;
184+
conf.miner.first_attempt_time_ms = i64::MAX as u64;
185+
conf.miner.subsequent_attempt_time_ms = i64::MAX as u64;
186186

187187
let num_rounds = 5;
188188

0 commit comments

Comments
 (0)