From a973817b06740cca6a065ff3aea9e7fa63eecbee Mon Sep 17 00:00:00 2001 From: Lugon LQ <48004924+lugondev@users.noreply.github.com> Date: Tue, 16 Apr 2024 13:34:21 +0700 Subject: [PATCH 1/2] add test --- src/runes.rs | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/src/runes.rs b/src/runes.rs index 3a247aa12a..eef7586376 100644 --- a/src/runes.rs +++ b/src/runes.rs @@ -3909,6 +3909,99 @@ 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())], + 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(); From ae59d5d874b6565763683210fcba2baae2b61542 Mon Sep 17 00:00:00 2001 From: Lugon LQ <48004924+lugondev@users.noreply.github.com> Date: Thu, 18 Apr 2024 02:30:00 +0700 Subject: [PATCH 2/2] add two outputs transaction --- src/runes.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/runes.rs b/src/runes.rs index eef7586376..9888edb07c 100644 --- a/src/runes.rs +++ b/src/runes.rs @@ -3954,6 +3954,7 @@ mod tests { let txid1 = context.core.broadcast_tx(TransactionTemplate { inputs: &[(2, 0, 0, Witness::new())], + outputs: 2, op_return: Some( Runestone { mint: Some(id),