Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix off-by-one in wallet when waiting for etching commitment to mature #3515

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,15 @@ impl Wallet {
.into_option()?;

if let Some(transaction) = transaction {
if u32::try_from(transaction.info.confirmations).unwrap()
if u32::try_from(transaction.info.confirmations).unwrap() + 1
>= Runestone::COMMIT_CONFIRMATIONS.into()
{
let tx_out = self
.bitcoin_client()
.get_tx_out(&commit.txid(), 0, Some(true))?;

if let Some(tx_out) = tx_out {
if tx_out.confirmations >= Runestone::COMMIT_CONFIRMATIONS.into() {
if tx_out.confirmations + 1 >= Runestone::COMMIT_CONFIRMATIONS.into() {
break;
}
} else {
Expand Down
16 changes: 8 additions & 8 deletions tests/json_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,10 @@ fn get_runes() {
spacers: 0
},
symbol: Some('¢'),
timestamp: 11,
timestamp: 10,
turbo: false,
},
id: RuneId { block: 11, tx: 1 },
id: RuneId { block: 10, tx: 1 },
mintable: false,
parent: Some(InscriptionId {
txid: a.output.reveal,
Expand All @@ -568,7 +568,7 @@ fn get_runes() {
api::Runes {
entries: vec![
(
RuneId { block: 11, tx: 1 },
RuneId { block: 10, tx: 1 },
RuneEntry {
block: a.id.block,
burned: 0,
Expand All @@ -583,12 +583,12 @@ fn get_runes() {
spacers: 0
},
symbol: Some('¢'),
timestamp: 11,
timestamp: 10,
turbo: false,
}
),
(
RuneId { block: 19, tx: 1 },
RuneId { block: 17, tx: 1 },
RuneEntry {
block: b.id.block,
burned: 0,
Expand All @@ -603,12 +603,12 @@ fn get_runes() {
spacers: 0
},
symbol: Some('¢'),
timestamp: 19,
timestamp: 17,
turbo: false,
}
),
(
RuneId { block: 27, tx: 1 },
RuneId { block: 24, tx: 1 },
RuneEntry {
block: c.id.block,
burned: 0,
Expand All @@ -623,7 +623,7 @@ fn get_runes() {
spacers: 0
},
symbol: Some('¢'),
timestamp: 27,
timestamp: 24,
turbo: false,
}
)
Expand Down
2 changes: 1 addition & 1 deletion tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fn batch(core: &mockcore::Handle, ord: &TestServer, batchfile: batch::File) -> E
"Waiting for rune commitment [[:xdigit:]]{64} to mature…\n"
);

core.mine_blocks(6);
core.mine_blocks(5);

let output = spawn.run_and_deserialize_output::<Batch>();

Expand Down
18 changes: 9 additions & 9 deletions tests/runes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ fn one_rune() {
runes: vec![(
Rune(RUNE),
RuneInfo {
block: 8,
block: 7,
burned: 0,
divisibility: 0,
etching: etch.output.reveal,
id: RuneId { block: 8, tx: 1 },
id: RuneId { block: 7, tx: 1 },
terms: None,
mints: 0,
number: 0,
Expand All @@ -61,7 +61,7 @@ fn one_rune() {
},
supply: 1000,
symbol: Some('¢'),
timestamp: ord::timestamp(8),
timestamp: ord::timestamp(7),
turbo: false,
tx: 1,
}
Expand Down Expand Up @@ -92,11 +92,11 @@ fn two_runes() {
(
Rune(RUNE),
RuneInfo {
block: 8,
block: 7,
burned: 0,
divisibility: 0,
etching: a.output.reveal,
id: RuneId { block: 8, tx: 1 },
id: RuneId { block: 7, tx: 1 },
terms: None,
mints: 0,
number: 0,
Expand All @@ -107,19 +107,19 @@ fn two_runes() {
},
supply: 1000,
symbol: Some('¢'),
timestamp: ord::timestamp(8),
timestamp: ord::timestamp(7),
turbo: false,
tx: 1,
}
),
(
Rune(RUNE + 1),
RuneInfo {
block: 16,
block: 14,
burned: 0,
divisibility: 0,
etching: b.output.reveal,
id: RuneId { block: 16, tx: 1 },
id: RuneId { block: 14, tx: 1 },
terms: None,
mints: 0,
number: 1,
Expand All @@ -130,7 +130,7 @@ fn two_runes() {
},
supply: 1000,
symbol: Some('¢'),
timestamp: ord::timestamp(16),
timestamp: ord::timestamp(14),
turbo: false,
tx: 1,
}
Expand Down
8 changes: 4 additions & 4 deletions tests/wallet/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn runic_utxos_are_deducted_from_cardinal() {
.ord(&ord)
.run_and_deserialize_output::<Balance>(),
Balance {
cardinal: 50 * COIN_VALUE * 8 - 20_000,
cardinal: 50 * COIN_VALUE * 7 - 20_000,
ordinal: 10000,
runic: Some(10_000),
runes: Some(
Expand All @@ -138,7 +138,7 @@ fn runic_utxos_are_deducted_from_cardinal() {
.into_iter()
.collect()
),
total: 50 * COIN_VALUE * 8,
total: 50 * COIN_VALUE * 7,
}
);
}
Expand Down Expand Up @@ -240,7 +240,7 @@ fn runic_utxos_are_displayed_with_decimal_amount() {
.ord(&ord)
.run_and_deserialize_output::<Balance>(),
Balance {
cardinal: 50 * COIN_VALUE * 8 - 20_000,
cardinal: 50 * COIN_VALUE * 7 - 20_000,
ordinal: 10000,
runic: Some(10_000),
runes: Some(
Expand All @@ -254,7 +254,7 @@ fn runic_utxos_are_displayed_with_decimal_amount() {
.into_iter()
.collect()
),
total: 50 * COIN_VALUE * 8,
total: 50 * COIN_VALUE * 7,
}
);
}
8 changes: 4 additions & 4 deletions tests/wallet/batch_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1504,7 +1504,7 @@ fn batch_can_etch_rune() {
.ord(&ord)
.run_and_deserialize_output::<Balance>(),
Balance {
cardinal: 44999980000,
cardinal: 39999980000,
ordinal: 10000,
runic: Some(10000),
runes: Some(
Expand All @@ -1518,7 +1518,7 @@ fn batch_can_etch_rune() {
.into_iter()
.collect()
),
total: 450 * COIN_VALUE,
total: 400 * COIN_VALUE,
}
);
}
Expand Down Expand Up @@ -1645,11 +1645,11 @@ fn batch_can_etch_rune_without_premine() {
.ord(&ord)
.run_and_deserialize_output::<Balance>(),
Balance {
cardinal: 44999990000,
cardinal: 39999990000,
ordinal: 10000,
runic: Some(0),
runes: Some(default()),
total: 450 * COIN_VALUE,
total: 400 * COIN_VALUE,
}
);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/wallet/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fn minting_rune_and_fails_if_after_end() {
.core(&core)
.ord(&ord)
.expected_exit_code(1)
.expected_stderr("error: rune AAAAAAAAAAAAA mint ended on block 11\n")
.expected_stderr("error: rune AAAAAAAAAAAAA mint ended on block 10\n")
.run_and_extract_stdout();
}

Expand Down
Loading