From 6eddd410277b163d3528d99af69d634706f3b9b8 Mon Sep 17 00:00:00 2001 From: 0xLugon Date: Thu, 11 Apr 2024 10:35:25 +0700 Subject: [PATCH] Test that mints without a cap are unmintable (#3495) Test that if the `cap` field of an etching is unset, it is treated as being zero, and the rune is unmintable.Test that if the `cap` field of an etching is unset, it is treated as being zero, and the rune is unmintable. --- src/runes.rs | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/src/runes.rs b/src/runes.rs index 0117dbc5fc..e3b8caed91 100644 --- a/src/runes.rs +++ b/src/runes.rs @@ -4770,6 +4770,91 @@ mod tests { ); } + #[test] + fn open_mints_without_a_cap_are_unmintable() { + let context = Context::builder().arg("--index-runes").build(); + + let (txid0, id) = context.etch( + Runestone { + etching: Some(Etching { + rune: Some(Rune(RUNE)), + terms: Some(Terms { + amount: Some(1000), + offset: (None, Some(2)), + ..default() + }), + ..default() + }), + ..default() + }, + 1, + ); + + context.assert_runes( + [( + id, + RuneEntry { + block: id.block, + etching: txid0, + spaced_rune: SpacedRune { + rune: Rune(RUNE), + spacers: 0, + }, + timestamp: id.block, + terms: Some(Terms { + amount: Some(1000), + offset: (None, Some(2)), + ..default() + }), + ..default() + }, + )], + [], + ); + + context.core.broadcast_tx(TransactionTemplate { + inputs: &[(2, 0, 0, Witness::new())], + op_return: Some( + Runestone { + edicts: vec![Edict { + id, + amount: 1000, + output: 0, + }], + mint: Some(id), + ..default() + } + .encipher(), + ), + ..default() + }); + + context.mine_blocks(1); + + context.assert_runes( + [( + id, + RuneEntry { + block: id.block, + spaced_rune: SpacedRune { + rune: Rune(RUNE), + spacers: 0, + }, + timestamp: id.block, + mints: 0, + etching: txid0, + terms: Some(Terms { + amount: Some(1000), + offset: (None, Some(2)), + ..default() + }), + ..default() + }, + )], + [], + ); + } + #[test] fn open_mint_claims_can_use_split() { let context = Context::builder().arg("--index-runes").build();