Skip to content

Commit 1e411b4

Browse files
committed
improved mint tests
1 parent 88a00f9 commit 1e411b4

File tree

2 files changed

+54
-17
lines changed

2 files changed

+54
-17
lines changed

stacks-node/src/tests/nakamoto_integrations.rs

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12892,10 +12892,6 @@ fn test_sip_031_activation() {
1289212892
if burn_block_height
1289312893
== naka_conf.burnchain.epochs.clone().unwrap()[StacksEpochId::Epoch32].start_height
1289412894
{
12895-
println!(
12896-
"\n\nOOPS {:?}\n\n",
12897-
block.get("transactions").unwrap().as_array().unwrap()
12898-
);
1289912895
// the first transaction is the coinbase
1290012896
coinbase_txid = Some(
1290112897
block
@@ -13131,7 +13127,7 @@ fn test_sip_031_last_phase() {
1313113127
);
1313213128

1313313129
// get current liquidity
13134-
let _sip_031_current_liquid_ustx = chainstate
13130+
let sip_031_current_liquid_ustx_before = chainstate
1313513131
.with_read_only_clarity_tx(
1313613132
&sortdb
1313713133
.index_handle_at_block(&chainstate, &latest_stacks_block_id)
@@ -13141,7 +13137,7 @@ fn test_sip_031_last_phase() {
1314113137
)
1314213138
.unwrap();
1314313139

13144-
// 50 more tenures...
13140+
// 50 more tenures (each one with 3 stacks blocks)
1314513141
for _ in 0..50 {
1314613142
let commits_before = commits_submitted.load(Ordering::SeqCst);
1314713143
next_block_and_process_new_stacks_blocks(
@@ -13168,17 +13164,41 @@ fn test_sip_031_last_phase() {
1316813164
naka_conf.is_mainnet(),
1316913165
);
1317013166

13167+
// check for mint events for the SIP-031 boot contract (excluding the activation one)
1317113168
let events = block.get("events").unwrap().as_array().unwrap();
1317213169
for event in events {
1317313170
if let Some(mint_event) = event.get("stx_mint_event") {
13174-
let minted_amount =
13175-
u128::try_from(mint_event.get("amount").unwrap().as_u64().unwrap()).unwrap();
13176-
assert_eq!(sip_031_mint_and_transfer_amount, minted_amount);
13177-
total_minted_and_transferred += minted_amount;
13178-
break;
13171+
if mint_event.get("recipient").unwrap().as_str().unwrap()
13172+
== boot_code_id(SIP_031_NAME, naka_conf.is_mainnet()).to_string()
13173+
&& burn_block_height != epoch32_start_height
13174+
{
13175+
let minted_amount = mint_event
13176+
.get("amount")
13177+
.unwrap()
13178+
.as_str()
13179+
.unwrap()
13180+
.parse::<u128>()
13181+
.unwrap();
13182+
assert_eq!(sip_031_mint_and_transfer_amount, minted_amount);
13183+
total_minted_and_transferred += minted_amount;
13184+
13185+
let coinbase_txid = block
13186+
.get("transactions")
13187+
.unwrap()
13188+
.as_array()
13189+
.unwrap()
13190+
.get(1)
13191+
.unwrap()
13192+
.get("txid")
13193+
.unwrap()
13194+
.as_str()
13195+
.unwrap();
13196+
13197+
// check the event txid is mapped to the coinbase
13198+
assert_eq!(event.get("txid").unwrap().as_str().unwrap(), coinbase_txid);
13199+
}
1317913200
}
1318013201
}
13181-
total_minted_and_transferred += sip_031_mint_and_transfer_amount;
1318213202
}
1318313203

1318413204
// (100_000 + 200_000 + 300_000) * 5
@@ -13212,6 +13232,23 @@ fn test_sip_031_last_phase() {
1321213232
}))
1321313233
);
1321413234

13235+
// get current liquidity
13236+
let sip_031_current_liquid_ustx = chainstate
13237+
.with_read_only_clarity_tx(
13238+
&sortdb
13239+
.index_handle_at_block(&chainstate, &latest_stacks_block_id)
13240+
.unwrap(),
13241+
&latest_stacks_block_id,
13242+
|conn| conn.with_clarity_db_readonly(|db| db.get_total_liquid_ustx().unwrap()),
13243+
)
13244+
.unwrap();
13245+
13246+
// check liquidity has been updated accordingly
13247+
assert!(
13248+
sip_031_current_liquid_ustx - sip_031_current_liquid_ustx_before
13249+
>= total_minted_and_transferred
13250+
);
13251+
1321513252
set_test_sip_031_emission_schedule(None);
1321613253

1321713254
coord_channel

stackslib/src/chainstate/nakamoto/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -641,23 +641,23 @@ pub static SIP031_EMISSION_INTERVALS_TESTNET: LazyLock<[SIP031EmissionInterval;
641641
start_height: 2_600,
642642
},
643643
SIP031EmissionInterval {
644-
amount: 0,
644+
amount: 5_000,
645645
start_height: 2_500,
646646
},
647647
SIP031EmissionInterval {
648-
amount: 0,
648+
amount: 4_000,
649649
start_height: 2_400,
650650
},
651651
SIP031EmissionInterval {
652-
amount: 0,
652+
amount: 3_000,
653653
start_height: 2_300,
654654
},
655655
SIP031EmissionInterval {
656-
amount: 0,
656+
amount: 2_000,
657657
start_height: 2_200,
658658
},
659659
SIP031EmissionInterval {
660-
amount: 0,
660+
amount: 1_000,
661661
start_height: 2_100,
662662
},
663663
];

0 commit comments

Comments
 (0)