Skip to content

Commit 7968b49

Browse files
committed
crc: rename make_stacks_transfer to $1_serialized
1 parent 70cb6e7 commit 7968b49

File tree

9 files changed

+188
-135
lines changed

9 files changed

+188
-135
lines changed

stackslib/src/core/test_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ pub fn make_stacks_transfer_tx(
283283
}
284284

285285
/// Make a stacks transfer transaction, returning the serialized transaction bytes
286-
pub fn make_stacks_transfer(
286+
pub fn make_stacks_transfer_serialized(
287287
sender: &StacksPrivateKey,
288288
nonce: u64,
289289
tx_fee: u64,

stackslib/src/core/tests/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ use crate::core::mempool::{
6565
db_get_all_nonces, MemPoolSyncData, MemPoolWalkSettings, MemPoolWalkTxTypes, TxTag,
6666
BLOOM_COUNTER_DEPTH, BLOOM_COUNTER_ERROR_RATE, MAX_BLOOM_COUNTER_TXS,
6767
};
68-
use crate::core::test_util::{insert_tx_in_mempool, make_stacks_transfer, to_addr};
68+
use crate::core::test_util::{insert_tx_in_mempool, make_stacks_transfer_serialized, to_addr};
6969
use crate::core::{FIRST_BURNCHAIN_CONSENSUS_HASH, FIRST_STACKS_BLOCK_HASH};
7070
use crate::net::Error as NetError;
7171
use crate::util_lib::bloom::test::setup_bloom_counter;
@@ -2795,7 +2795,7 @@ fn large_mempool() {
27952795
let sender_addr = to_addr(sender_sk);
27962796
let fee = thread_rng().gen_range(180..2000);
27972797
let transfer_tx =
2798-
make_stacks_transfer(sender_sk, *nonce, fee, 0x80000000, &recipient, 1);
2798+
make_stacks_transfer_serialized(sender_sk, *nonce, fee, 0x80000000, &recipient, 1);
27992799
insert_tx_in_mempool(
28002800
&mempool_tx,
28012801
transfer_tx,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use stacks::chainstate::stacks::db::StacksChainState;
99
use stacks::chainstate::stacks::miner::{signal_mining_blocked, signal_mining_ready};
1010
use stacks::clarity_cli::vm_execute as execute;
1111
use stacks::config::{EventKeyType, EventObserverConfig, InitialBalance};
12-
use stacks::core::test_util::{make_contract_call, make_stacks_transfer};
12+
use stacks::core::test_util::{make_contract_call, make_stacks_transfer_serialized};
1313
use stacks::core::{self, EpochList, STACKS_EPOCH_MAX};
1414
use stacks::util_lib::boot::boot_code_id;
1515
use stacks_common::types::chainstate::{StacksAddress, StacksBlockId};
@@ -961,7 +961,7 @@ fn pox_2_unlock_all() {
961961
);
962962

963963
// perform a transfer
964-
let tx = make_stacks_transfer(
964+
let tx = make_stacks_transfer_serialized(
965965
&spender_sk,
966966
5,
967967
tx_fee,

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

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use stacks::config::InitialBalance;
2828
use stacks::core::mempool::MAXIMUM_MEMPOOL_TX_CHAINING;
2929
use stacks::core::test_util::{
3030
make_contract_call, make_contract_publish, make_sponsored_stacks_transfer_on_testnet,
31-
make_stacks_transfer, to_addr,
31+
make_stacks_transfer_serialized, to_addr,
3232
};
3333
use stacks::core::{
3434
EpochList, StacksEpoch, StacksEpochId, CHAIN_ID_TESTNET, PEER_VERSION_EPOCH_2_0,
@@ -336,7 +336,7 @@ fn integration_test_get_info() {
336336
}
337337

338338
if round >= 1 {
339-
let tx_xfer = make_stacks_transfer(
339+
let tx_xfer = make_stacks_transfer_serialized(
340340
&spender_sk,
341341
round - 1,
342342
10,
@@ -807,7 +807,7 @@ fn integration_test_get_info() {
807807
eprintln!("Test: POST {path} (valid)");
808808

809809
// tx_xfer is 180 bytes long
810-
let tx_xfer = make_stacks_transfer(
810+
let tx_xfer = make_stacks_transfer_serialized(
811811
&spender_sk,
812812
round,
813813
200,
@@ -845,7 +845,7 @@ fn integration_test_get_info() {
845845

846846
// tx_xfer_invalid is 180 bytes long
847847
// bad nonce
848-
let tx_xfer_invalid = make_stacks_transfer(&spender_sk, round + 30, 200, CHAIN_ID_TESTNET,
848+
let tx_xfer_invalid = make_stacks_transfer_serialized(&spender_sk, round + 30, 200, CHAIN_ID_TESTNET,
849849
&StacksAddress::from_string(ADDR_4).unwrap().into(), 456);
850850

851851
let tx_xfer_invalid_tx = StacksTransaction::consensus_deserialize(&mut &tx_xfer_invalid[..]).unwrap();
@@ -1126,7 +1126,7 @@ fn contract_stx_transfer() {
11261126

11271127
if round == 1 {
11281128
// block-height = 2
1129-
let xfer_to_contract = make_stacks_transfer(
1129+
let xfer_to_contract = make_stacks_transfer_serialized(
11301130
&sk_3,
11311131
0,
11321132
10,
@@ -1221,7 +1221,7 @@ fn contract_stx_transfer() {
12211221
} else if round == 4 {
12221222
// let's testing "chaining": submit MAXIMUM_MEMPOOL_TX_CHAINING - 1 txs, which should succeed
12231223
for i in 0..MAXIMUM_MEMPOOL_TX_CHAINING {
1224-
let xfer_to_contract = make_stacks_transfer(
1224+
let xfer_to_contract = make_stacks_transfer_serialized(
12251225
&sk_3,
12261226
1 + i,
12271227
200,
@@ -1247,7 +1247,7 @@ fn contract_stx_transfer() {
12471247
.unwrap();
12481248
}
12491249
// this one should fail because the nonce is already in the mempool
1250-
let xfer_to_contract = make_stacks_transfer(
1250+
let xfer_to_contract = make_stacks_transfer_serialized(
12511251
&sk_3,
12521252
3,
12531253
190,
@@ -1480,7 +1480,7 @@ fn mine_transactions_out_of_order() {
14801480

14811481
if round == 1 {
14821482
// block-height = 2
1483-
let xfer_to_contract = make_stacks_transfer(
1483+
let xfer_to_contract = make_stacks_transfer_serialized(
14841484
&sk,
14851485
1,
14861486
10,
@@ -1517,7 +1517,7 @@ fn mine_transactions_out_of_order() {
15171517
)
15181518
.unwrap();
15191519
} else if round == 3 {
1520-
let xfer_to_contract = make_stacks_transfer(
1520+
let xfer_to_contract = make_stacks_transfer_serialized(
15211521
&sk,
15221522
3,
15231523
10,
@@ -1538,7 +1538,7 @@ fn mine_transactions_out_of_order() {
15381538
)
15391539
.unwrap();
15401540
} else if round == 4 {
1541-
let xfer_to_contract = make_stacks_transfer(
1541+
let xfer_to_contract = make_stacks_transfer_serialized(
15421542
&sk,
15431543
0,
15441544
10,
@@ -1745,7 +1745,7 @@ fn bad_contract_tx_rollback() {
17451745

17461746
if round == 1 {
17471747
// block-height = 2
1748-
let xfer_to_contract = make_stacks_transfer(
1748+
let xfer_to_contract = make_stacks_transfer_serialized(
17491749
&sk_3,
17501750
0,
17511751
10,
@@ -1771,8 +1771,14 @@ fn bad_contract_tx_rollback() {
17711771
.unwrap();
17721772
} else if round == 2 {
17731773
// block-height = 3
1774-
let xfer_to_contract =
1775-
make_stacks_transfer(&sk_3, 1, 10, CHAIN_ID_TESTNET, &addr_2.into(), 1000);
1774+
let xfer_to_contract = make_stacks_transfer_serialized(
1775+
&sk_3,
1776+
1,
1777+
10,
1778+
CHAIN_ID_TESTNET,
1779+
&addr_2.into(),
1780+
1000,
1781+
);
17761782
let (consensus_hash, block_hash) = (
17771783
&tenure.parent_block.metadata.consensus_hash,
17781784
&tenure.parent_block.metadata.anchored_header.block_hash(),
@@ -1791,8 +1797,14 @@ fn bad_contract_tx_rollback() {
17911797
.unwrap();
17921798

17931799
// doesn't consistently get mined by the StacksBlockBuilder, because order matters!
1794-
let xfer_to_contract =
1795-
make_stacks_transfer(&sk_3, 2, 10, CHAIN_ID_TESTNET, &addr_2.into(), 3000);
1800+
let xfer_to_contract = make_stacks_transfer_serialized(
1801+
&sk_3,
1802+
2,
1803+
10,
1804+
CHAIN_ID_TESTNET,
1805+
&addr_2.into(),
1806+
3000,
1807+
);
17961808
tenure
17971809
.mem_pool
17981810
.submit_raw(
@@ -2246,7 +2258,7 @@ fn mempool_errors() {
22462258
if round == 1 {
22472259
// let's submit an invalid transaction!
22482260
eprintln!("Test: POST {path} (invalid)");
2249-
let tx_xfer_invalid = make_stacks_transfer(
2261+
let tx_xfer_invalid = make_stacks_transfer_serialized(
22502262
&spender_sk,
22512263
30, // bad nonce -- too much chaining
22522264
200,
@@ -2288,7 +2300,7 @@ fn mempool_errors() {
22882300
assert_eq!(data.get("expected").unwrap().as_i64().unwrap(), 26);
22892301
assert_eq!(data.get("actual").unwrap().as_i64().unwrap(), 30);
22902302

2291-
let tx_xfer_invalid = make_stacks_transfer(
2303+
let tx_xfer_invalid = make_stacks_transfer_serialized(
22922304
&spender_sk,
22932305
0,
22942306
1, // bad fee
@@ -2322,7 +2334,7 @@ fn mempool_errors() {
23222334
assert_eq!(data.get("expected").unwrap().as_u64().unwrap(), 180);
23232335
assert_eq!(data.get("actual").unwrap().as_u64().unwrap(), 1);
23242336

2325-
let tx_xfer_invalid = make_stacks_transfer(
2337+
let tx_xfer_invalid = make_stacks_transfer_serialized(
23262338
&contract_sk,
23272339
1,
23282340
2000, // not enough funds!

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

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use stacks::chainstate::stacks::{
1616
use stacks::codec::StacksMessageCodec;
1717
use stacks::core::mempool::MemPoolDB;
1818
use stacks::core::test_util::{
19-
make_coinbase, make_contract_call, make_contract_publish, make_poison, make_stacks_transfer,
20-
sign_standard_single_sig_tx_anchor_mode_version, to_addr,
19+
make_coinbase, make_contract_call, make_contract_publish, make_poison,
20+
make_stacks_transfer_serialized, sign_standard_single_sig_tx_anchor_mode_version, to_addr,
2121
};
2222
use stacks::core::{StacksEpochId, CHAIN_ID_TESTNET};
2323
use stacks::cost_estimates::metrics::UnitMetric;
@@ -292,8 +292,14 @@ fn mempool_setup_chainstate() {
292292
)
293293
.unwrap();
294294

295-
let tx_bytes =
296-
make_stacks_transfer(&contract_sk, 5, 200, CHAIN_ID_TESTNET, &other_addr, 1000);
295+
let tx_bytes = make_stacks_transfer_serialized(
296+
&contract_sk,
297+
5,
298+
200,
299+
CHAIN_ID_TESTNET,
300+
&other_addr,
301+
1000,
302+
);
297303
let tx =
298304
StacksTransaction::consensus_deserialize(&mut tx_bytes.as_slice()).unwrap();
299305
chain_state
@@ -370,8 +376,14 @@ fn mempool_setup_chainstate() {
370376
.unwrap()
371377
.into();
372378

373-
let tx_bytes =
374-
make_stacks_transfer(&contract_sk, 5, 200, CHAIN_ID_TESTNET, &bad_addr, 1000);
379+
let tx_bytes = make_stacks_transfer_serialized(
380+
&contract_sk,
381+
5,
382+
200,
383+
CHAIN_ID_TESTNET,
384+
&bad_addr,
385+
1000,
386+
);
375387
let tx =
376388
StacksTransaction::consensus_deserialize(&mut tx_bytes.as_slice()).unwrap();
377389
let e = chain_state
@@ -386,8 +398,14 @@ fn mempool_setup_chainstate() {
386398
assert!(matches!(e, MemPoolRejection::BadAddressVersionByte));
387399

388400
// bad fees
389-
let tx_bytes =
390-
make_stacks_transfer(&contract_sk, 5, 0, CHAIN_ID_TESTNET, &other_addr, 1000);
401+
let tx_bytes = make_stacks_transfer_serialized(
402+
&contract_sk,
403+
5,
404+
0,
405+
CHAIN_ID_TESTNET,
406+
&other_addr,
407+
1000,
408+
);
391409
let tx =
392410
StacksTransaction::consensus_deserialize(&mut tx_bytes.as_slice()).unwrap();
393411
let e = chain_state
@@ -403,8 +421,14 @@ fn mempool_setup_chainstate() {
403421
assert!(matches!(e, MemPoolRejection::FeeTooLow(0, _)));
404422

405423
// bad nonce
406-
let tx_bytes =
407-
make_stacks_transfer(&contract_sk, 0, 200, CHAIN_ID_TESTNET, &other_addr, 1000);
424+
let tx_bytes = make_stacks_transfer_serialized(
425+
&contract_sk,
426+
0,
427+
200,
428+
CHAIN_ID_TESTNET,
429+
&other_addr,
430+
1000,
431+
);
408432
let tx =
409433
StacksTransaction::consensus_deserialize(&mut tx_bytes.as_slice()).unwrap();
410434
let e = chain_state
@@ -420,7 +444,7 @@ fn mempool_setup_chainstate() {
420444
assert!(matches!(e, MemPoolRejection::BadNonces(_)));
421445

422446
// not enough funds
423-
let tx_bytes = make_stacks_transfer(
447+
let tx_bytes = make_stacks_transfer_serialized(
424448
&contract_sk,
425449
5,
426450
110000,
@@ -444,7 +468,7 @@ fn mempool_setup_chainstate() {
444468

445469
// sender == recipient
446470
let contract_princ = PrincipalData::from(contract_addr);
447-
let tx_bytes = make_stacks_transfer(
471+
let tx_bytes = make_stacks_transfer_serialized(
448472
&contract_sk,
449473
5,
450474
300,
@@ -478,7 +502,7 @@ fn mempool_setup_chainstate() {
478502
)
479503
.unwrap();
480504
let mainnet_princ = mainnet_recipient.into();
481-
let tx_bytes = make_stacks_transfer(
505+
let tx_bytes = make_stacks_transfer_serialized(
482506
&contract_sk,
483507
5,
484508
300,
@@ -531,8 +555,14 @@ fn mempool_setup_chainstate() {
531555
assert!(matches!(e, MemPoolRejection::BadTransactionVersion));
532556

533557
// send amount must be positive
534-
let tx_bytes =
535-
make_stacks_transfer(&contract_sk, 5, 300, CHAIN_ID_TESTNET, &other_addr, 0);
558+
let tx_bytes = make_stacks_transfer_serialized(
559+
&contract_sk,
560+
5,
561+
300,
562+
CHAIN_ID_TESTNET,
563+
&other_addr,
564+
0,
565+
);
536566
let tx =
537567
StacksTransaction::consensus_deserialize(&mut tx_bytes.as_slice()).unwrap();
538568
let e = chain_state
@@ -548,7 +578,7 @@ fn mempool_setup_chainstate() {
548578
assert!(matches!(e, MemPoolRejection::TransferAmountMustBePositive));
549579

550580
// not enough funds
551-
let tx_bytes = make_stacks_transfer(
581+
let tx_bytes = make_stacks_transfer_serialized(
552582
&contract_sk,
553583
5,
554584
110000,
@@ -570,7 +600,7 @@ fn mempool_setup_chainstate() {
570600
eprintln!("Err: {e:?}");
571601
assert!(matches!(e, MemPoolRejection::NotEnoughFunds(111000, 99500)));
572602

573-
let tx_bytes = make_stacks_transfer(
603+
let tx_bytes = make_stacks_transfer_serialized(
574604
&contract_sk,
575605
5,
576606
99700,

0 commit comments

Comments
 (0)