Skip to content

Commit 98aed37

Browse files
committed
WIP: cannot seem to mine a second stacks blocks
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent 2016d02 commit 98aed37

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

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

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ fn simple_neon_integration() {
945945
let send_fee = 100;
946946
naka_conf.add_initial_balance(
947947
PrincipalData::from(sender_addr.clone()).to_string(),
948-
send_amt + send_fee,
948+
send_amt * 2 + send_fee,
949949
);
950950
let sender_signer_sk = Secp256k1PrivateKey::new();
951951
let sender_signer_addr = tests::to_addr(&sender_signer_sk);
@@ -3168,11 +3168,13 @@ fn forked_tenure_is_ignored() {
31683168
);
31693169
let sender_signer_sk = Secp256k1PrivateKey::new();
31703170
let sender_signer_addr = tests::to_addr(&sender_signer_sk);
3171+
let recipient = PrincipalData::from(StacksAddress::burn_address(false));
31713172
naka_conf.add_initial_balance(
31723173
PrincipalData::from(sender_signer_addr.clone()).to_string(),
31733174
100000,
31743175
);
31753176
let stacker_sk = setup_stacker(&mut naka_conf);
3177+
let http_origin = format!("http://{}", &naka_conf.node.rpc_bind);
31763178

31773179
test_observer::spawn();
31783180
let observer_port = test_observer::EVENT_OBSERVER_PORT;
@@ -3318,11 +3320,20 @@ fn forked_tenure_is_ignored() {
33183320

33193321
// Now let's produce a second block for tenure C and ensure it builds off of block C.
33203322
let blocks_before = mined_blocks.load(Ordering::SeqCst);
3321-
next_block_and(&mut btc_regtest_controller, 60, || {
3322-
let blocks_count = mined_blocks.load(Ordering::SeqCst);
3323-
Ok(blocks_count > blocks_before)
3324-
})
3325-
.unwrap();
3323+
let start_time = Instant::now();
3324+
// submit a tx so that the miner will mine an extra block
3325+
let sender_nonce = 0;
3326+
let transfer_tx =
3327+
make_stacks_transfer(&sender_sk, sender_nonce, send_fee, &recipient, send_amt);
3328+
submit_tx(&http_origin, &transfer_tx);
3329+
info!("Tenure C is mining a second block");
3330+
while mined_blocks.load(Ordering::SeqCst) <= blocks_before {
3331+
assert!(
3332+
start_time.elapsed() < Duration::from_secs(45),
3333+
"FAIL: Test timed out while waiting for block production",
3334+
);
3335+
thread::sleep(Duration::from_secs(1));
3336+
}
33263337

33273338
info!("Tenure C produced a second block!");
33283339

@@ -3333,21 +3344,16 @@ fn forked_tenure_is_ignored() {
33333344
let block_2_c = blocks.last().unwrap();
33343345

33353346
info!("Starting tenure D.");
3336-
// Submit a block commit op for tenure D
3347+
// Submit a block commit op for tenure D and mine a stacks block
33373348
let commits_before = commits_submitted.load(Ordering::SeqCst);
3338-
next_block_and(&mut btc_regtest_controller, 60, || {
3339-
let commits_count = commits_submitted.load(Ordering::SeqCst);
3340-
Ok(commits_count > commits_before)
3341-
})
3342-
.unwrap();
3343-
3344-
// Wait for a stacks block to be broadcasted
33453349
let blocks_before = mined_blocks.load(Ordering::SeqCst);
33463350
next_block_and(&mut btc_regtest_controller, 60, || {
3351+
let commits_count = commits_submitted.load(Ordering::SeqCst);
33473352
let blocks_count = mined_blocks.load(Ordering::SeqCst);
3348-
Ok(blocks_count > blocks_before)
3353+
Ok(commits_count > commits_before && blocks_count > blocks_before)
33493354
})
33503355
.unwrap();
3356+
33513357
let block_tenure_d = NakamotoChainState::get_canonical_block_header(chainstate.db(), &sortdb)
33523358
.unwrap()
33533359
.unwrap();

0 commit comments

Comments
 (0)