From 1fd7aef8389a372c0f5fd1258343baf58093457b Mon Sep 17 00:00:00 2001 From: 0xLugon Date: Sat, 20 Apr 2024 02:51:20 +0700 Subject: [PATCH] Add test Rune cannot be minted less than limit amount (#3556) --- src/runes.rs | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/src/runes.rs b/src/runes.rs index 75a3436cbf..aea423d8f8 100644 --- a/src/runes.rs +++ b/src/runes.rs @@ -3909,6 +3909,100 @@ mod tests { ); } + #[test] + fn rune_cannot_be_minted_less_than_limit_amount() { + 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), + cap: Some(100), + ..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, + mints: 0, + terms: Some(Terms { + amount: Some(1000), + cap: Some(100), + ..default() + }), + ..default() + }, + )], + [], + ); + + let txid1 = context.core.broadcast_tx(TransactionTemplate { + inputs: &[(2, 0, 0, Witness::new())], + outputs: 2, + op_return: Some( + Runestone { + mint: Some(id), + edicts: vec![Edict { + id, + amount: 111, + output: 0, + }], + ..default() + } + .encipher(), + ), + ..default() + }); + + context.mine_blocks(1); + + context.assert_runes( + [( + id, + RuneEntry { + block: id.block, + etching: txid0, + terms: Some(Terms { + amount: Some(1000), + cap: Some(100), + ..default() + }), + mints: 1, + spaced_rune: SpacedRune { + rune: Rune(RUNE), + spacers: 0, + }, + premine: 0, + timestamp: id.block, + ..default() + }, + )], + [( + OutPoint { + txid: txid1, + vout: 0, + }, + vec![(id, 1000)], + )], + ); + } + #[test] fn etching_with_amount_can_be_minted() { let context = Context::builder().arg("--index-runes").build();