Skip to content

Commit

Permalink
Merge branch 'develop' into stakenet-8
Browse files Browse the repository at this point in the history
  • Loading branch information
mappum authored Feb 15, 2024
2 parents 8c79cda + 4743a33 commit fa72f8e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
toolchain: nightly-2023-05-08
override: true
- name: Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cargo
Expand All @@ -51,7 +51,7 @@ jobs:
toolchain: nightly-2023-05-08
override: true
- name: Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cargo
Expand All @@ -76,7 +76,7 @@ jobs:
toolchain: nightly-2023-05-08
override: true
- name: Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cargo
Expand Down Expand Up @@ -137,7 +137,7 @@ jobs:
override: true
- name: Cache
id: cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cargo
Expand Down Expand Up @@ -192,7 +192,7 @@ jobs:
components: clippy
override: true
- name: Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cargo
Expand Down
4 changes: 3 additions & 1 deletion src/bitcoin/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,8 @@ impl Config {
min_checkpoint_interval: 15,
emergency_disbursal_lock_time_interval: 60,
emergency_disbursal_max_tx_size: 11,
user_fee_factor: 20_000,
max_age: 60 * 60 * 24 * 7 * 3,
..Config::bitcoin()
}
}
Expand All @@ -1086,7 +1088,7 @@ impl Config {
max_checkpoint_interval: 60 * 60 * 8,
max_inputs: 40,
max_outputs: 200,
max_age: 60 * 60 * 24 * 30 * 4,
max_age: 60 * 60 * 24 * 7 * 3,
target_checkpoint_inclusion: 2,
min_fee_rate: 2, // relay threshold is 1 sat/vbyte
max_fee_rate: 200,
Expand Down
2 changes: 2 additions & 0 deletions src/bitcoin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ impl Config {
Self {
min_withdrawal_checkpoints: 1,
max_offline_checkpoints: 1,
min_confirmations: 0,
fee_pool_target_balance: 10_000_000,
..Self::bitcoin()
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,18 @@ pub async fn poll_for_updated_balance(address: Address, expected_balance: u64) -
return initial_balance.into();
}

let mut count = 0;
loop {
let balance = app_client(DEFAULT_RPC)
.query(|app| app.bitcoin.accounts.balance(address))
.await
.unwrap();
if balance != initial_balance {
if count >= 60 || balance != initial_balance {
break balance.into();
}

tokio::time::sleep(Duration::from_secs(1)).await;
count += 1;
}
}

Expand Down
16 changes: 12 additions & 4 deletions tests/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ async fn bitcoin_test() {

tx.send(Some(())).await.unwrap();

let expected_balance = 989996715180000;
let expected_balance = 989996871600000;
let balance = poll_for_updated_balance(funded_accounts[0].address, expected_balance).await;
assert_eq!(balance, Amount::from(expected_balance));

Expand Down Expand Up @@ -466,6 +466,14 @@ async fn bitcoin_test() {
.await
.unwrap();

app_client()
.with_wallet(funded_accounts[0].wallet.clone())
.call(
move |app| build_call!(app.accounts.take_as_funding((MIN_FEE).into())),
move |app| build_call!(app.bitcoin.transfer_to_fee_pool(8000000000.into())),
)
.await?;

btc_client
.generate_to_address(4, &async_wallet_address)
.await
Expand All @@ -486,7 +494,7 @@ async fn bitcoin_test() {
.unwrap();
assert!(signer_jailed);

let expected_balance = 989989871600000;
let expected_balance = 989981871600000;
let balance = poll_for_updated_balance(funded_accounts[0].address, expected_balance).await;
assert_eq!(balance, Amount::from(expected_balance));

Expand Down Expand Up @@ -533,7 +541,7 @@ async fn bitcoin_test() {
}
}
}
assert_eq!(signatory_balance, 49986239);
assert_eq!(signatory_balance, 49994239);

let funded_account_balances: Vec<_> = funded_accounts
.iter()
Expand All @@ -548,7 +556,7 @@ async fn bitcoin_test() {
})
.collect();

let expected_account_balances: Vec<u64> = vec![989988029, 0, 0, 0];
let expected_account_balances: Vec<u64> = vec![989980029, 0, 0, 0];
assert_eq!(funded_account_balances, expected_account_balances);

for (i, account) in funded_accounts[0..1].iter().enumerate() {
Expand Down

0 comments on commit fa72f8e

Please sign in to comment.