@@ -685,6 +685,59 @@ describe('mint', () => {
685685 } ) ;
686686} ) ;
687687
688+ test ( 'mint is valid for etching in same block' , async ( ) => {
689+ const { runeUpdater, storage } = getDefaultRuneUpdaterContext ( ) ;
690+
691+ storage . getValidMintCount . mockResolvedValue ( 0 ) ;
692+
693+ const tx1 : UpdaterTx = {
694+ txid : 'txid1' ,
695+ vin : [ { txid : 'parenttxid' , vout : 1 , txinwitness : [ ] } ] ,
696+ vout : [
697+ {
698+ scriptPubKey : {
699+ hex : getDeployRunestoneHex ( {
700+ etching : { terms : { amount : 100 , cap : 1 } } ,
701+ } ) ,
702+ } ,
703+ } ,
704+ MAGIC_EDEN_OUTPUT ,
705+ ] ,
706+ } ;
707+ await runeUpdater . indexRunes ( tx1 , 21 ) ;
708+
709+ const tx2 : UpdaterTx = {
710+ txid : 'txid2' ,
711+ vin : [ { txid : 'parenttxid' , vout : 2 , txinwitness : [ ] } ] ,
712+ vout : [
713+ {
714+ scriptPubKey : {
715+ hex : getDeployRunestoneHex ( {
716+ edicts : [ { id : [ 100000 , 21 ] , amount : 100 , output : 1 } ] ,
717+ mint : [ 100000 , 21 ] ,
718+ } ) ,
719+ } ,
720+ } ,
721+ MAGIC_EDEN_OUTPUT ,
722+ ] ,
723+ } ;
724+
725+ await runeUpdater . indexRunes ( tx2 , 88 ) ;
726+
727+ expect ( runeUpdater . etchings . length ) . toBe ( 1 ) ;
728+ expect ( runeUpdater . utxoBalances . length ) . toBe ( 1 ) ;
729+ expect ( runeUpdater . utxoBalances [ 0 ] ) . toMatchObject ( {
730+ txid : 'txid2' ,
731+ vout : 1 ,
732+ rune : 'AAAAAAAAAAAAAAAADBCSMALNGAF' ,
733+ runeId : {
734+ block : 100000 ,
735+ tx : 21 ,
736+ } ,
737+ amount : 100n ,
738+ } ) ;
739+ } ) ;
740+
688741describe ( 'edict' , ( ) => {
689742 test ( 'edicts successfully moves runes' , async ( ) => {
690743 const { runeUpdater, storage } = getDefaultRuneUpdaterContext ( ) ;
@@ -765,6 +818,76 @@ describe('edict', () => {
765818 } ) ;
766819 } ) ;
767820
821+ test ( 'edicts chained successfully moves runes' , async ( ) => {
822+ const { runeUpdater, storage } = getDefaultRuneUpdaterContext ( ) ;
823+ const tx1 : UpdaterTx = {
824+ txid : 'txid' ,
825+ vin : [ { txid : 'parenttxid' , vout : 0 , txinwitness : [ ] } ] ,
826+ vout : [
827+ {
828+ scriptPubKey : {
829+ hex : getDeployRunestoneHex ( { } ) ,
830+ } ,
831+ } ,
832+ MAGIC_EDEN_OUTPUT ,
833+ ] ,
834+ } ;
835+ const tx2 : UpdaterTx = {
836+ txid : 'childtxid' ,
837+ vin : [ { txid : 'txid' , vout : 1 , txinwitness : [ ] } ] ,
838+ vout : [ MAGIC_EDEN_OUTPUT ] ,
839+ } ;
840+
841+ storage . getUtxoBalance . mockResolvedValueOnce ( [
842+ {
843+ txid : 'parenttxid' ,
844+ vout : 0 ,
845+ amount : 400n ,
846+ rune : 'TESTRUNE' ,
847+ runeId : { block : 888 , tx : 8 } ,
848+ scriptPubKey : Buffer . from ( 'a914ea6b832a05c6ca578baa3836f3f25553d41068a587' , 'hex' ) ,
849+ address : '3P4WqXDbSLRhzo2H6MT6YFbvBKBDPLbVtQ' ,
850+ } ,
851+ ] ) ;
852+
853+ storage . getEtching . mockResolvedValue ( {
854+ valid : true ,
855+ txid : 'txid' ,
856+ rune : 'TESTRUNE' ,
857+ runeId : { block : 888 , tx : 8 } ,
858+ terms : { amount : 500n , cap : 1n } ,
859+ } ) ;
860+
861+ await runeUpdater . indexRunes ( tx1 , 88 ) ;
862+ await runeUpdater . indexRunes ( tx2 , 89 ) ;
863+ expect ( runeUpdater . etchings . length ) . toBe ( 0 ) ;
864+ expect ( runeUpdater . utxoBalances . length ) . toBe ( 2 ) ;
865+ expect ( runeUpdater . utxoBalances [ 0 ] ) . toMatchObject ( {
866+ txid : 'txid' ,
867+ vout : 1 ,
868+ rune : 'TESTRUNE' ,
869+ runeId : {
870+ block : 888 ,
871+ tx : 8 ,
872+ } ,
873+ amount : 400n ,
874+ } ) ;
875+ expect ( runeUpdater . utxoBalances [ 1 ] ) . toMatchObject ( {
876+ txid : 'childtxid' ,
877+ vout : 0 ,
878+ rune : 'TESTRUNE' ,
879+ runeId : {
880+ block : 888 ,
881+ tx : 8 ,
882+ } ,
883+ amount : 400n ,
884+ } ) ;
885+ expect ( runeUpdater . spentOutputs ) . toEqual ( [
886+ { txid : 'parenttxid' , vout : 0 } ,
887+ { txid : 'txid' , vout : 1 } ,
888+ ] ) ;
889+ } ) ;
890+
768891 test ( 'edict with invalid output is cenotaph' , async ( ) => {
769892 const { runeUpdater, storage } = getDefaultRuneUpdaterContext ( ) ;
770893 const tx : UpdaterTx = {
0 commit comments